From ea184ef316728227df22fb5ca58e99949e50e5ea Mon Sep 17 00:00:00 2001 From: pluja Date: Wed, 7 Oct 2020 16:26:45 +0200 Subject: [PATCH] Proxies comments avatar images --- youtube_data/comments.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_data/comments.py b/youtube_data/comments.py index 0b3d07b..15f1499 100644 --- a/youtube_data/comments.py +++ b/youtube_data/comments.py @@ -83,8 +83,9 @@ def concat_texts(strings): def parse_comment(raw_comment): cmnt = {} raw_comment = raw_comment['commentThreadRenderer']['comment']['commentRenderer'] + imgHostName = urllib.parse.urlparse(raw_comment['authorThumbnail']['thumbnails'][0]['url']).netloc cmnt['author'] = raw_comment['authorText']['runs'][0]['text'] - cmnt['thumbnail'] = raw_comment['authorThumbnail']['thumbnails'][0]['url'] + cmnt['thumbnail'] = raw_comment['authorThumbnail']['thumbnails'][0]['url'].replace("https://{}".format(imgHostName), "")+"?host="+imgHostName cmnt['channel'] = raw_comment['authorEndpoint']['commandMetadata']['webCommandMetadata']['url'] cmnt['text'] = Markup(bleach.linkify(concat_texts(raw_comment['contentText']['runs']).replace("\n", "
"))) cmnt['date'] = raw_comment['publishedTimeText']['runs'][0]['text']