improved typing
Browse files- .idea/dictionaries/haroldmartin.xml +4 -0
- pytube/__main__.py +1 -0
- pytube/cli.py +0 -1
- pytube/contrib/playlist.py +1 -1
- pytube/monostate.py +1 -1
- pytube/query.py +2 -2
- pytube/streams.py +1 -1
- tests/test_cli.py +1 -1
.idea/dictionaries/haroldmartin.xml
CHANGED
@@ -12,7 +12,9 @@
|
|
12 |
<w>descrambling</w>
|
13 |
<w>eurl</w>
|
14 |
<w>ficano</w>
|
|
|
15 |
<w>filesize</w>
|
|
|
16 |
<w>itag</w>
|
17 |
<w>itags</w>
|
18 |
<w>lsig</w>
|
@@ -23,11 +25,13 @@
|
|
23 |
<w>nficano</w>
|
24 |
<w>noqa</w>
|
25 |
<w>noreorder</w>
|
|
|
26 |
<w>ntfs</w>
|
27 |
<w>prog</w>
|
28 |
<w>pytube</w>
|
29 |
<w>recompiles</w>
|
30 |
<w>samp</w>
|
|
|
31 |
<w>streamability</w>
|
32 |
<w>stty</w>
|
33 |
<w>tracklist</w>
|
|
|
12 |
<w>descrambling</w>
|
13 |
<w>eurl</w>
|
14 |
<w>ficano</w>
|
15 |
+
<w>filenames</w>
|
16 |
<w>filesize</w>
|
17 |
+
<w>gangnam</w>
|
18 |
<w>itag</w>
|
19 |
<w>itags</w>
|
20 |
<w>lsig</w>
|
|
|
25 |
<w>nficano</w>
|
26 |
<w>noqa</w>
|
27 |
<w>noreorder</w>
|
28 |
+
<w>nosec</w>
|
29 |
<w>ntfs</w>
|
30 |
<w>prog</w>
|
31 |
<w>pytube</w>
|
32 |
<w>recompiles</w>
|
33 |
<w>samp</w>
|
34 |
+
<w>scodecs</w>
|
35 |
<w>streamability</w>
|
36 |
<w>stty</w>
|
37 |
<w>tracklist</w>
|
pytube/__main__.py
CHANGED
@@ -69,6 +69,7 @@ class YouTube:
|
|
69 |
self.player_config_args: Dict = {} # inline js in the html containing
|
70 |
# streams
|
71 |
self.age_restricted: Optional[bool] = None
|
|
|
72 |
|
73 |
self.fmt_streams: List[Stream] = []
|
74 |
self.caption_tracks: List[Caption] = []
|
|
|
69 |
self.player_config_args: Dict = {} # inline js in the html containing
|
70 |
# streams
|
71 |
self.age_restricted: Optional[bool] = None
|
72 |
+
self.vid_descr: Optional[str] = None
|
73 |
|
74 |
self.fmt_streams: List[Stream] = []
|
75 |
self.caption_tracks: List[Caption] = []
|
pytube/cli.py
CHANGED
@@ -235,7 +235,6 @@ def download_by_resolution(
|
|
235 |
:param str target:
|
236 |
Target directory for download
|
237 |
"""
|
238 |
-
# TODO(nficano): allow dash itags to be selected
|
239 |
stream = youtube.streams.get_by_resolution(resolution)
|
240 |
if stream is None:
|
241 |
print(f"Could not find a stream with resolution: {resolution}")
|
|
|
235 |
:param str target:
|
236 |
Target directory for download
|
237 |
"""
|
|
|
238 |
stream = youtube.streams.get_by_resolution(resolution)
|
239 |
if stream is None:
|
240 |
print(f"Could not find a stream with resolution: {resolution}")
|
pytube/contrib/playlist.py
CHANGED
@@ -38,7 +38,7 @@ class Playlist:
|
|
38 |
# Needs testing with non-English
|
39 |
self.last_update: Optional[date] = None
|
40 |
results = re.search(
|
41 |
-
r"<li>Last updated on (\w{3}) (\d{1,2}), (\d{4})
|
42 |
)
|
43 |
if results:
|
44 |
month, day, year = results.groups()
|
|
|
38 |
# Needs testing with non-English
|
39 |
self.last_update: Optional[date] = None
|
40 |
results = re.search(
|
41 |
+
r"<li>Last updated on (\w{3}) (\d{1,2}), (\d{4})</li>", self.html
|
42 |
)
|
43 |
if results:
|
44 |
month, day, year = results.groups()
|
pytube/monostate.py
CHANGED
@@ -8,7 +8,7 @@ from typing_extensions import Protocol
|
|
8 |
class OnProgress(Protocol):
|
9 |
def __call__(
|
10 |
self,
|
11 |
-
stream:
|
12 |
chunk: Any,
|
13 |
file_handler: io.BufferedWriter,
|
14 |
bytes_remaining: int,
|
|
|
8 |
class OnProgress(Protocol):
|
9 |
def __call__(
|
10 |
self,
|
11 |
+
stream: bytes,
|
12 |
chunk: Any,
|
13 |
file_handler: io.BufferedWriter,
|
14 |
bytes_remaining: int,
|
pytube/query.py
CHANGED
@@ -287,8 +287,8 @@ class StreamQuery:
|
|
287 |
def get_audio_only(self, subtype: str = "mp4") -> Optional[Stream]:
|
288 |
"""Get highest bitrate audio stream for given codec (defaults to mp4)
|
289 |
|
290 |
-
:param str
|
291 |
-
Audio
|
292 |
:rtype: :class:`Stream <Stream>` or None
|
293 |
:returns:
|
294 |
The :class:`Stream <Stream>` matching the given itag or None if
|
|
|
287 |
def get_audio_only(self, subtype: str = "mp4") -> Optional[Stream]:
|
288 |
"""Get highest bitrate audio stream for given codec (defaults to mp4)
|
289 |
|
290 |
+
:param str subtype:
|
291 |
+
Audio subtype, defaults to mp4
|
292 |
:rtype: :class:`Stream <Stream>` or None
|
293 |
:returns:
|
294 |
The :class:`Stream <Stream>` matching the given itag or None if
|
pytube/streams.py
CHANGED
@@ -264,7 +264,7 @@ class Stream:
|
|
264 |
additional callback is defined in the monostate. This is exposed to
|
265 |
allow things like displaying a progress bar.
|
266 |
|
267 |
-
:param
|
268 |
Segment of media file binary data, not yet written to disk.
|
269 |
:param file_handler:
|
270 |
The file handle where the media is being written to.
|
|
|
264 |
additional callback is defined in the monostate. This is exposed to
|
265 |
allow things like displaying a progress bar.
|
266 |
|
267 |
+
:param bytes chunk:
|
268 |
Segment of media file binary data, not yet written to disk.
|
269 |
:param file_handler:
|
270 |
The file handle where the media is being written to.
|
tests/test_cli.py
CHANGED
@@ -86,7 +86,7 @@ def test_download_caption_with_language_not_found(youtube):
|
|
86 |
|
87 |
def test_display_progress_bar(capsys):
|
88 |
cli.display_progress_bar(bytes_received=25, filesize=100, scale=0.55)
|
89 |
-
out,
|
90 |
assert "25.0%" in out
|
91 |
|
92 |
|
|
|
86 |
|
87 |
def test_display_progress_bar(capsys):
|
88 |
cli.display_progress_bar(bytes_received=25, filesize=100, scale=0.55)
|
89 |
+
out, _ = capsys.readouterr()
|
90 |
assert "25.0%" in out
|
91 |
|
92 |
|