diff --git a/main.py b/main.py index ca2b1d8..ebd8530 100644 --- a/main.py +++ b/main.py @@ -96,6 +96,7 @@ async def video(domain, id): "video.html", domain=domain, video=vid, + comments=peertube.get_comments(domain, id), quality=quality, embed=embed, commit=commit, diff --git a/peertube.py b/peertube.py index 680b81f..d39a263 100644 --- a/peertube.py +++ b/peertube.py @@ -24,17 +24,17 @@ def search(domain, term, start = 0, count = 10): return amount, results -def comments(domain, id): +def get_comments(domain, id): url = "https://" + domain + "/api/v1/videos/" + id + "/comment-threads" comments_object = json.loads(requests.get(url).text) return comments_object if __name__ == "__main__": - name = get_instance_name("videos.lukesmith.xyz") - print(name) - #com = comments("videos.lukesmith.xyz", "591bf5dd-b02f-40f7-a2cc-b4929c52cb51") - #print(json.dumps(com, indent=2)) + #name = get_instance_name("videos.lukesmith.xyz") + #print(name) + com = get_comments("videos.lukesmith.xyz", "d1bfb082-b203-43dc-9676-63d28fe65db5") + print(json.dumps(com, indent=2)) #vid = video("diode.zone", "c4f0d71b-bd8b-4641-87b0-6d9edd4fa9ce") #print(json.dumps(vid, indent=2)) #_, results = search("diode.zone", "test") diff --git a/templates/video.html b/templates/video.html index f649a3b..e10bc09 100644 --- a/templates/video.html +++ b/templates/video.html @@ -62,4 +62,35 @@ Views: {{ video.views }} Likes: {{ video.likes }} Dislikes: {{ +
+
+
+{{ comments.total }} Comments +
+
+{% for comment in comments.data %} + + {% if not comment.isDeleted %} + {{ comment.account.displayName }} +
+ {{ comment.text }} +
+ {% else %} +
+ Unknown +
+ Deleted Comment +
+ {% endif %} + + {% if comment.totalReplies == 1 %} + 1 Reply + {% else %} + {{ comment.totalReplies }} Replies + {% endif %} + +
+
+{% endfor %} + {% endblock %}