aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/yt_data_extract')
-rw-r--r--youtube/yt_data_extract/common.py8
-rw-r--r--youtube/yt_data_extract/everything_else.py11
2 files changed, 12 insertions, 7 deletions
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py
index f97597c..2e59109 100644
--- a/youtube/yt_data_extract/common.py
+++ b/youtube/yt_data_extract/common.py
@@ -542,8 +542,12 @@ def extract_items(response, item_types=_item_types,
item_types=item_types)
if items:
break
- elif 'onResponseReceivedEndpoints' in response:
- for endpoint in response.get('onResponseReceivedEndpoints', []):
+ elif ('onResponseReceivedEndpoints' in response
+ or 'onResponseReceivedActions' in response):
+ for endpoint in multi_get(response,
+ 'onResponseReceivedEndpoints',
+ 'onResponseReceivedActions',
+ []):
items, ctoken = extract_items_from_renderer_list(
multi_deep_get(
endpoint,
diff --git a/youtube/yt_data_extract/everything_else.py b/youtube/yt_data_extract/everything_else.py
index 56a2e68..9a6e31a 100644
--- a/youtube/yt_data_extract/everything_else.py
+++ b/youtube/yt_data_extract/everything_else.py
@@ -9,7 +9,7 @@ import re
import urllib
from math import ceil
-def extract_channel_info(polymer_json, tab):
+def extract_channel_info(polymer_json, tab, continuation=False):
response, err = extract_response(polymer_json)
if err:
return {'error': err}
@@ -23,7 +23,8 @@ def extract_channel_info(polymer_json, tab):
# channel doesn't exist or was terminated
# example terminated channel: https://www.youtube.com/channel/UCnKJeK_r90jDdIuzHXC0Org
- if not metadata:
+ # metadata and microformat are not present for continuation requests
+ if not metadata and not continuation:
if response.get('alerts'):
error_string = ' '.join(
extract_str(deep_get(alert, 'alertRenderer', 'text'), default='')
@@ -44,7 +45,7 @@ def extract_channel_info(polymer_json, tab):
info['approx_subscriber_count'] = extract_approx_int(deep_get(response,
'header', 'c4TabbedHeaderRenderer', 'subscriberCountText'))
- # stuff from microformat (info given by youtube for every page on channel)
+ # stuff from microformat (info given by youtube for first page on channel)
info['short_description'] = metadata.get('description')
if info['short_description'] and len(info['short_description']) > 730:
info['short_description'] = info['short_description'][0:730] + '...'
@@ -69,8 +70,8 @@ def extract_channel_info(polymer_json, tab):
info['ctoken'] = None
# empty channel
- if 'contents' not in response and 'continuationContents' not in response:
- return info
+ #if 'contents' not in response and 'continuationContents' not in response:
+ # return info
if tab in ('videos', 'playlists', 'search'):
items, ctoken = extract_items(response)