diff options
author | James Taylor <user234683@users.noreply.github.com> | 2020-08-12 14:46:29 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2020-08-12 14:46:29 -0700 |
commit | ac9b7f01620210de55d4bb50808877f2a0f4ccef (patch) | |
tree | fd17f1602b2778de0f1d9fe765252e874dcdd744 /youtube | |
parent | 4bedf554610191065f374492ab261260d9d5492a (diff) | |
download | yt-local-ac9b7f01620210de55d4bb50808877f2a0f4ccef.tar.lz yt-local-ac9b7f01620210de55d4bb50808877f2a0f4ccef.tar.xz yt-local-ac9b7f01620210de55d4bb50808877f2a0f4ccef.zip |
Switch to desktop endpnt w/ new ctoken format except sort by old>1
Sorting by old for pages > 1 currently broken on some channels;
it's still using the mobile endpoint.
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/channel.py | 31 | ||||
-rw-r--r-- | youtube/templates/channel.html | 7 |
2 files changed, 19 insertions, 19 deletions
diff --git a/youtube/channel.py b/youtube/channel.py index 2ba2440..efb336b 100644 --- a/youtube/channel.py +++ b/youtube/channel.py @@ -28,7 +28,8 @@ headers_pbj = ( ('X-YouTube-Client-Name', '2'), ('X-YouTube-Client-Version', '2.20180830'), ) -generic_cookie = (('Cookie', 'VISITOR_INFO1_LIVE=8XihrAcN1l4'),) +real_cookie = (('Cookie', 'VISITOR_INFO1_LIVE=8XihrAcN1l4'),) +generic_cookie = (('Cookie', 'VISITOR_INFO1_LIVE=ST1Ti53r4fU'),) # SORT: # videos: @@ -89,17 +90,23 @@ def channel_ctoken_mobile(channel_id, page, sort, tab, view=1): return base64.urlsafe_b64encode(pointless_nest).decode('ascii') def get_channel_tab(channel_id, page="1", sort=3, tab='videos', view=1, print_status=True): - ctoken = channel_ctoken_mobile(channel_id, page, sort, tab, view) - ctoken = ctoken.replace('=', '%3D') - url = ('https://m.youtube.com/channel/' + channel_id + '/' + tab - + '?ctoken=' + ctoken + '&pbj=1') - - if print_status: - print("Sending channel tab ajax request") - content = util.fetch_url(url, - util.mobile_ua + headers_pbj + generic_cookie, debug_name='channel_tab') - if print_status: - print("Finished recieving channel tab response") + message = 'Got channel tab' if print_status else None + + if int(sort) == 2 and int(page) > 1: # use mobile endpoint + ctoken = channel_ctoken_mobile(channel_id, page, sort, tab, view) + ctoken = ctoken.replace('=', '%3D') + url = ('https://m.youtube.com/channel/' + channel_id + '/' + tab + + '?ctoken=' + ctoken + '&pbj=1') + content = util.fetch_url(url, + util.mobile_ua + headers_pbj + real_cookie, + debug_name='channel_tab', report_text=message) + else: # use desktop endpoint + ctoken = channel_ctoken_desktop(channel_id, page, sort, tab, view) + ctoken = ctoken.replace('=', '%3D') + url = 'https://www.youtube.com/browse_ajax?ctoken=' + ctoken + content = util.fetch_url(url, + util.desktop_ua + headers_1 + generic_cookie, + debug_name='channel_tab', report_text=message) return content diff --git a/youtube/templates/channel.html b/youtube/templates/channel.html index ef2bedf..a0cdff9 100644 --- a/youtube/templates/channel.html +++ b/youtube/templates/channel.html @@ -68,13 +68,6 @@ .item-grid{ padding-left: 20px; } - .item-grid .horizontal-item-box .item{ - width:330px; - } - .no-description .thumbnail-box{ - width: 120px; - height:90px; - } .item-list{ width:800px; margin: auto; |