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,6 +65,7 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
<br>
<br>
<br>
{% if video.commentsEnabled %}
{{ comments.total }} Comments
<br>
<br>
@ -92,5 +93,8 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
<br>
<br>
{% endfor %}
{% else %}
Comments disabled.
{% endif %}
{% endblock %}