Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/youtube.py (Python)

Code before:
        See: https://github.com/yt-dlp/yt-dlp/pull/519
        """
        for ytcfg in data:
            session_index = int_or_none(try_get(ytcfg, lambda x: x['SESSION_INDEX']))
            if session_index is not None:
                return session_index

    # Deprecated?
    def _extract_identity_token(self, ytcfg=None, webpage=None):
        if ytcfg:
            token = try_get(ytcfg, lambda x: x['ID_TOKEN'], str)
            if token:
                return token
        if webpage:
            return self._search_regex(
                r'\bID_TOKEN["\']\s*:\s*["\'](.+?)["\']', webpage,
                'identity token', default=None, fatal=False)

    def _data_sync_id_to_delegated_session_id(self, data_sync_id):
        if not data_sync_id:
            return
        # 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
        session_ids = data_sync_id.split('||')
        if len(session_ids) >= 2 and session_ids[1]:
            return session_ids[0]

    def _extract_account_syncid(self, *args):
        """
        Extract current session ID required to download private playlists of secondary channels
        @params response and/or ytcfg
        """
        # ytcfg includes channel_syncid if on secondary channel
        delegated_sid = traverse_obj(
            args, (..., 'DELEGATED_SESSION_ID'), expected_type=str, get_all=False)
        if delegated_sid:
            return delegated_sid

        data_sync_id = self._extract_data_sync_id(*args)
        return self._data_sync_id_to_delegated_session_id(data_sync_id)

    def _extract_data_sync_id(self, *args):
        """
        Extract current account dataSyncId.
        In the format DELEGATED_SESSION_ID||USER_SESSION_ID or USER_SESSION_ID||
        @params response and/or ytcfg
        """
        if data_sync_id := self._configuration_arg('data_sync_id', [None], ie_key=YoutubeIE, casesense=True)[0]:
            return data_sync_id

        return traverse_obj(

Review comment (suggestion):
```suggestion
        channel_syncid, _, user_syncid = data_sync_id.partition('||')
        if user_syncid:
            return channel_syncid
```

Code after:
        See: https://github.com/yt-dlp/yt-dlp/pull/519
        """
        for ytcfg in data:
            session_index = int_or_none(try_get(ytcfg, lambda x: x['SESSION_INDEX']))
            if session_index is not None:
                return session_index

    # Deprecated?
    def _extract_identity_token(self, ytcfg=None, webpage=None):
        if ytcfg:
            token = try_get(ytcfg, lambda x: x['ID_TOKEN'], str)
            if token:
                return token
        if webpage:
            return self._search_regex(
                r'\bID_TOKEN["\']\s*:\s*["\'](.+?)["\']', webpage,
                'identity token', default=None, fatal=False)

    def _data_sync_id_to_delegated_session_id(self, data_sync_id):
        if not data_sync_id:
            return
        # 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
        channel_syncid, _, user_syncid = data_sync_id.partition('||')
        if user_syncid:
            return channel_syncid

    def _extract_account_syncid(self, *args):
        """
        Extract current session ID required to download private playlists of secondary channels
        @params response and/or ytcfg
        """
        # ytcfg includes channel_syncid if on secondary channel
        if delegated_sid := traverse_obj(args, (..., 'DELEGATED_SESSION_ID', {str}, any)):
            return delegated_sid

        data_sync_id = self._extract_data_sync_id(*args)
        return self._data_sync_id_to_delegated_session_id(data_sync_id)

    def _extract_data_sync_id(self, *args):
        """
        Extract current account dataSyncId.
        In the format DELEGATED_SESSION_ID||USER_SESSION_ID or USER_SESSION_ID||
        @params response and/or ytcfg
        """
        if data_sync_id := self._configuration_arg('data_sync_id', [None], ie_key=YoutubeIE, casesense=True)[0]:
            return data_sync_id

        return traverse_obj(
            args, (..., ('DATASYNC_ID', ('responseContext', 'mainAppWebResponseContext', 'datasyncId')), {str}, any))