aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/channel.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-07-06 18:34:11 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-07-06 18:34:11 -0700
commit2ba4fd8994e6b82adae2316257868844208e657e (patch)
tree3d976f98e8b0f950ebdf2757da6fdafae8c6ea64 /youtube/channel.py
parent237d19d834aa978fa4000d32c5c75600dbdce4e2 (diff)
downloadyt-local-2ba4fd8994e6b82adae2316257868844208e657e.tar.lz
yt-local-2ba4fd8994e6b82adae2316257868844208e657e.tar.xz
yt-local-2ba4fd8994e6b82adae2316257868844208e657e.zip
channel playlists: fix error when 0 playlists, correct stats for playlist
Diffstat (limited to 'youtube/channel.py')
-rw-r--r--youtube/channel.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/youtube/channel.py b/youtube/channel.py
index 3238341..4d7b563 100644
--- a/youtube/channel.py
+++ b/youtube/channel.py
@@ -178,7 +178,15 @@ def channel_playlists_html(polymer_json):
except KeyError:
items = []
else:
- items = contents['twoColumnBrowseResultsRenderer']['tabs'][2]['tabRenderer']['content']['sectionListRenderer']['contents'][0]['itemSectionRenderer']['contents'][0]['gridRenderer']['items']
+ item_section = contents['twoColumnBrowseResultsRenderer']['tabs'][2]['tabRenderer']['content']['sectionListRenderer']['contents'][0]['itemSectionRenderer']['contents'][0]
+ try:
+ items = item_section['gridRenderer']['items']
+ except KeyError:
+ if "messageRenderer" in item_section:
+ items = []
+ else:
+ raise
+
items_html = grid_items_html(items, {'author': microformat['title']})
return yt_channel_items_template.substitute(
@@ -256,6 +264,8 @@ def get_channel_page(url, query_string=''):
return channel_about_page(polymer_json)
elif tab == 'playlists':
polymer_json = common.fetch_url('https://www.youtube.com/channel/' + channel_id + '/playlists?pbj=1', headers_1)
+ '''with open('debug/channel_playlists_debug', 'wb') as f:
+ f.write(polymer_json)'''
polymer_json = json.loads(polymer_json)
return channel_playlists_html(polymer_json)
else: