Only send get_comments requests if comments are enabled

This commit is contained in:
metalune 2021-01-21 10:30:26 +01:00
parent 8be6ab231c
commit 0e44673dc6
2 changed files with 36 additions and 26 deletions

View file

@ -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,

View file

@ -65,10 +65,11 @@ 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>
@ -91,6 +92,9 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
</i>
<br>
<br>
{% endfor %}
{% endfor %}
{% else %}
Comments disabled.
{% endif %}
{% endblock %}