diff options
author | Jesus E <heckyel@riseup.net> | 2023-05-28 21:17:03 -0400 |
---|---|---|
committer | Jesus E <heckyel@riseup.net> | 2023-05-28 21:17:03 -0400 |
commit | 97032b31ee7c2d955c32be6bb7a69198f02411f6 (patch) | |
tree | 8cba14cdf444711a8fb20eee13593182d6635e5b | |
parent | ba3714c86057dbc0da2e5e6ed1a132f292e32575 (diff) | |
download | yt-local-97032b31ee7c2d955c32be6bb7a69198f02411f6.tar.lz yt-local-97032b31ee7c2d955c32be6bb7a69198f02411f6.tar.xz yt-local-97032b31ee7c2d955c32be6bb7a69198f02411f6.zip |
Update channel ctoken format due to youtube changes
Hopefully they don't immediately revert it.
Related to #151
-rw-r--r-- | youtube/channel.py | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/youtube/channel.py b/youtube/channel.py index 799c001..4ae6484 100644 --- a/youtube/channel.py +++ b/youtube/channel.py @@ -31,6 +31,49 @@ headers_mobile = ( real_cookie = (('Cookie', 'VISITOR_INFO1_LIVE=8XihrAcN1l4'),) generic_cookie = (('Cookie', 'VISITOR_INFO1_LIVE=ST1Ti53r4fU'),) +# added an extra nesting under the 2nd base64 compared to v4 +def channel_ctoken_v5(channel_id, page, sort, tab, view=1): + new_sort = (2 if int(sort) == 1 else 1) + offset = str(30*(int(page) - 1)) + pointless_nest = proto.string(80226972, + proto.string(2, channel_id) + + proto.string(3, + proto.percent_b64encode( + proto.string(110, + proto.string(3, + proto.string(15, + proto.string(1, + proto.string(1, + proto.unpadded_b64encode( + proto.string(1, + proto.string(1, + proto.unpadded_b64encode( + proto.string(2, + b"ST:" + + proto.unpadded_b64encode( + proto.string(2, offset) + ) + ) + ) + ) + ) + ) + ) + # targetId, just needs to be present but + # doesn't need to be correct + + proto.string(2, "63faaff0-0000-23fe-80f0-582429d11c38") + ) + # 1 - newest, 2 - popular + + proto.uint(3, new_sort) + ) + ) + ) + ) + ) + ) + + return base64.urlsafe_b64encode(pointless_nest).decode('ascii') + # https://github.com/user234683/youtube-local/issues/151 def channel_ctoken_v4(channel_id, page, sort, tab, view=1): new_sort = (2 if int(sort) == 1 else 1) @@ -160,7 +203,7 @@ def get_channel_tab(channel_id, page="1", sort=3, tab='videos', view=1, if not ctoken: if tab == 'videos': - ctoken = channel_ctoken_v4(channel_id, page, sort, tab, view) + ctoken = channel_ctoken_v5(channel_id, page, sort, tab, view) else: ctoken = channel_ctoken_v3(channel_id, page, sort, tab, view) ctoken = ctoken.replace('=', '%3D') |