aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/channel.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2021-03-02 18:54:22 -0800
committerJesús <heckyel@hyperbola.info>2021-03-03 10:40:02 -0500
commit2df42389246bd731e04bd2e2472a05d27917b981 (patch)
tree92c683efee4537875be547fad044eab5c8d2e1e0 /youtube/channel.py
parentc45f60d3f5914d7924e9940c504bd3443f2eb8de (diff)
downloadyt-local-2df42389246bd731e04bd2e2472a05d27917b981.tar.lz
yt-local-2df42389246bd731e04bd2e2472a05d27917b981.tar.xz
yt-local-2df42389246bd731e04bd2e2472a05d27917b981.zip
Use new channel api endpoint now that browse_ajax is disabled
Fixes channel pages > 1 Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/channel.py')
-rw-r--r--youtube/channel.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/youtube/channel.py b/youtube/channel.py
index 64b6612..d60f1d3 100644
--- a/youtube/channel.py
+++ b/youtube/channel.py
@@ -120,11 +120,28 @@ def get_channel_tab(channel_id, page="1", sort=3, tab='videos', view=1,
if not ctoken:
ctoken = channel_ctoken_v3(channel_id, page, sort, tab, view)
ctoken = ctoken.replace('=', '%3D')
- url = 'https://www.youtube.com/browse_ajax?ctoken=' + ctoken
+ # Not sure what the purpose of the key is or whether it will change
+ # For now it seems to be constant for the API endpoint, not dependent
+ # on the browsing session or channel
+ key = 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
+ url = 'https://www.youtube.com/youtubei/v1/browse?key=' + key
+
+ data = {
+ 'context': {
+ 'client': {
+ 'hl': 'en',
+ 'gl': 'US',
+ 'clientName': 'WEB',
+ 'clientVersion': '2.20180830',
+ },
+ },
+ 'continuation': ctoken,
+ }
+
+ content_type_header = (('Content-Type', 'application/json'),)
content = util.fetch_url(
- url,
- headers_desktop + generic_cookie,
- debug_name='channel_tab', report_text=message)
+ url, headers_desktop + content_type_header,
+ data=json.dumps(data), debug_name='channel_tab', report_text=message)
return content