aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/channel.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/channel.py')
-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):