From 8cf42ed00b9c570100ef7013204d53e732159968 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 30 Aug 2018 20:01:36 -0700 Subject: Fix blank comments causing parsing to fail --- youtube/comments.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'youtube/comments.py') diff --git a/youtube/comments.py b/youtube/comments.py index 9d9a9c0..5490938 100644 --- a/youtube/comments.py +++ b/youtube/comments.py @@ -197,7 +197,7 @@ def parse_comments_polymer(content, replies=False): 'author_avatar': comment_raw['authorThumbnail']['thumbnails'][0]['url'], 'likes': comment_raw['likeCount'], 'published': common.get_plain_text(comment_raw['publishedTimeText']), - 'text': comment_raw['contentText']['runs'], + 'text': comment_raw['contentText'].get('runs', ''), 'view_replies_text': view_replies_text, 'replies_url': replies_url, } @@ -206,6 +206,7 @@ def parse_comments_polymer(content, replies=False): print('Error parsing comments: ' + str(e)) comments = () ctoken = '' + raise else: print("Finished getting and parsing comments") return {'ctoken': ctoken, 'comments': comments, 'video_title': video_title} -- cgit v1.2.3