Only send get_comments requests if comments are enabled
This commit is contained in:
parent
8be6ab231c
commit
0e44673dc6
2 changed files with 36 additions and 26 deletions
8
main.py
8
main.py
|
@ -28,6 +28,7 @@ class VideoWrapper:
|
|||
self.dislikes = a["dislikes"]
|
||||
|
||||
self.embedPath = a["embedPath"]
|
||||
self.commentsEnabled = a["commentsEnabled"]
|
||||
|
||||
self.resolutions = []
|
||||
self.video = None
|
||||
|
@ -92,11 +93,16 @@ async def video(domain, id):
|
|||
quality = "best"
|
||||
vid = VideoWrapper(data, quality)
|
||||
|
||||
# only make a request for the comments if commentsEnabled
|
||||
comments = ""
|
||||
if data["commentsEnabled"]:
|
||||
comments = peertube.get_comments(domain, id)
|
||||
|
||||
return await render_template(
|
||||
"video.html",
|
||||
domain=domain,
|
||||
video=vid,
|
||||
comments=peertube.get_comments(domain, id),
|
||||
comments=comments,
|
||||
quality=quality,
|
||||
embed=embed,
|
||||
commit=commit,
|
||||
|
|
|
@ -65,32 +65,36 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
|
|||
<br>
|
||||
<br>
|
||||
<br>
|
||||
{{ comments.total }} Comments
|
||||
<br>
|
||||
<br>
|
||||
{% for comment in comments.data %}
|
||||
{% if video.commentsEnabled %}
|
||||
{{ comments.total }} Comments
|
||||
<br>
|
||||
<br>
|
||||
{% for comment in comments.data %}
|
||||
|
||||
{% if not comment.isDeleted %}
|
||||
<b>{{ comment.account.displayName }}</b>
|
||||
<br>
|
||||
{{ comment.text }}
|
||||
<br>
|
||||
{% else %}
|
||||
<div style="color: #5F5F5F">
|
||||
<b>Unknown</b>
|
||||
{% if not comment.isDeleted %}
|
||||
<b>{{ comment.account.displayName }}</b>
|
||||
<br>
|
||||
Deleted Comment
|
||||
</div>
|
||||
{% endif %}
|
||||
<i>
|
||||
{% if comment.totalReplies == 1 %}
|
||||
1 Reply
|
||||
{% else %}
|
||||
{{ comment.totalReplies }} Replies
|
||||
{% endif %}
|
||||
</i>
|
||||
<br>
|
||||
<br>
|
||||
{% endfor %}
|
||||
{{ comment.text }}
|
||||
<br>
|
||||
{% else %}
|
||||
<div style="color: #5F5F5F">
|
||||
<b>Unknown</b>
|
||||
<br>
|
||||
Deleted Comment
|
||||
</div>
|
||||
{% endif %}
|
||||
<i>
|
||||
{% if comment.totalReplies == 1 %}
|
||||
1 Reply
|
||||
{% else %}
|
||||
{{ comment.totalReplies }} Replies
|
||||
{% endif %}
|
||||
</i>
|
||||
<br>
|
||||
<br>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
Comments disabled.
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue