dropin

alternative frontend for dropout.tv
git clone https://git.ce9e.org/dropin.git

commit
0c62e577c81429c50dfa3ad38eb5efb00c3e6b09
parent
4c446d714beab0b232a61d42fbd8c007af6179ed
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2025-02-12 02:53
refactor: top level objects in contexts

Diffstat

M dropin.py 24 ++++++++++++------------
M templates/collection.html 10 +++++-----
M templates/feed.xml 12 ++++++------
M templates/series.html 8 ++++----
M templates/video.html 32 ++++++++++++++++----------------

5 files changed, 43 insertions, 43 deletions


diff --git a/dropin.py b/dropin.py

@@ -217,11 +217,11 @@ def render_response(request, template, **data):
  217   217     return web.Response(body=body, content_type='text/html')
  218   218 
  219   219 
  220    -1 def render_feed(request, data, items):
   -1   220 def render_feed(request, col, items):
  221   221     if not env.globals.get('ORIGIN'):
  222   222         raise web.HTTPNotFound
  223   223     tpl = env.get_template('feed.xml')
  224    -1     body = tpl.render(**data, items=items, request=request)
   -1   224     body = tpl.render(col=col, items=items, request=request)
  225   225     return web.Response(body=body, content_type='text/xml')
  226   226 
  227   227 
@@ -257,11 +257,11 @@ async def search_view(request):
  257   257 
  258   258 async def collection_view(request):
  259   259     id = request.match_info['id']
  260    -1     data, items = await asyncio.gather(
   -1   260     col, items = await asyncio.gather(
  261   261         fetch(f'https://api.vhx.tv/collections/{id}'),
  262   262         fetch_items(f'https://api.vhx.tv/collections/{id}/items'),
  263   263     )
  264    -1     return render_response(request, 'collection.html', **data, items=items)
   -1   264     return render_response(request, 'collection.html', col=col, items=items)
  265   265 
  266   266 
  267   267 async def collection_feed(request):
@@ -285,17 +285,17 @@ async def get_series(id):
  285   285         {**season, 'episodes': episodes}
  286   286         for season, episodes in zip(_seasons, season_episodes)
  287   287     ]
  288    -1     return {**series, 'seasons': seasons}
   -1   288     return series, seasons
  289   289 
  290   290 
  291   291 async def series_view(request):
  292    -1     series = await get_series(request.match_info['id'])
  293    -1     return render_response(request, 'series.html', **series)
   -1   292     series, seasons = await get_series(request.match_info['id'])
   -1   293     return render_response(request, 'series.html', col=series, seasons=seasons)
  294   294 
  295   295 
  296   296 async def series_feed(request):
  297    -1     series = await get_series(request.match_info['id'])
  298    -1     items = [e for season in series['seasons'] for e in season['episodes']]
   -1   297     series, seasons = await get_series(request.match_info['id'])
   -1   298     items = [e for season in seasons for e in season['episodes']]
  299   299     return render_feed(request, series, items)
  300   300 
  301   301 
@@ -320,9 +320,9 @@ async def get_next(data):
  320   320 
  321   321 async def video_view(request):
  322   322     id = request.match_info['id']
  323    -1     data = await fetch(f'https://api.vhx.tv/videos/{id}')
  324    -1     next = await get_next(data)
  325    -1     return render_response(request, 'video.html', **data, next=next)
   -1   323     video = await fetch(f'https://api.vhx.tv/videos/{id}')
   -1   324     next = await get_next(video)
   -1   325     return render_response(request, 'video.html', video=video, next=next)
  326   326 
  327   327 
  328   328 async def file_view(request):

diff --git a/templates/collection.html b/templates/collection.html

@@ -1,17 +1,17 @@
    1     1 {% extends 'base.html' %}
    2     2 
    3    -1 {% block title %}{{ title }} - {{ super() }}{% endblock %}
   -1     3 {% block title %}{{ col.title }} - {{ super() }}{% endblock %}
    4     4 
    5     5 {% block head %}
    6    -1     {% if ORIGIN and type == 'playlist' %}
    7    -1         <link rel="alternate" type="application/atom+xml" href="/{{ type }}/{{ id }}.rss">
   -1     6     {% if ORIGIN and col.type == 'playlist' %}
   -1     7         <link rel="alternate" type="application/atom+xml" href="/{{ col.type }}/{{ col.id }}.rss">
    8     8     {% endif %}
    9     9 {% endblock %}
   10    10 
   11    11 {% block content %}
   12    12     <div class="wrapper-wide">
   13    -1         <h1>{{ title }}</h1>
   14    -1         {%+ if description %}<div class="description">{{ description|linebreaks }}</div>{% endif %}
   -1    13         <h1>{{ col.title }}</h1>
   -1    14         {%+ if col.description %}<div class="description">{{ col.description|linebreaks }}</div>{% endif %}
   15    15         {% include '_list.html' %}
   16    16     </div>
   17    17 {% endblock %}

diff --git a/templates/feed.xml b/templates/feed.xml

@@ -1,25 +1,25 @@
    1     1 <?xml version="1.0" encoding="UTF-8"?>
    2     2 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:podcast="https://podcastindex.org/namespace/1.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
    3     3     <channel>
    4    -1         <title>{{ title }}</title>
    5    -1         {%+ if description %}<description>{{ description }}</description>{% endif %}
    6    -1         <link>{{ _links.collection_page.href }}</link>
   -1     4         <title>{{ col.title }}</title>
   -1     5         {%+ if col.description %}<description>{{ col.description }}</description>{% endif %}
   -1     6         <link>{{ col._links.collection_page.href }}</link>
    7     7         <language>en-US</language>
    8     8         <itunes:author>Dropout</itunes:author>
    9     9         <copyright>Dropout Connected Ventures</copyright>
   10    10         <podcast:funding url="https://www.dropout.tv">Subscribe</podcast:funding>
   11    -1         <itunes:image href="{{ additional_images.aspect_ratio_1_1.medium }}" />
   -1    11         <itunes:image href="{{ col.additional_images.aspect_ratio_1_1.medium }}" />
   12    12         <itunes:category text="Comedy" />
   13    13         {% for item in items %}
   14    14             <item>
   15    -1                 <title>{% if type == 'series' %}{{ item.metadata.season_name }}: {% endif %}{{ item.title }}</title>
   -1    15                 <title>{% if col.type == 'series' %}{{ item.metadata.season_name }}: {% endif %}{{ item.title }}</title>
   16    16                 <link>{{ item._links.video_page.href }}</link>
   17    17                 <guid>{{ item._links.video_page.href }}</guid>
   18    18                 <pubDate>{{ item.created_at|feed_date }}</pubDate>
   19    19                 {%+ if description %}<description>{{ item.description }}</description>{% endif %}
   20    20                 <itunes:duration>{{ item.duration.seconds }}</itunes:duration>
   21    21                 <itunes:image href="{{ item.additional_images.aspect_ratio_1_1.medium }}" />
   22    -1                 {% if type == 'series' %}
   -1    22                 {% if col.type == 'series' %}
   23    23                     {%+ if item.season_number %}<itunes:season>{{ item.season_number }}</itunes:season>{% endif%}
   24    24                     {%+ if item.episode_number %}<itunes:episode>{{ item.episode_number }}</itunes:episode>{% endif%}
   25    25                 {% endif %}

diff --git a/templates/series.html b/templates/series.html

@@ -1,17 +1,17 @@
    1     1 {% extends 'base.html' %}
    2     2 
    3    -1 {% block title %}{{ title }} - {{ super() }}{% endblock %}
   -1     3 {% block title %}{{ col.title }} - {{ super() }}{% endblock %}
    4     4 
    5     5 {% block head %}
    6     6     {% if ORIGIN %}
    7    -1         <link rel="alternate" type="application/atom+xml" href="/series/{{ id }}.rss">
   -1     7         <link rel="alternate" type="application/atom+xml" href="/series/{{ col.id }}.rss">
    8     8     {% endif %}
    9     9 {% endblock %}
   10    10 
   11    11 {% block content %}
   12    12     <div class="wrapper-wide">
   13    -1         <h1>{{ title }}</h1>
   14    -1         {%+ if description %}<div class="description">{{ description|linebreaks }}</div>{% endif %}
   -1    13         <h1>{{ col.title }}</h1>
   -1    14         {%+ if col.description %}<div class="description">{{ col.description|linebreaks }}</div>{% endif %}
   15    15 
   16    16         {% for season in seasons|reverse %}
   17    17             <h2 id="season-{{ season.season_number }}">{{ season.title }}</h2>

diff --git a/templates/video.html b/templates/video.html

@@ -1,14 +1,14 @@
    1     1 {% extends 'base.html' %}
    2     2 
    3    -1 {% block title %}{{ title }} &middot; {% if metadata.series_name %}{{ metadata.series_name }} &middot;{% endif %} {{ super() }}{% endblock %}
   -1     3 {% block title %}{{ video.title }} &middot; {% if video.metadata.series_name %}{{ video.metadata.series_name }} &middot;{% endif %} {{ super() }}{% endblock %}
    4     4 
    5     5 {% block content %}
    6     6     <div class="relative">
    7    -1         <video controls poster="{{ thumbnail.large }}" preload="none" width="960" height="720">
    8    -1             {% for file in _embedded.files %}
    9    -1                 <source type="{{ file.mime_type }}" src="/video/{{ id }}-{{ file.quality }}.{{ file.format }}" {% if file.quality != 'adaptive' %}media="(min-height: {{ file.quality }}x)" data-quality="{{ file.quality }}" data-co2="{{ file.size.formatted }} (~{{ file.size.bytes|co2 }})"{% endif %}>
   -1     7         <video controls poster="{{ video.thumbnail.large }}" preload="none" width="960" height="720">
   -1     8             {% for file in video._embedded.files %}
   -1     9                 <source type="{{ file.mime_type }}" src="/video/{{ video.id }}-{{ file.quality }}.{{ file.format }}" {% if file.quality != 'adaptive' %}media="(min-height: {{ file.quality }}x)" data-quality="{{ file.quality }}" data-co2="{{ file.size.formatted }} (~{{ file.size.bytes|co2 }})"{% endif %}>
   10    10             {% endfor %}
   11    -1             {% for track in tracks.subtitles %}
   -1    11             {% for track in video.tracks.subtitles %}
   12    12                 <track kind="{{ track.kind }}" label="{{ track.label }}" srclang="{{ track.srclang }}" src="{{ track._links.vtt.href }}">
   13    13             {% endfor %}
   14    14         </video>
@@ -17,22 +17,22 @@
   17    17         {% endif %}
   18    18     </div>
   19    19     <div class="wrapper">
   20    -1         <h1>{{ title }}</h1>
   -1    20         <h1>{{ video.title }}</h1>
   21    21         <div class="meta">
   22    -1             {% if metadata.series_id %}
   23    -1                 <a href="/series/{{ metadata.series_id }}/">{{ metadata.series_name }}</a>
   24    -1                 <a href="/series/{{ metadata.series_id }}/#season-{{ metadata.season_number }}" class="hidden-link">Season {{ metadata.season_number }}</a>,
   25    -1                 Episode {{ metadata.episode_number }}
   -1    22             {% if video.metadata.series_id %}
   -1    23                 <a href="/series/{{ video.metadata.series_id }}/">{{ video.metadata.series_name }}</a>
   -1    24                 <a href="/series/{{ video.metadata.series_id }}/#season-{{ video.metadata.season_number }}" class="hidden-link">Season {{ video.metadata.season_number }}</a>,
   -1    25                 Episode {{ video.metadata.episode_number }}
   26    26                 &middot;
   27    27             {% endif %}
   28    -1             {{ duration|duration }} &middot;
   29    -1             <time title="{{ created_at }}">{{ created_at|dt }}</time>
   30    -1             {% if _links.video_page %}&middot; <a class="hidden-link" href="{{ _links.video_page.href }}" referrerpolicy="no-referrer">Watch on dropout.tv</a>{% endif %}
   -1    28             {{ video.duration|duration }} &middot;
   -1    29             <time title="{{ video.created_at }}">{{ video.created_at|dt }}</time>
   -1    30             {% if video._links.video_page %}&middot; <a class="hidden-link" href="{{ video._links.video_page.href }}" referrerpolicy="no-referrer">Watch on dropout.tv</a>{% endif %}
   31    31         </div>
   32    -1         {%+ if description %}<div class="description">{{ description|linebreaks }}</div>{% endif %}
   33    -1         {% if tags %}
   -1    32         {%+ if video.description %}<div class="description">{{ video.description|linebreaks }}</div>{% endif %}
   -1    33         {% if video.tags %}
   34    34             <ul class="tags">
   35    -1                 {% for tag in tags %}
   -1    35                 {% for tag in video.tags %}
   36    36                     <li class="tag"><a href="/search/?q=tags: {{ tag }}" rel="tag">#{{ tag }}</a></li>
   37    37                 {% endfor %}
   38    38             </ul>