aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-07-04 21:56:53 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-07-04 21:56:53 -0700
commit5c4c21bfd33bdf06a49f1d43c60cbb845593f756 (patch)
treec79ec27245e3b15f5b4f337d0ba8e5ff1b4c20bf /youtube
parentdcdf02737a7e44dff238b5ad8c23ee422c270d7a (diff)
downloadyt-local-5c4c21bfd33bdf06a49f1d43c60cbb845593f756.tar.lz
yt-local-5c4c21bfd33bdf06a49f1d43c60cbb845593f756.tar.xz
yt-local-5c4c21bfd33bdf06a49f1d43c60cbb845593f756.zip
fix exception when channel has no videos
Diffstat (limited to 'youtube')
-rw-r--r--youtube/channel.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube/channel.py b/youtube/channel.py
index 205d61f..3cec09d 100644
--- a/youtube/channel.py
+++ b/youtube/channel.py
@@ -137,7 +137,11 @@ def get_number_of_videos(channel_id):
f.write(response)'''
response = response.decode('utf-8')
print("Got response for number of videos")
- return int(re.search(r'"num_videos_text":\s*{(?:"item_type":\s*"formatted_string",)?\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response).group(1).replace(',',''))
+ match = re.search(r'"num_videos_text":\s*{(?:"item_type":\s*"formatted_string",)?\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response)
+ if match:
+ return int(match.group(1).replace(',',''))
+ else:
+ return 0
@functools.lru_cache(maxsize=128)
def get_channel_id(username):