Skip to content

Commit 8c4884f

Browse files
Added start and end video no. of playlist"
1 parent 4308903 commit 8c4884f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Download playlist from cmd using python/playlist.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def main():
142142
help="List id of the playlist", type=str)
143143
parser.add_argument('-s', '--start', nargs='?',
144144
help="Start no. of playlist", type=int)
145+
parser.add_argument('-e', '--end', nargs='?',
146+
help="End no. of playlist", type=int)
145147
args = parser.parse_args()
146148

147149
if args.url:
@@ -152,7 +154,9 @@ def main():
152154
print(parser.parse_args(['--help']))
153155

154156
if args.start:
155-
start = args.start
157+
start = args.start - 1
158+
if args.end:
159+
end = args.end
156160

157161
try:
158162

@@ -178,24 +182,26 @@ def main():
178182

179183
soup = BeautifulSoup(driver.page_source, 'html.parser')
180184
path = soup.find(
181-
"h1", class_="pl-header-title").string.replace('\n', '').replace(' ', '').replace(',', '').replace('.', '')
185+
"h1", class_="pl-header-title").string.replace('\n', '').replace(' ', '').replace(',', '').replace('.', '').replace(':', '')
182186

183187
_urls = soup.find_all(
184188
"a", class_="pl-video-title-link")
185189

186190
totalVideos = len(_urls)
191+
if end == 0:
192+
end = totalVideos
187193

188194
print("There are total of " + str(totalVideos) + " Videos in the playlist")
189195

190196
if not os.path.exists(path):
191197
os.system('mkdir %s' % path)
192198

193-
for i, (_url) in enumerate(_urls):
194-
if i + 1 < start:
195-
continue
199+
for i in range(start, end):
200+
201+
_url = _urls[i]
196202

197203
_name = _url.string.replace('\n', '').replace(
198-
' ', '').replace(',', '').replace('.', '')
204+
' ', '').replace(',', '').replace('.', '').replace(':', '')
199205

200206
_name += '.mp4'
201207

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy