Add ability to view comments on videos

This commit is contained in:
metalune 2021-01-20 21:00:11 +01:00
parent 1a30b83c3b
commit 8f65d71673
3 changed files with 37 additions and 5 deletions

View file

@ -96,6 +96,7 @@ async def video(domain, id):
"video.html", "video.html",
domain=domain, domain=domain,
video=vid, video=vid,
comments=peertube.get_comments(domain, id),
quality=quality, quality=quality,
embed=embed, embed=embed,
commit=commit, commit=commit,

View file

@ -24,17 +24,17 @@ def search(domain, term, start = 0, count = 10):
return amount, results return amount, results
def comments(domain, id): def get_comments(domain, id):
url = "https://" + domain + "/api/v1/videos/" + id + "/comment-threads" url = "https://" + domain + "/api/v1/videos/" + id + "/comment-threads"
comments_object = json.loads(requests.get(url).text) comments_object = json.loads(requests.get(url).text)
return comments_object return comments_object
if __name__ == "__main__": if __name__ == "__main__":
name = get_instance_name("videos.lukesmith.xyz") #name = get_instance_name("videos.lukesmith.xyz")
print(name) #print(name)
#com = comments("videos.lukesmith.xyz", "591bf5dd-b02f-40f7-a2cc-b4929c52cb51") com = get_comments("videos.lukesmith.xyz", "d1bfb082-b203-43dc-9676-63d28fe65db5")
#print(json.dumps(com, indent=2)) print(json.dumps(com, indent=2))
#vid = video("diode.zone", "c4f0d71b-bd8b-4641-87b0-6d9edd4fa9ce") #vid = video("diode.zone", "c4f0d71b-bd8b-4641-87b0-6d9edd4fa9ce")
#print(json.dumps(vid, indent=2)) #print(json.dumps(vid, indent=2))
#_, results = search("diode.zone", "test") #_, results = search("diode.zone", "test")

View file

@ -62,4 +62,35 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
</td> </td>
</tr> </tr>
</table> </table>
<br>
<br>
<br>
{{ 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>
<br>
Deleted Comment
</div>
{% endif %}
<i>
{% if comment.totalReplies == 1 %}
1 Reply
{% else %}
{{ comment.totalReplies }} Replies
{% endif %}
</i>
<br>
<br>
{% endfor %}
{% endblock %} {% endblock %}