]> git.bitcoin.ninja Git - youtube-dl/blobdiff - youtube_dl/extractor/youtube.py
YoutubePlaylistIE: break only if there's no entry field in the response
[youtube-dl] / youtube_dl / extractor / youtube.py
index 39894ae88282d5986fb69f46a182a5292a146f89..a16836c6937d6ca263f4b0e9224e41c699ab5d1d 100644 (file)
@@ -186,7 +186,7 @@ class YoutubeIE(InfoExtractor):
         elif len(s) == 88:
             return s[48] + s[81:67:-1] + s[82] + s[66:62:-1] + s[85] + s[61:48:-1] + s[67] + s[47:12:-1] + s[3] + s[11:3:-1] + s[2] + s[12]
         elif len(s) == 87:
-            return s[62] + s[82:62:-1] + s[83] + s[61:52:-1] + s[0] + s[51:2:-1]
+            return s[4:23] + s[86] + s[24:85]
         elif len(s) == 86:
             return s[2:63] + s[82] + s[64:82] + s[63]
         elif len(s) == 85:
@@ -696,7 +696,11 @@ class YoutubePlaylistIE(InfoExtractor):
         videos = []
 
         while True:
-            url = self._TEMPLATE_URL % (playlist_id, self._MAX_RESULTS, self._MAX_RESULTS * (page_num - 1) + 1)
+            start_index = self._MAX_RESULTS * (page_num - 1) + 1
+            if start_index >= 1000:
+                self._downloader.report_warning(u'Max number of results reached')
+                break
+            url = self._TEMPLATE_URL % (playlist_id, self._MAX_RESULTS, start_index)
             page = self._download_webpage(url, playlist_id, u'Downloading page #%s' % page_num)
 
             try:
@@ -715,9 +719,6 @@ class YoutubePlaylistIE(InfoExtractor):
                 index = entry['yt$position']['$t']
                 if 'media$group' in entry and 'media$player' in entry['media$group']:
                     videos.append((index, entry['media$group']['media$player']['url']))
-
-            if len(response['feed']['entry']) < self._MAX_RESULTS:
-                break
             page_num += 1
 
         videos = [v[1] for v in sorted(videos)]