]> git.bitcoin.ninja Git - youtube-dl/commitdiff
Implement the playlist/start options in FileDownloader
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Wed, 10 Apr 2013 12:32:03 +0000 (14:32 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Wed, 10 Apr 2013 12:32:03 +0000 (14:32 +0200)
It makes it available for all the InfoExtractors

youtube_dl/FileDownloader.py
youtube_dl/InfoExtractors.py

index 58be5caeee268f1dbcfcd712e1791d1c2d2cbdd7..5a5141ba523a21100abde773c98d89123ee6b9e9 100644 (file)
@@ -485,10 +485,25 @@ class FileDownloader(object):
             #We process each entry in the playlist
             playlist = ie_result.get('title', None) or ie_result.get('id', None)
             self.to_screen(u'[download] Downloading playlist: %s'  % playlist)
-            n_videos = len(ie_result['entries'])
+
             playlist_results = []
-            for i,entry in enumerate(ie_result['entries'],1):
-                self.to_screen(u'[download] Downloading video #%s of %s' %(i, n_videos))
+
+            n_all_entries = len(ie_result['entries'])
+            playliststart = self.params.get('playliststart', 1) - 1
+            playlistend = self.params.get('playlistend', -1)
+
+            if playlistend == -1:
+                entries = ie_result['entries'][playliststart:]
+            else:
+                entries = ie_result['entries'][playliststart:playlistend]
+
+            n_entries = len(entries)
+
+            self.to_screen(u"[%s] playlist '%s': Collected %d video ids (downloading %d of them)" %
+                (ie_result['extractor'], playlist, n_all_entries, n_entries))
+
+            for i,entry in enumerate(entries,1):
+                self.to_screen(u'[download] Downloading video #%s of %s' %(i, n_entries))
                 entry_result = self.process_ie_result(entry, False)
                 entry_result['playlist'] = playlist
                 #We must do the download here to correctly set the 'playlist' key
index b7371365ac7e431808ca9927beb70c4e0b0e1635..a7fdf1607c4c73e4caef623a1598065e84b3a834 100755 (executable)
@@ -1806,19 +1806,6 @@ class YoutubePlaylistIE(InfoExtractor):
             page_num += 1
 
         videos = [v[1] for v in sorted(videos)]
-        total = len(videos)
-
-        playliststart = self._downloader.params.get('playliststart', 1) - 1
-        playlistend = self._downloader.params.get('playlistend', -1)
-        if playlistend == -1:
-            videos = videos[playliststart:]
-        else:
-            videos = videos[playliststart:playlistend]
-
-        if len(videos) == total:
-            self._downloader.to_screen(u'[youtube] PL %s: Found %i videos' % (playlist_id, total))
-        else:
-            self._downloader.to_screen(u'[youtube] PL %s: Found %i videos, downloading %i' % (playlist_id, total, len(videos)))
 
         url_results = [self.url_result(url) for url in videos]
         return [self.playlist_result(url_results, playlist_id)]
@@ -1943,18 +1930,6 @@ class YoutubeUserIE(InfoExtractor):
 
             pagenum += 1
 
-        all_ids_count = len(video_ids)
-        playliststart = self._downloader.params.get('playliststart', 1) - 1
-        playlistend = self._downloader.params.get('playlistend', -1)
-
-        if playlistend == -1:
-            video_ids = video_ids[playliststart:]
-        else:
-            video_ids = video_ids[playliststart:playlistend]
-
-        self._downloader.to_screen(u"[youtube] user %s: Collected %d video ids (downloading %d of them)" %
-                (username, all_ids_count, len(video_ids)))
-
         urls = ['http://www.youtube.com/watch?v=%s' % video_id for video_id in video_ids]
         url_results = [self.url_result(url) for url in urls]
         return [self.playlist_result(url_results, playlist_title = username)]
@@ -2035,15 +2010,6 @@ class BlipTVUserIE(InfoExtractor):
 
             pagenum += 1
 
-        all_ids_count = len(video_ids)
-        playliststart = self._downloader.params.get('playliststart', 1) - 1
-        playlistend = self._downloader.params.get('playlistend', -1)
-
-        if playlistend == -1:
-            video_ids = video_ids[playliststart:]
-        else:
-            video_ids = video_ids[playliststart:playlistend]
-
         self._downloader.to_screen(u"[%s] user %s: Collected %d video ids (downloading %d of them)" %
                 (self.IE_NAME, username, all_ids_count, len(video_ids)))