From 777ed756dcfd01845451937fb38559ee57ec44e9 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Mon, 23 Dec 2019 14:39:59 -0800 Subject: Channel: Change search results to use next and previous page buttons Because youtube doesn't give the number of search results, so previous behavior would give an error if a page number out of range was selected. --- youtube/yt_data_extract/everything_else.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'youtube/yt_data_extract') diff --git a/youtube/yt_data_extract/everything_else.py b/youtube/yt_data_extract/everything_else.py index 4e3271f..5194693 100644 --- a/youtube/yt_data_extract/everything_else.py +++ b/youtube/yt_data_extract/everything_else.py @@ -59,9 +59,11 @@ def extract_channel_info(polymer_json, tab): # get items info['items'] = [] if tab in ('videos', 'playlists', 'search'): - items, _ = extract_items(response) + items, ctoken = extract_items(response) additional_info = {'author': info['channel_name'], 'author_url': info['channel_url']} info['items'] = [extract_item_info(renderer, additional_info) for renderer in items] + if tab == 'search': + info['is_last_page'] = (ctoken is None) elif tab == 'about': items, _ = extract_items(response, item_types={'channelAboutFullMetadataRenderer'}) if not items: -- cgit v1.2.3