Improve comments UI

Adds author like and sytles better
This commit is contained in:
pluja 2020-10-07 16:49:42 +02:00
parent ea184ef316
commit ed055be0b5
2 changed files with 24 additions and 13 deletions

View File

@ -3,23 +3,28 @@
<div class="content">
{% if comment.authorIsChannelOwner %}
<a class="author" href="{{comment.channel}}"><i class="red user circle icon"></i>{{comment.author}}</a>
<a class="author" style="color: red;" href="{{comment.channel}}"><i class="red user circle icon"></i>{{comment.author}}</a>
{% else %}
<a class="author" href="{{comment.channel}}">{{comment.author}}</a>
{% endif %}
<div class="metadata">
<div class="date">{{comment.date}}</div>
<div class="rating">
<i class="thumbs up icon"></i>
{{comment.likes}}
<div class="metadata">
<div class="date">{{comment.date}}</div>
</div>
<div class="rating">
<i class="comment icon"></i>
{{comment.replies}}
<div class="text">
{{comment.text}}
</div>
<div class="metadata">
<div class="rating">
<i class="comment icon"></i>
{{comment.replies}}
</div>
<div class="rating">
<i class="thumbs up icon"></i>
{{comment.likes}}
</div>
{%if comment.creatorHeart != false%}
<i class="small red heart icon"></i><img class="ui circular image" style="width: 15px; height: 15px;" src="{{comment.creatorHeart}}">
{% endif %}
</div>
</div>
<div class="text">
{{comment.text}}
</div>
</div>
</div>

View File

@ -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", "<br>")))
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']