From ed055be0b5e0a75db4459928e3be529e1ec40880 Mon Sep 17 00:00:00 2001 From: pluja Date: Wed, 7 Oct 2020 16:49:42 +0200 Subject: [PATCH] Improve comments UI Adds author like and sytles better --- app/templates/_video_comment.html | 31 ++++++++++++++++++------------- youtube_data/comments.py | 6 ++++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/templates/_video_comment.html b/app/templates/_video_comment.html index ee10a7a..6cc1478 100644 --- a/app/templates/_video_comment.html +++ b/app/templates/_video_comment.html @@ -3,23 +3,28 @@
{% if comment.authorIsChannelOwner %} - {{comment.author}} + {{comment.author}} {% else %} {{comment.author}} {% endif %} - \ No newline at end of file diff --git a/youtube_data/comments.py b/youtube_data/comments.py index 15f1499..2f47535 100644 --- a/youtube_data/comments.py +++ b/youtube_data/comments.py @@ -82,6 +82,7 @@ def concat_texts(strings): def parse_comment(raw_comment): cmnt = {} + print(raw_comment) 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'] @@ -89,6 +90,11 @@ def parse_comment(raw_comment): 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'] + + try: + cmnt['creatorHeart'] = raw_comment['creatorHeart']['creatorHeartRenderer']['creatorThumbnail']['thumbnails'][0]['url'] + except: + cmnt['creatorHeart'] = False try: cmnt['likes'] = raw_comment['likeCount']