Added play buttons for invoking desktop-client

master
Felix Stupp 3 years ago
parent b390cbfb17
commit 04fc620e1d
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -7,7 +7,7 @@ from __future__ import annotations
from functools import partial
import logging
import os
from pathlib import Path
from urllib.parse import urlencode, quote_plus
from typing import Any, Callable, Dict, Iterable, Optional, Union
from flask import Flask, jsonify, make_response, request
@ -137,6 +137,14 @@ def as_link(uri: str):
uri = Markup.escape(uri)
return Markup(f'<a href="{uri}">{uri}</a>')
@flask_app.template_filter()
def as_play_link(video_uri: str):
opts = {
"video_uri": video_uri,
}
play_uri = "entertainment-decider:///player/play?" + urlencode(opts, quote_via=quote_plus)
return Markup(f'<a class=button href="{play_uri}">Play</a>')
@flask_app.template_filter()
def tenary(b: bool, true_str: str, false_str: str) -> str:
return true_str if b else false_str

@ -19,6 +19,9 @@
<pre>{{ element.notes or "" }}</pre>
<h2>Properties</h2>
<ul>
<li>
{{ element.uri | as_play_link }}
</li>
<li>Can be considered: {{ element.can_considered | tenary("Yes", "no") }}</li>
</ul>
<h2>Part of Collections</h2>

@ -10,6 +10,16 @@
padding: .2em;
border: solid black 1px;
}
a:link { text-decoration: none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:active { text-decoration: none; }
.button {
padding: .1rem .2rem;
margin: 0 .1rem;
background-color: lightcoral;
border-radius: .3rem;
}
</style>
</head>
<body>
@ -28,7 +38,7 @@
<th>Progress</th>
<th>Length</th>
<th>Consider</th>
<th>Link</th>
<th>Actions</th>
</tr>
{% for media in media_list %}
<tr>
@ -45,7 +55,9 @@
</td>
<td>{{ media.length }}&nbsp;s</td>
<td>{{ media.can_considered | tenary("Yes", "no") }}</td>
<td><a href="{{ media.uri }}">link</a></td>
<td>
{{ media.uri | as_play_link }}
</td>
</tr>
{% endfor %}
</table>

Loading…
Cancel
Save