family-guy
commited on
Commit
·
bb3ef78
1
Parent(s):
bdfa1a4
Linting / typos
Browse files- pytube/__main__.py +3 -3
- pytube/exceptions.py +1 -1
- pytube/extract.py +1 -1
- pytube/streams.py +7 -7
pytube/__main__.py
CHANGED
@@ -20,7 +20,6 @@ from pytube import request
|
|
20 |
from pytube import Stream
|
21 |
from pytube import StreamQuery
|
22 |
from pytube.compat import parse_qsl
|
23 |
-
from pytube.exceptions import AgeRestrictionError
|
24 |
from pytube.helpers import apply_mixin
|
25 |
|
26 |
|
@@ -58,7 +57,8 @@ class YouTube(object):
|
|
58 |
self.vid_info_url = None # the url to vid info, parsed from watch html
|
59 |
|
60 |
self.watch_html = None # the html of /watch?v=<video_id>
|
61 |
-
self.player_config_args = None # inline js in the html containing
|
|
|
62 |
self.age_restricted = None
|
63 |
|
64 |
self.fmt_streams = [] # list of :class:`Stream <Stream>` instances
|
@@ -240,7 +240,7 @@ class YouTube(object):
|
|
240 |
return self.player_config_args['title']
|
241 |
|
242 |
def register_on_progress_callback(self, func):
|
243 |
-
"""Register a download
|
244 |
|
245 |
:param callable func:
|
246 |
A callback function that takes ``stream``, ``chunk``,
|
|
|
20 |
from pytube import Stream
|
21 |
from pytube import StreamQuery
|
22 |
from pytube.compat import parse_qsl
|
|
|
23 |
from pytube.helpers import apply_mixin
|
24 |
|
25 |
|
|
|
57 |
self.vid_info_url = None # the url to vid info, parsed from watch html
|
58 |
|
59 |
self.watch_html = None # the html of /watch?v=<video_id>
|
60 |
+
self.player_config_args = None # inline js in the html containing
|
61 |
+
# streams
|
62 |
self.age_restricted = None
|
63 |
|
64 |
self.fmt_streams = [] # list of :class:`Stream <Stream>` instances
|
|
|
240 |
return self.player_config_args['title']
|
241 |
|
242 |
def register_on_progress_callback(self, func):
|
243 |
+
"""Register a download progress callback function post initialization.
|
244 |
|
245 |
:param callable func:
|
246 |
A callback function that takes ``stream``, ``chunk``,
|
pytube/exceptions.py
CHANGED
@@ -21,7 +21,7 @@ class ExtractError(PytubeError):
|
|
21 |
:param str msg:
|
22 |
User defined error message.
|
23 |
:param str video_id:
|
24 |
-
A YouTube video
|
25 |
"""
|
26 |
if video_id is not None:
|
27 |
msg = '{video_id}: {msg}'.format(video_id=video_id, msg=msg)
|
|
|
21 |
:param str msg:
|
22 |
User defined error message.
|
23 |
:param str video_id:
|
24 |
+
A YouTube video identifier.
|
25 |
"""
|
26 |
if video_id is not None:
|
27 |
msg = '{video_id}: {msg}'.format(video_id=video_id, msg=msg)
|
pytube/extract.py
CHANGED
@@ -47,7 +47,7 @@ def watch_url(video_id):
|
|
47 |
"""Construct a sanitized YouTube watch url, given a video id.
|
48 |
|
49 |
:param str video_id:
|
50 |
-
A YouTube video
|
51 |
:rtype: str
|
52 |
:returns:
|
53 |
Sanitized YouTube watch url.
|
|
|
47 |
"""Construct a sanitized YouTube watch url, given a video id.
|
48 |
|
49 |
:param str video_id:
|
50 |
+
A YouTube video identifier.
|
51 |
:rtype: str
|
52 |
:returns:
|
53 |
Sanitized YouTube watch url.
|
pytube/streams.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
"""
|
3 |
-
This module
|
4 |
|
5 |
A container object for the media stream (video only / audio only / video+audio
|
6 |
combined). This was referred to as ``Video`` in the legacy pytube version, but
|
@@ -30,7 +30,7 @@ class Stream(object):
|
|
30 |
|
31 |
:param dict stream:
|
32 |
The unscrambled data extracted from YouTube.
|
33 |
-
:param dict
|
34 |
The data object containing video media data like title and
|
35 |
keywords.
|
36 |
:param dict monostate:
|
@@ -47,7 +47,7 @@ class Stream(object):
|
|
47 |
self.res = None # resolution (e.g.: 480p, 720p, 1080p)
|
48 |
self.url = None # signed download url
|
49 |
|
50 |
-
self.mime_type = None # content
|
51 |
self.type = None # the part of the mime before the slash
|
52 |
self.subtype = None # the part of the mime after the slash
|
53 |
|
@@ -68,7 +68,7 @@ class Stream(object):
|
|
68 |
|
69 |
# The player configuration which contains information like the video
|
70 |
# title.
|
71 |
-
# TODO(nficano): this should be moved to the
|
72 |
self.player_config_args = player_config_args
|
73 |
|
74 |
# 'video/webm; codecs="vp8, vorbis"' -> 'video/webm', ['vp8', 'vorbis']
|
@@ -131,7 +131,7 @@ class Stream(object):
|
|
131 |
"""Get the video/audio codecs from list of codecs.
|
132 |
|
133 |
Parse a variable length sized list of codecs and returns a
|
134 |
-
|
135 |
and audio as the second. Returns None if one is not available
|
136 |
(adaptive only).
|
137 |
|
@@ -219,9 +219,9 @@ class Stream(object):
|
|
219 |
|
220 |
:param str chunk:
|
221 |
Segment of media file binary data, not yet written to disk.
|
222 |
-
:param
|
223 |
The file handle where the media is being written to.
|
224 |
-
:type
|
225 |
:py:class:`io.BufferedWriter`
|
226 |
:param int bytes_remaining:
|
227 |
The delta between the total file size in bytes and amount already
|
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
"""
|
3 |
+
This module contains a container for stream manifest data.
|
4 |
|
5 |
A container object for the media stream (video only / audio only / video+audio
|
6 |
combined). This was referred to as ``Video`` in the legacy pytube version, but
|
|
|
30 |
|
31 |
:param dict stream:
|
32 |
The unscrambled data extracted from YouTube.
|
33 |
+
:param dict player_config_args:
|
34 |
The data object containing video media data like title and
|
35 |
keywords.
|
36 |
:param dict monostate:
|
|
|
47 |
self.res = None # resolution (e.g.: 480p, 720p, 1080p)
|
48 |
self.url = None # signed download url
|
49 |
|
50 |
+
self.mime_type = None # content identifier (e.g.: video/mp4)
|
51 |
self.type = None # the part of the mime before the slash
|
52 |
self.subtype = None # the part of the mime after the slash
|
53 |
|
|
|
68 |
|
69 |
# The player configuration which contains information like the video
|
70 |
# title.
|
71 |
+
# TODO(nficano): this should be moved to the monostate.
|
72 |
self.player_config_args = player_config_args
|
73 |
|
74 |
# 'video/webm; codecs="vp8, vorbis"' -> 'video/webm', ['vp8', 'vorbis']
|
|
|
131 |
"""Get the video/audio codecs from list of codecs.
|
132 |
|
133 |
Parse a variable length sized list of codecs and returns a
|
134 |
+
constant 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 |
|
|
|
219 |
|
220 |
:param str chunk:
|
221 |
Segment of media file binary data, not yet written to disk.
|
222 |
+
:param file_handler:
|
223 |
The file handle where the media is being written to.
|
224 |
+
:type file_handler:
|
225 |
:py:class:`io.BufferedWriter`
|
226 |
:param int bytes_remaining:
|
227 |
The delta between the total file size in bytes and amount already
|