]> jfr.im git - yt-dlp.git/commitdiff
[youtube] Improve channel syncid extraction to support ytcfg (#241)
authorcoletdjnz <redacted>
Wed, 14 Apr 2021 05:07:03 +0000 (05:07 +0000)
committerGitHub <redacted>
Wed, 14 Apr 2021 05:07:03 +0000 (10:37 +0530)
Authored by: colethedj

yt_dlp/extractor/youtube.py

index ea09ad358139a8f8ef9be8e3edd77621a00dc517..54b9ce94cb61065c4bc7a19509c820bb79765880 100644 (file)
@@ -336,14 +336,19 @@ def _extract_identity_token(self, webpage, item_id):
 
     @staticmethod
     def _extract_account_syncid(data):
-        """Extract syncId required to download private playlists of secondary channels"""
-        sync_ids = (
-            try_get(data, lambda x: x['responseContext']['mainAppWebResponseContext']['datasyncId'], compat_str)
-            or '').split("||")
+        """
+        Extract syncId required to download private playlists of secondary channels
+        @param data Either response or ytcfg
+        """
+        sync_ids = (try_get(
+            data, (lambda x: x['responseContext']['mainAppWebResponseContext']['datasyncId'],
+                   lambda x: x['DATASYNC_ID']), compat_str) or '').split("||")
         if len(sync_ids) >= 2 and sync_ids[1]:
             # datasyncid is of the form "channel_syncid||user_syncid" for secondary channel
             # and just "user_syncid||" for primary channel. We only want the channel_syncid
             return sync_ids[0]
+        # ytcfg includes channel_syncid if on secondary channel
+        return data.get('DELEGATED_SESSION_ID')
 
     def _extract_ytcfg(self, video_id, webpage):
         return self._parse_json(