@@ -1285,17 +1285,48 @@ def get_user_videos(self, channel_id=None, user_id=None, custom_username=None, v
1285
1285
1286
1286
def get_playlist_items (self , playlist_url , params = None ):
1287
1287
1288
- yt_initial_data , ytcfg , player_response_info = self ._get_initial_info (
1288
+ yt_initial_data , ytcfg , _ = self ._get_initial_info (
1289
1289
playlist_url , params )
1290
1290
1291
- items = self ._get_rendered_content (
1292
- yt_initial_data )['playlistVideoListRenderer' ]['contents' ]
1291
+ page_contents = self ._get_rendered_content (yt_initial_data )
1293
1292
1294
- for item in items :
1295
- playlist_video = item .get ('playlistVideoRenderer' )
1293
+ # TODO remove code duplication
1294
+ api_key = ytcfg .get ('INNERTUBE_API_KEY' )
1295
+ continuation_url = self ._YOUTUBE_BROWSE_API_TEMPLATE .format (api_key )
1296
1296
1297
- if playlist_video :
1298
- yield self ._parse_video (playlist_video )
1297
+ continuation_params = {
1298
+ 'context' : ytcfg .get ('INNERTUBE_CONTEXT' ) or {}
1299
+ }
1300
+ continuation = None
1301
+ first_time = True
1302
+ while True :
1303
+ if first_time :
1304
+ items = multi_get (
1305
+ page_contents , 'playlistVideoListRenderer' , 'contents' )
1306
+ first_time = False
1307
+ else :
1308
+ continuation_params ['continuation' ] = continuation
1309
+ yt_info = self ._get_continuation_info (
1310
+ continuation_url , params , json = continuation_params )
1311
+ items = multi_get (yt_info , 'onResponseReceivedActions' ,
1312
+ 0 , 'appendContinuationItemsAction' , 'continuationItems' )
1313
+
1314
+ if not items :
1315
+ break
1316
+
1317
+ continuation = None
1318
+ for item in items :
1319
+ vid = item .get ('playlistVideoRenderer' )
1320
+ continuation_item = item .get ('continuationItemRenderer' )
1321
+
1322
+ if vid :
1323
+ yield self ._parse_video (vid )
1324
+ elif continuation_item :
1325
+ continuation = multi_get (
1326
+ continuation_item , 'continuationEndpoint' , 'continuationCommand' , 'token' )
1327
+
1328
+ if not continuation :
1329
+ break
1299
1330
1300
1331
_CONSENT_ID_REGEX = r'PENDING\+(\d+)'
1301
1332
# https://github.com/ytdl-org/youtube-dl/blob/a8035827177d6b59aca03bd717acb6a9bdd75ada/youtube_dl/extractor/youtube.py#L251
@@ -1634,7 +1665,7 @@ def _get_chat_messages(self, initial_info, ytcfg, params):
1634
1665
1635
1666
# Top chat replay - Some messages, such as potential spam, may not be visible
1636
1667
# Live chat replay - All messages are visible
1637
- chat_type = params .get ('chat_type' ).title () # Live or Top
1668
+ chat_type = params .get ('chat_type' , 'live' ).title () # Live or Top
1638
1669
continuation_index = 0 if chat_type == 'Top' else 1
1639
1670
continuation_info = list (initial_continuation_info .items ())[
1640
1671
continuation_index ]
0 commit comments