aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/channel.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-02-07 20:58:17 -0800
committerJames Taylor <user234683@users.noreply.github.com>2019-02-07 20:58:17 -0800
commit4d7bba92eb62518e2273d030235214f4a7605444 (patch)
tree3950f6b98ef7a2b828adf906850c6ea598f27c0d /youtube/channel.py
parentb669050bed540c106a04ef30d1296ff385ebb6ba (diff)
downloadyt-local-4d7bba92eb62518e2273d030235214f4a7605444.tar.lz
yt-local-4d7bba92eb62518e2273d030235214f4a7605444.tar.xz
yt-local-4d7bba92eb62518e2273d030235214f4a7605444.zip
Use pbj format for playlist requests, ajax deprecated
Diffstat (limited to 'youtube/channel.py')
-rw-r--r--youtube/channel.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/youtube/channel.py b/youtube/channel.py
index 1ec5635..0dafde5 100644
--- a/youtube/channel.py
+++ b/youtube/channel.py
@@ -47,6 +47,12 @@ headers_1 = (
('X-YouTube-Client-Name', '1'),
('X-YouTube-Client-Version', '2.20180830'),
)
+headers_pbj = (
+ ('Accept', '*/*'),
+ ('Accept-Language', 'en-US,en;q=0.5'),
+ ('X-YouTube-Client-Name', '2'),
+ ('X-YouTube-Client-Version', '2.20180830'),
+)
# https://www.youtube.com/browse_ajax?action_continuation=1&direct_render=1&continuation=4qmFsgJAEhhVQzdVY3M0MkZaeTN1WXpqcnF6T0lIc3caJEVnWjJhV1JsYjNNZ0FEZ0JZQUZxQUhvQk1yZ0JBQSUzRCUzRA%3D%3D
# https://www.youtube.com/browse_ajax?ctoken=4qmFsgJAEhhVQzdVY3M0MkZaeTN1WXpqcnF6T0lIc3caJEVnWjJhV1JsYjNNZ0FEZ0JZQUZxQUhvQk1yZ0JBQSUzRCUzRA%3D%3D&continuation=4qmFsgJAEhhVQzdVY3M0MkZaeTN1WXpqcnF6T0lIc3caJEVnWjJhV1JsYjNNZ0FEZ0JZQUZxQUhvQk1yZ0JBQSUzRCUzRA%3D%3D&itct=CDsQybcCIhMIhZi1krTc2wIVjMicCh2HXQnhKJsc
@@ -99,14 +105,15 @@ def get_channel_tab(channel_id, page="1", sort=3, tab='videos', view=1):
def get_number_of_videos(channel_id):
# Uploads playlist
playlist_id = 'UU' + channel_id[2:]
- url = 'https://m.youtube.com/playlist?list=' + playlist_id + '&ajax=1&disable_polymer=true'
+ url = 'https://m.youtube.com/playlist?list=' + playlist_id + '&pbj=1'
print("Getting number of videos")
- response = common.fetch_url(url, common.mobile_ua + headers_1)
+ response = common.fetch_url(url, common.mobile_ua + headers_pbj)
'''with open('debug/playlist_debug_metadata', 'wb') as f:
f.write(response)'''
response = response.decode('utf-8')
print("Got response for number of videos")
- match = re.search(r'"num_videos_text":\s*{(?:"item_type":\s*"formatted_string",)?\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response)
+
+ match = re.search(r'"numVideosText":\s*{\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response)
if match:
return int(match.group(1).replace(',',''))
else: