aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/playlist.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/playlist.py')
-rw-r--r--youtube/playlist.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/youtube/playlist.py b/youtube/playlist.py
index 7eb4d22..a2ff80f 100644
--- a/youtube/playlist.py
+++ b/youtube/playlist.py
@@ -47,23 +47,25 @@ def playlist_first_page(playlist_id, report_text="Retrieved playlist", use_mobil
return content
-def get_videos(playlist_id, page, use_mobile=False):
+def get_videos(playlist_id, page, include_shorts=True, use_mobile=False):
# mobile requests return 20 videos per page
if use_mobile:
- url = "https://m.youtube.com/playlist?ctoken="
- url += playlist_ctoken(playlist_id, (int(page)-1)*20) + "&pbj=1"
- content = util.fetch_url(
- url, util.mobile_xhr_headers,
- report_text="Retrieved playlist", debug_name='playlist_videos'
- )
+ page_size = 20
+ headers = util.mobile_xhr_headers
# desktop requests return 100 videos per page
else:
- url = "https://www.youtube.com/playlist?ctoken="
- url += playlist_ctoken(playlist_id, (int(page)-1)*100) + "&pbj=1"
- content = util.fetch_url(
- url, util.desktop_xhr_headers,
- report_text="Retrieved playlist", debug_name='playlist_videos'
- )
+ page_size = 100
+ headers = util.desktop_xhr_headers
+
+ url = "https://m.youtube.com/playlist?ctoken="
+ url += playlist_ctoken(playlist_id, (int(page)-1)*page_size,
+ include_shorts=include_shorts)
+ url += "&pbj=1"
+ content = util.fetch_url(
+ url, headers, report_text="Retrieved playlist",
+ debug_name='playlist_videos'
+ )
+
info = json.loads(content.decode('utf-8'))
return info
@@ -117,7 +119,7 @@ def get_playlist_page():
'playlist.html',
header_playlist_names=local_playlist.get_playlist_names(),
video_list=info.get('items', []),
- num_pages = math.ceil(video_count/100),
+ num_pages=math.ceil(video_count/100),
parameters_dictionary=request.args,
**info['metadata']