nficano commited on
Commit
da19fc7
·
1 Parent(s): 899dfc0

docstrings

Browse files
pytube/__main__.py CHANGED
@@ -83,7 +83,7 @@ class YouTube(object):
83
  def prefetch_init(self):
84
  """Download data, descramble it, and build Stream instances.
85
 
86
- :rtype: ``None``
87
 
88
  """
89
  self.prefetch()
@@ -97,7 +97,7 @@ class YouTube(object):
97
  be applied in-place, instead of holding references to mutations at each
98
  interstitial step.
99
 
100
- :rtype: ``None``
101
 
102
  """
103
  logger.info('init started')
@@ -136,7 +136,7 @@ class YouTube(object):
136
  operations don't does need to make calls outside of the interpreter
137
  which blocks for long periods of time.
138
 
139
- :rtype: ``None``
140
 
141
  """
142
  self.watch_html = request.get(url=self.watch_url)
@@ -162,7 +162,7 @@ class YouTube(object):
162
  download or adaptive streams (e.g.: ``url_encoded_fmt_stream_map``
163
  or ``adaptive_fmts``).
164
 
165
- :rtype: ``None``
166
 
167
  """
168
  stream_manifest = self.player_config['args'][fmt]
@@ -180,7 +180,7 @@ class YouTube(object):
180
  Take the unscrambled player response data, and use it to initialize
181
  instances of :class:`Caption <Caption>`.
182
 
183
- :rtype: ``None``
184
 
185
  """
186
  if 'captions' not in self.player_config['args']['player_response']:
@@ -237,7 +237,7 @@ class YouTube(object):
237
  A callback function that takes ``stream``, ``chunk``,
238
  ``file_handle``, ``bytes_remaining`` as parameters.
239
 
240
- :rtype: ``None``
241
 
242
  """
243
  self.stream_monostate['on_progress'] = func
@@ -248,7 +248,7 @@ class YouTube(object):
248
  :param callable func:
249
  A callback function that takes ``stream`` and ``file_handle``.
250
 
251
- :rtype: ``None``
252
 
253
  """
254
  self.stream_monostate['on_complete'] = func
 
83
  def prefetch_init(self):
84
  """Download data, descramble it, and build Stream instances.
85
 
86
+ :rtype: None
87
 
88
  """
89
  self.prefetch()
 
97
  be applied in-place, instead of holding references to mutations at each
98
  interstitial step.
99
 
100
+ :rtype: None
101
 
102
  """
103
  logger.info('init started')
 
136
  operations don't does need to make calls outside of the interpreter
137
  which blocks for long periods of time.
138
 
139
+ :rtype: None
140
 
141
  """
142
  self.watch_html = request.get(url=self.watch_url)
 
162
  download or adaptive streams (e.g.: ``url_encoded_fmt_stream_map``
163
  or ``adaptive_fmts``).
164
 
165
+ :rtype: None
166
 
167
  """
168
  stream_manifest = self.player_config['args'][fmt]
 
180
  Take the unscrambled player response data, and use it to initialize
181
  instances of :class:`Caption <Caption>`.
182
 
183
+ :rtype: None
184
 
185
  """
186
  if 'captions' not in self.player_config['args']['player_response']:
 
237
  A callback function that takes ``stream``, ``chunk``,
238
  ``file_handle``, ``bytes_remaining`` as parameters.
239
 
240
+ :rtype: None
241
 
242
  """
243
  self.stream_monostate['on_progress'] = func
 
248
  :param callable func:
249
  A callback function that takes ``stream`` and ``file_handle``.
250
 
251
+ :rtype: None
252
 
253
  """
254
  self.stream_monostate['on_complete'] = func
pytube/helpers.py CHANGED
@@ -70,7 +70,7 @@ def apply_mixin(dct, key, func, *args, **kwargs):
70
  :param \*\*kwargs:
71
  (optional) keyword arguments that ``func`` takes.
72
  :rtype:
73
- ``None``
74
  """
75
  dct[key] = func(dct[key], *args, **kwargs)
76
 
 
70
  :param \*\*kwargs:
71
  (optional) keyword arguments that ``func`` takes.
72
  :rtype:
73
+ None
74
  """
75
  dct[key] = func(dct[key], *args, **kwargs)
76
 
pytube/query.py CHANGED
@@ -27,59 +27,59 @@ class StreamQuery:
27
  :param fps:
28
  (optional) The frames per second.
29
  :type fps:
30
- int or ``None``
31
 
32
  :param resolution:
33
  (optional) Alias to ``res``.
34
  :type res:
35
- str or ``None``
36
 
37
  :param res:
38
  (optional) The video resolution.
39
  :type resolution:
40
- str or ``None``
41
 
42
  :param mime_type:
43
  (optional) Two-part identifier for file formats and format contents
44
  composed of a "type", a "subtype".
45
  :type mime_type:
46
- str or ``None``
47
 
48
  :param type:
49
  (optional) Type part of the ``mime_type`` (e.g.: audio, video).
50
  :type type:
51
- str or ``None``
52
 
53
  :param subtype:
54
  (optional) Sub-type part of the ``mime_type`` (e.g.: mp4, mov).
55
  :type subtype:
56
- str or ``None``
57
 
58
  :param file_extension:
59
  (optional) Alias to ``sub_type``.
60
  :type file_extension:
61
- str or ``None``
62
 
63
  :param abr:
64
  (optional) Average bitrate (ABR) refers to the average amount of
65
  data transferred per unit of time (e.g.: 64kbps, 192kbps).
66
  :type abr:
67
- str or ``None``
68
 
69
  :param bitrate:
70
  (optional) Alias to ``abr``.
71
  :type bitrate:
72
- str or ``None``
73
 
74
  :param video_codec:
75
  (optional) Video compression format.
76
  :type video_codec:
77
- str or ``None``
78
 
79
  :param audio_codec:
80
  (optional) Audio compression format.
81
  :type audio_codec:
82
- str or ``None``
83
 
84
  :param bool progressive:
85
  Excludes adaptive streams (one file contains both audio and video
@@ -99,7 +99,7 @@ class StreamQuery:
99
  (optional) Interface for defining complex filters without
100
  subclassing.
101
  :type custom_filter_functions:
102
- list or ``None``
103
 
104
  """
105
  filters = []
@@ -189,9 +189,9 @@ class StreamQuery:
189
 
190
  :param str itag:
191
  YouTube format identifier code.
192
- :rtype: :class:`Stream <Stream>` or ``None``
193
  :returns:
194
- The :class:`Stream <Stream>` matching the given itag or ``None`` if
195
  not found.
196
 
197
  """
@@ -203,9 +203,9 @@ class StreamQuery:
203
  def first(self):
204
  """Get the first :class:`Stream <Stream>` in the results.
205
 
206
- :rtype: :class:`Stream <Stream>` or ``None``
207
  :returns:
208
- the first result of this query or ``None`` if the result doesn't
209
  contain any streams.
210
 
211
  """
@@ -217,9 +217,9 @@ class StreamQuery:
217
  def last(self):
218
  """Get the last :class:`Stream <Stream>` in the results.
219
 
220
- :rtype: :class:`Stream <Stream>` or ``None``
221
  :returns:
222
- Return the last result of this query or ``None`` if the result
223
  doesn't contain any streams.
224
 
225
  """
@@ -263,10 +263,10 @@ class CaptionQuery:
263
 
264
  :param str lang_code:
265
  The code that identifies the caption language.
266
- :rtype: :class:`Caption <Caption>` or ``None``
267
  :returns:
268
  The :class:`Caption <Caption>` matching the given ``lang_code`` or
269
- ``None`` if it does not exist.
270
  """
271
  return self.lang_code_index.get(lang_code)
272
 
 
27
  :param fps:
28
  (optional) The frames per second.
29
  :type fps:
30
+ int or None
31
 
32
  :param resolution:
33
  (optional) Alias to ``res``.
34
  :type res:
35
+ str or None
36
 
37
  :param res:
38
  (optional) The video resolution.
39
  :type resolution:
40
+ str or None
41
 
42
  :param mime_type:
43
  (optional) Two-part identifier for file formats and format contents
44
  composed of a "type", a "subtype".
45
  :type mime_type:
46
+ str or None
47
 
48
  :param type:
49
  (optional) Type part of the ``mime_type`` (e.g.: audio, video).
50
  :type type:
51
+ str or None
52
 
53
  :param subtype:
54
  (optional) Sub-type part of the ``mime_type`` (e.g.: mp4, mov).
55
  :type subtype:
56
+ str or None
57
 
58
  :param file_extension:
59
  (optional) Alias to ``sub_type``.
60
  :type file_extension:
61
+ str or None
62
 
63
  :param abr:
64
  (optional) Average bitrate (ABR) refers to the average amount of
65
  data transferred per unit of time (e.g.: 64kbps, 192kbps).
66
  :type abr:
67
+ str or None
68
 
69
  :param bitrate:
70
  (optional) Alias to ``abr``.
71
  :type bitrate:
72
+ str or None
73
 
74
  :param video_codec:
75
  (optional) Video compression format.
76
  :type video_codec:
77
+ str or None
78
 
79
  :param audio_codec:
80
  (optional) Audio compression format.
81
  :type audio_codec:
82
+ str or None
83
 
84
  :param bool progressive:
85
  Excludes adaptive streams (one file contains both audio and video
 
99
  (optional) Interface for defining complex filters without
100
  subclassing.
101
  :type custom_filter_functions:
102
+ list or None
103
 
104
  """
105
  filters = []
 
189
 
190
  :param str itag:
191
  YouTube format identifier code.
192
+ :rtype: :class:`Stream <Stream>` or None
193
  :returns:
194
+ The :class:`Stream <Stream>` matching the given itag or None if
195
  not found.
196
 
197
  """
 
203
  def first(self):
204
  """Get the first :class:`Stream <Stream>` in the results.
205
 
206
+ :rtype: :class:`Stream <Stream>` or None
207
  :returns:
208
+ the first result of this query or None if the result doesn't
209
  contain any streams.
210
 
211
  """
 
217
  def last(self):
218
  """Get the last :class:`Stream <Stream>` in the results.
219
 
220
+ :rtype: :class:`Stream <Stream>` or None
221
  :returns:
222
+ Return the last result of this query or None if the result
223
  doesn't contain any streams.
224
 
225
  """
 
263
 
264
  :param str lang_code:
265
  The code that identifies the caption language.
266
+ :rtype: :class:`Caption <Caption>` or None
267
  :returns:
268
  The :class:`Caption <Caption>` matching the given ``lang_code`` or
269
+ None if it does not exist.
270
  """
271
  return self.lang_code_index.get(lang_code)
272
 
pytube/streams.py CHANGED
@@ -132,7 +132,7 @@ class Stream(object):
132
 
133
  Parse a variable length sized list of codecs and returns a
134
  consitant two element tuple, with the video codec as the first element
135
- and audio as the second. Returns ``None`` if one is not available
136
  (adaptive only).
137
 
138
  :rtype: tuple
@@ -180,7 +180,7 @@ class Stream(object):
180
  (optional) Output path for writing media file. If one is not
181
  specified, defaults to the current working directory.
182
  :type output_path: str or None
183
- :rtype: ``None``
184
 
185
  """
186
  # TODO(nficano): allow a filename to specified.
@@ -219,7 +219,7 @@ class Stream(object):
219
  The delta between the total file size in bytes and amount already
220
  downloaded.
221
 
222
- :rtype: ``None``
223
 
224
  """
225
  file_handler.write(chunk)
@@ -245,7 +245,7 @@ class Stream(object):
245
  :type file_handle:
246
  :py:class:`io.BufferedWriter`
247
 
248
- :rtype: ``None``
249
 
250
  """
251
  logger.debug('download finished')
 
132
 
133
  Parse a variable length sized list of codecs and returns a
134
  consitant two element tuple, with the video codec as the first element
135
+ and audio as the second. Returns None if one is not available
136
  (adaptive only).
137
 
138
  :rtype: tuple
 
180
  (optional) Output path for writing media file. If one is not
181
  specified, defaults to the current working directory.
182
  :type output_path: str or None
183
+ :rtype: None
184
 
185
  """
186
  # TODO(nficano): allow a filename to specified.
 
219
  The delta between the total file size in bytes and amount already
220
  downloaded.
221
 
222
+ :rtype: None
223
 
224
  """
225
  file_handler.write(chunk)
 
245
  :type file_handle:
246
  :py:class:`io.BufferedWriter`
247
 
248
+ :rtype: None
249
 
250
  """
251
  logger.debug('download finished')
tests/test_query.py CHANGED
@@ -40,7 +40,7 @@ def test_filters(test_input, expected, cipher_signature):
40
  @pytest.mark.parametrize('test_input', ['first', 'last'])
41
  def test_empty(test_input, cipher_signature):
42
  """Ensure :meth:`~pytube.StreamQuery.last` and
43
- :meth:`~pytube.StreamQuery.first` return ``None`` if the resultset is
44
  empty.
45
  """
46
  query = cipher_signature.streams.filter(video_codec='vp20')
 
40
  @pytest.mark.parametrize('test_input', ['first', 'last'])
41
  def test_empty(test_input, cipher_signature):
42
  """Ensure :meth:`~pytube.StreamQuery.last` and
43
+ :meth:`~pytube.StreamQuery.first` return None if the resultset is
44
  empty.
45
  """
46
  query = cipher_signature.streams.filter(video_codec='vp20')