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.dislikes = a["dislikes"]
|
||||||
|
|
||||||
self.embedPath = a["embedPath"]
|
self.embedPath = a["embedPath"]
|
||||||
|
self.commentsEnabled = a["commentsEnabled"]
|
||||||
|
|
||||||
self.resolutions = []
|
self.resolutions = []
|
||||||
self.video = None
|
self.video = None
|
||||||
|
@ -92,11 +93,16 @@ async def video(domain, id):
|
||||||
quality = "best"
|
quality = "best"
|
||||||
vid = VideoWrapper(data, quality)
|
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(
|
return await render_template(
|
||||||
"video.html",
|
"video.html",
|
||||||
domain=domain,
|
domain=domain,
|
||||||
video=vid,
|
video=vid,
|
||||||
comments=peertube.get_comments(domain, id),
|
comments=comments,
|
||||||
quality=quality,
|
quality=quality,
|
||||||
embed=embed,
|
embed=embed,
|
||||||
commit=commit,
|
commit=commit,
|
||||||
|
|
|
@ -65,6 +65,7 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
{% if video.commentsEnabled %}
|
||||||
{{ comments.total }} Comments
|
{{ comments.total }} Comments
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
@ -92,5 +93,8 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
Comments disabled.
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue