Add embed and fix some videos not playing
This commit is contained in:
parent
104a36deea
commit
c778a9147d
2 changed files with 24 additions and 4 deletions
12
main.py
12
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__":
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
By:
|
||||
<b>{{ video.channel.displayName }}</b> ({{ video.channel.name }}@{{ video.channel.host }})
|
||||
<br>
|
||||
{% if video.no_quality_selected %}
|
||||
{% if video.no_quality_selected and not embed %}
|
||||
<img height="300" src="https://{{ video.channel.host }}{{ video.thumbnailPath }}">
|
||||
<p style="color: red">Please select a resolution:</p>
|
||||
{% elif embed %}
|
||||
<embed height="300" src="https://{{ video.channel.host }}{{ video.embedPath }}">
|
||||
<br>
|
||||
{% else %}
|
||||
<video height="300" controls>
|
||||
<source src="{{ video.video }}">
|
||||
|
@ -17,8 +20,9 @@
|
|||
{% endif %}
|
||||
|
||||
{% for resolution in video.resolutions %}
|
||||
<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
|
||||
<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
|
||||
{% endfor %}
|
||||
<a href="?embed=1">Embedded</a>
|
||||
|
||||
<br>
|
||||
Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{ video.dislikes }}</b>
|
||||
|
@ -46,6 +50,14 @@
|
|||
<td><b>Privacy</b></td>
|
||||
<td>{{ video.privacy.label }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Tags</b></td>
|
||||
<td>
|
||||
{% for tag in video.tags %}
|
||||
{{ tag }}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue