Skip to content
This repository has been archived by the owner on Jun 21, 2021. It is now read-only.

Commit

Permalink
[youtube] Improve channel syncid extraction to support ytcfg (blackja…
Browse files Browse the repository at this point in the history
…ck4494#241)

Authored by: colethedj
  • Loading branch information
coletdjnz authored Apr 14, 2021
1 parent 921b76c commit 8ea3f7b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions yt_dlp/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8ea3f7b

Please sign in to comment.