aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/channel.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-12-17 13:46:29 -0800
committerJesús <heckyel@hyperbola.info>2020-12-18 23:25:45 -0500
commit43679efff5c44c41e7e8c6ca46da145becbe7c03 (patch)
tree3dc9f9c493064ed5f8c06d6d017d2723ededfefa /youtube/channel.py
parentcf7aa4189386a4d4ffd8eb2cc80992fe1603f0c1 (diff)
downloadyt-local-43679efff5c44c41e7e8c6ca46da145becbe7c03.tar.lz
yt-local-43679efff5c44c41e7e8c6ca46da145becbe7c03.tar.xz
yt-local-43679efff5c44c41e7e8c6ca46da145becbe7c03.zip
channel: replace page #s w/ next page button using provided ctoken
Since yt doesn't accept page #'s when sorting by oldest Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/channel.py')
-rw-r--r--youtube/channel.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/youtube/channel.py b/youtube/channel.py
index 97afa6e..eed3253 100644
--- a/youtube/channel.py
+++ b/youtube/channel.py
@@ -113,26 +113,18 @@ def channel_ctoken_v1(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):
+def get_channel_tab(channel_id, page="1", sort=3, tab='videos', view=1,
+ ctoken=None, print_status=True):
message = 'Got channel tab' if print_status else None
- if int(sort) == 2 and int(page) > 1:
- ctoken = channel_ctoken_v1(channel_id, page, sort, tab, view)
- ctoken = ctoken.replace('=', '%3D')
- url = ('https://www.youtube.com/channel/' + channel_id + '/' + tab
- + '?action_continuation=1&continuation=' + ctoken
- + '&pbj=1')
- content = util.fetch_url(
- url, headers_desktop + real_cookie,
- debug_name='channel_tab', report_text=message)
- else:
+ 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
- content = util.fetch_url(
- url,
- headers_desktop + generic_cookie,
- debug_name='channel_tab', report_text=message)
+ url = 'https://www.youtube.com/browse_ajax?ctoken=' + ctoken
+ content = util.fetch_url(
+ url,
+ headers_desktop + generic_cookie,
+ debug_name='channel_tab', report_text=message)
return content
@@ -220,11 +212,13 @@ def get_channel_page_general_url(base_url, tab, request, channel_id=None):
sort = request.args.get('sort', '3')
view = request.args.get('view', '1')
query = request.args.get('query', '')
+ ctoken = request.args.get('ctoken', '')
if tab == 'videos' and channel_id:
tasks = (
gevent.spawn(get_number_of_videos_channel, channel_id),
- gevent.spawn(get_channel_tab, channel_id, page_number, sort, 'videos', view)
+ gevent.spawn(get_channel_tab, channel_id, page_number, sort,
+ 'videos', view, ctoken)
)
gevent.joinall(tasks)
util.check_gevent_exceptions(*tasks)