From c778a9147d9a19d1f30408085aa0e6f7fab876f5 Mon Sep 17 00:00:00 2001 From: metalune Date: Tue, 19 Jan 2021 15:24:28 +0100 Subject: [PATCH] Add embed and fix some videos not playing --- main.py | 12 ++++++++++-- templates/video.html | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index b38dc85..4c9152f 100644 --- a/main.py +++ b/main.py @@ -19,10 +19,17 @@ class VideoWrapper: self.likes = a["likes"] self.dislikes = a["dislikes"] + self.embedPath = a["embedPath"] + self.resolutions = [] self.video = None - for entry in a["files"]: + self.files = a["files"] + if len(self.files) == 0: + self.files = ((a["streamingPlaylists"])[0])["files"] + + + for entry in self.files: resolution = (entry["resolution"])["id"] self.resolutions.append(entry["resolution"]) @@ -67,11 +74,12 @@ async def search(domain, term): async def video(domain, id): data = peertube.video(domain, id) quality = request.args.get("quality") + embed = request.args.get("embed") if quality == None: quality = "best" vid = VideoWrapper(data, quality) - return await render_template("video.html", video=vid, quality=quality) + return await render_template("video.html", video=vid, quality=quality, embed=embed) if __name__ == "__main__": diff --git a/templates/video.html b/templates/video.html index 891e590..503c18c 100644 --- a/templates/video.html +++ b/templates/video.html @@ -5,9 +5,12 @@ By: {{ video.channel.displayName }} ({{ video.channel.name }}@{{ video.channel.host }})
- {% if video.no_quality_selected %} + {% if video.no_quality_selected and not embed %}

Please select a resolution:

+ {% elif embed %} + +
{% else %}