linting
Browse files- pytube/contrib/playlist.py +4 -2
- pytube/streams.py +5 -3
- setup.cfg +2 -3
- tests/test_playlist.py +7 -7
pytube/contrib/playlist.py
CHANGED
@@ -84,8 +84,10 @@ class Playlist(object):
|
|
84 |
start, stop, step = (1, len(self.video_urls) + 1, 1)
|
85 |
return (str(i).zfill(digits) for i in range(start, stop, step))
|
86 |
|
87 |
-
def download_all(
|
88 |
-
|
|
|
|
|
89 |
"""Download all the videos in the the playlist. Initially, download
|
90 |
resolution is 720p (or highest available), later more option
|
91 |
should be added to download resolution of choice
|
|
|
84 |
start, stop, step = (1, len(self.video_urls) + 1, 1)
|
85 |
return (str(i).zfill(digits) for i in range(start, stop, step))
|
86 |
|
87 |
+
def download_all(
|
88 |
+
self, download_path=None, prefix_number=True,
|
89 |
+
reverse_numbering=False,
|
90 |
+
):
|
91 |
"""Download all the videos in the the playlist. Initially, download
|
92 |
resolution is 720p (or highest available), later more option
|
93 |
should be added to download resolution of choice
|
pytube/streams.py
CHANGED
@@ -203,9 +203,11 @@ class Stream(object):
|
|
203 |
filename = filename or self.default_filename
|
204 |
|
205 |
if filename_prefix:
|
206 |
-
filename =
|
207 |
-
.format(
|
208 |
-
|
|
|
|
|
209 |
|
210 |
# file path
|
211 |
fp = os.path.join(output_path, filename)
|
|
|
203 |
filename = filename or self.default_filename
|
204 |
|
205 |
if filename_prefix:
|
206 |
+
filename = '{prefix}{filename}'\
|
207 |
+
.format(
|
208 |
+
prefix=safe_filename(filename_prefix),
|
209 |
+
filename=filename,
|
210 |
+
)
|
211 |
|
212 |
# file path
|
213 |
fp = os.path.join(output_path, filename)
|
setup.cfg
CHANGED
@@ -3,7 +3,7 @@ commit = True
|
|
3 |
tag = True
|
4 |
current_version = 9.2.3
|
5 |
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
|
6 |
-
serialize =
|
7 |
{major}.{minor}.{patch}
|
8 |
|
9 |
[metadata]
|
@@ -15,6 +15,5 @@ description-file = README.md
|
|
15 |
|
16 |
[coverage:run]
|
17 |
source = pytube
|
18 |
-
omit =
|
19 |
pytube/compat.py
|
20 |
-
|
|
|
3 |
tag = True
|
4 |
current_version = 9.2.3
|
5 |
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
|
6 |
+
serialize =
|
7 |
{major}.{minor}.{patch}
|
8 |
|
9 |
[metadata]
|
|
|
15 |
|
16 |
[coverage:run]
|
17 |
source = pytube
|
18 |
+
omit =
|
19 |
pytube/compat.py
|
|
tests/test_playlist.py
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
from pytube import Playlist
|
3 |
|
4 |
short_test_pl = 'https://www.youtube.com/watch?v=' \
|
5 |
-
|
6 |
-
long_test_pl =
|
7 |
-
|
8 |
|
9 |
|
10 |
def test_construct():
|
@@ -51,8 +51,8 @@ def test_numbering():
|
|
51 |
ob = Playlist(short_test_pl)
|
52 |
ob.populate_video_urls()
|
53 |
gen = ob._path_num_prefix_generator(reverse=False)
|
54 |
-
assert
|
55 |
-
assert
|
56 |
|
57 |
ob = Playlist(short_test_pl)
|
58 |
ob.populate_video_urls()
|
@@ -65,10 +65,10 @@ def test_numbering():
|
|
65 |
gen = ob._path_num_prefix_generator(reverse=False)
|
66 |
nxt = next(gen)
|
67 |
assert len(nxt) > 1
|
68 |
-
assert
|
69 |
nxt = next(gen)
|
70 |
assert len(nxt) > 1
|
71 |
-
assert
|
72 |
|
73 |
ob = Playlist(long_test_pl)
|
74 |
ob.populate_video_urls()
|
|
|
2 |
from pytube import Playlist
|
3 |
|
4 |
short_test_pl = 'https://www.youtube.com/watch?v=' \
|
5 |
+
'm5q2GCsteQs&list=PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw'
|
6 |
+
long_test_pl = 'https://www.youtube.com/watch?v=' \
|
7 |
+
'9CHDoAsX1yo&list=UUXuqSBlHAE6Xw-yeJA0Tunw'
|
8 |
|
9 |
|
10 |
def test_construct():
|
|
|
51 |
ob = Playlist(short_test_pl)
|
52 |
ob.populate_video_urls()
|
53 |
gen = ob._path_num_prefix_generator(reverse=False)
|
54 |
+
assert '1' in next(gen)
|
55 |
+
assert '2' in next(gen)
|
56 |
|
57 |
ob = Playlist(short_test_pl)
|
58 |
ob.populate_video_urls()
|
|
|
65 |
gen = ob._path_num_prefix_generator(reverse=False)
|
66 |
nxt = next(gen)
|
67 |
assert len(nxt) > 1
|
68 |
+
assert '1' in nxt
|
69 |
nxt = next(gen)
|
70 |
assert len(nxt) > 1
|
71 |
+
assert '2' in nxt
|
72 |
|
73 |
ob = Playlist(long_test_pl)
|
74 |
ob.populate_video_urls()
|