thumbnail view: Search for collection link if requested

- uses one found, if only one was found to prevent issues when multiple
would be possible
master
Felix Stupp 2 years ago
parent e8ee39aa29
commit 4866901159
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -21,6 +21,7 @@ from typing import (
List,
Mapping,
Optional,
Sequence,
Set,
Type,
TypeVar,
@ -246,6 +247,11 @@ def encode_options(opts: Mapping[str, Any]) -> str:
return urlencode({k: str(v) for k, v in opts.items()}, quote_via=quote_plus)
@flask_app.template_filter()
def first_and_only(list: Sequence[T]) -> Optional[T]:
return list[0] if len(list) == 1 else None
@flask_app.template_global()
def this_url(changed_args: Mapping[str, str] = {}) -> str:
if request.endpoint is None:

@ -388,6 +388,9 @@
alt="Thumbnail for {{ element.title }}"
loading="lazy"
/>
{% if link == None %}
{% set link = element.detected_playlists | list | first_and_only %}
{% endif %}
{% if link and (link.season or link.episode) %}
<a
class="episode_info"

Loading…
Cancel
Save