youtube --first AND --last

This commit is contained in:
DOCCA0 2021-04-17 13:27:43 +08:00
parent 1c841f7e8c
commit 7900239662

View File

@ -171,7 +171,14 @@ class YouTube(VideoExtractor):
self.title = re.search(r'<meta name="title" content="([^"]+)"', video_page).group(1) self.title = re.search(r'<meta name="title" content="([^"]+)"', video_page).group(1)
self.p_playlist() self.p_playlist()
firstIndex= kwargs['args'].first
lastIndex = kwargs['args'].last
for index, video in enumerate(videos, 1): for index, video in enumerate(videos, 1):
if firstIndex and index < int(firstIndex):
index = int(firstIndex)
video = videos[index-1]
if lastIndex and index > int(lastIndex):
break
vid = video['playlistVideoRenderer']['videoId'] vid = video['playlistVideoRenderer']['videoId']
try: try:
self.__class__().download_by_url(self.__class__.get_url_from_vid(vid), index=index, **kwargs) self.__class__().download_by_url(self.__class__.get_url_from_vid(vid), index=index, **kwargs)