diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-12-20 01:11:50 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-12-20 01:11:50 -0800 |
commit | a8d74ba082404bac016b210d151fb2d46cbd54d9 (patch) | |
tree | dd8f6409edf999ec2ea0f0b1d2e05453dce3f949 /youtube/channel.py | |
parent | 9d1c688310849f897c5fc7b3f37ab3ddeac67a9b (diff) | |
download | yt-local-a8d74ba082404bac016b210d151fb2d46cbd54d9.tar.lz yt-local-a8d74ba082404bac016b210d151fb2d46cbd54d9.tar.xz yt-local-a8d74ba082404bac016b210d151fb2d46cbd54d9.zip |
Correctly handle case where channel doesn't exist
Diffstat (limited to 'youtube/channel.py')
-rw-r--r-- | youtube/channel.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube/channel.py b/youtube/channel.py index 8c44700..d246495 100644 --- a/youtube/channel.py +++ b/youtube/channel.py @@ -1,6 +1,7 @@ import base64 import youtube.common as common from youtube.common import default_multi_get, URL_ORIGIN, get_thumbnail_url, video_id +import http_errors import urllib import json from string import Template @@ -193,6 +194,11 @@ def channel_videos_html(polymer_json, current_page=1, current_sort=3, number_of_ for alert in response['alerts']: result += alert['alertRenderer']['text']['simpleText'] + '\n' return result + elif 'errors' in response['responseContext']: + for error in response['responseContext']['errors']['error']: + if error['code'] == 'INVALID_VALUE' and error['location'] == 'browse_id': + raise http_errors.Error404('This channel does not exist') + raise else: raise channel_url = microformat['urlCanonical'].rstrip('/') |