Nick Ficano commited on
Commit
5e1a0c2
·
1 Parent(s): b0c3c02

more docstrings prep for autodocs :)

Browse files
Files changed (2) hide show
  1. pytube/api.py +2 -0
  2. pytube/models.py +10 -12
pytube/api.py CHANGED
@@ -55,6 +55,8 @@ YT_QUALITY_PROFILE_KEYS = (
55
 
56
 
57
  class YouTube(object):
 
 
58
  def __init__(self, url=None):
59
  """Initializes YouTube API wrapper.
60
 
 
55
 
56
 
57
  class YouTube(object):
58
+ """Class representation of a single instance of a YouTube session.
59
+ """
60
  def __init__(self, url=None):
61
  """Initializes YouTube API wrapper.
62
 
pytube/models.py CHANGED
@@ -1,8 +1,7 @@
1
  #!/usr/bin/env python
2
  # -*- coding: utf-8 -*-
3
- from __future__ import unicode_literals, print_function
4
- from os import remove
5
- from os.path import normpath, isfile, isdir
6
  from time import clock
7
 
8
  try:
@@ -32,14 +31,13 @@ class Video(object):
32
 
33
  def download(self, path='', chunk_size=8 * 1024, on_progress=None,
34
  on_finish=None, force_overwrite=False):
35
- """Downloads the file of the URL defined within the class
36
- instance.
37
 
38
  :param str path:
39
  The destination output directory.
40
  :param int chunk_size:
41
- File size (in bytes) to write to buffer at a time (default: 8
42
- bytes).
43
  :param func on_progress:
44
  The function to be called every time the buffer is written
45
  to. Arguments passed are the bytes recieved, file size, and start
@@ -50,15 +48,15 @@ class Video(object):
50
  :param bool force_overwrite:
51
  Force a file overwrite if conflicting one exists.
52
  """
53
- if isdir(normpath(path)):
54
- path = (normpath(path) + '/' if path else '')
55
  fullpath = '{}{}.{}'.format(path, self.filename, self.extension)
56
  else:
57
- fullpath = normpath(path)
58
 
59
  # TODO: Move this into cli, this kind of logic probably shouldn't be
60
  # handled by the library.
61
- if isfile(fullpath) and not force_overwrite:
62
  raise OSError("Conflicting filename:'{}'".format(self.filename))
63
 
64
  response = urlopen(self.url)
@@ -95,7 +93,7 @@ class Video(object):
95
  except KeyboardInterrupt:
96
  # TODO: Move this into the cli, ``KeyboardInterrupt`` handling
97
  # should be taken care of by the client.
98
- remove(fullpath)
99
  raise KeyboardInterrupt("Interrupt signal given. Deleting "
100
  "incomplete video.")
101
 
 
1
  #!/usr/bin/env python
2
  # -*- coding: utf-8 -*-
3
+ from __future__ import unicode_literals
4
+ import os
 
5
  from time import clock
6
 
7
  try:
 
31
 
32
  def download(self, path='', chunk_size=8 * 1024, on_progress=None,
33
  on_finish=None, force_overwrite=False):
34
+ """Downloads the video.
 
35
 
36
  :param str path:
37
  The destination output directory.
38
  :param int chunk_size:
39
+ File size (in bytes) to write to buffer at a time. By default,
40
+ this is set to 8 bytes.
41
  :param func on_progress:
42
  The function to be called every time the buffer is written
43
  to. Arguments passed are the bytes recieved, file size, and start
 
48
  :param bool force_overwrite:
49
  Force a file overwrite if conflicting one exists.
50
  """
51
+ if os.path.isdir(os.path.normpath(path)):
52
+ path = (os.path.normpath(path) + '/' if path else '')
53
  fullpath = '{}{}.{}'.format(path, self.filename, self.extension)
54
  else:
55
+ fullpath = os.path.normpath(path)
56
 
57
  # TODO: Move this into cli, this kind of logic probably shouldn't be
58
  # handled by the library.
59
+ if os.path.isfile(fullpath) and not force_overwrite:
60
  raise OSError("Conflicting filename:'{}'".format(self.filename))
61
 
62
  response = urlopen(self.url)
 
93
  except KeyboardInterrupt:
94
  # TODO: Move this into the cli, ``KeyboardInterrupt`` handling
95
  # should be taken care of by the client.
96
+ os.remove(fullpath)
97
  raise KeyboardInterrupt("Interrupt signal given. Deleting "
98
  "incomplete video.")
99