{% block css %}
-table { width: 100%; }
#status { text-align: center; font-weight: bold; }
+table { width: 100%; }
+th { text-align: center; }
+td { vertical-align: top; }
td.history { width: 50%; }
{% endblock %}
<input type="submit" name="reload" value="reload">
</form>
</td></tr>
-{% for prev_video, next_video in tuples %}
-<tr><td class="history">
-<a href="/{{page_names.file}}/{{prev_video.rel_path_b64}}">{{ prev_video.basename }}</a>
-</td><td class="history">
-<a href="/{{page_names.file}}/{{next_video.rel_path_b64}}">{{ next_video.basename }}</a>
-</td></tr>
-{% endfor %}
+<tr><th>past</th><th>future</th></tr>
+<tr>
+<td class="history">
+<ul>{% for file in prev_files %}
+<li><a href="/{{page_names.file}}/{{file.rel_path_b64}}">{{ file.basename }}</a>
+{% endfor %}</ul>
+</td>
+<td class="history">
+<ul>{% for file in next_files %}
+<li><a href="/{{page_names.file}}/{{file.rel_path_b64}}">{{ file.basename }}</a>
+{% endfor %}</ul>
+</td>
+</tr>
</table>
{% endblock %}
B64Str = NewType('B64Str', str)
PageNames: TypeAlias = dict[str, PathStr]
DownloadsIndex: TypeAlias = dict[YoutubeId, PathStr]
-PlaylistTuples = list[tuple[Optional['VideoFile'], Optional['VideoFile']]]
TemplateContext: TypeAlias = dict[
- str, None | bool | PlayerUpdateId | Optional[PathStr] | YoutubeId
- | QueryText | QuotaCost | list[FlagName] | 'VideoFile' | 'YoutubeVideo'
- | PageNames | list['YoutubeVideo'] | list['YoutubeQuery']
- | list[tuple[B64Str, PathStr]] | PlaylistTuples]
+ str,
+ None | bool
+ | PageNames | PathStr | PlayerUpdateId | QueryText | QuotaCost
+ | 'VideoFile' | YoutubeId | 'YoutubeVideo'
+ | list[FlagName] | list['VideoFile'] | list['YoutubeVideo']
+ | list['YoutubeQuery']
+]
# major expected directories
PATH_HOME = PathStr(environ.get('HOME', ''))
def _send_files_index(self) -> None:
conn = DbConnection()
- files = [(f.rel_path_b64, f.rel_path) for f in VideoFile.get_all(conn)]
+ files = VideoFile.get_all(conn)
conn.commit_close()
- files.sort(key=lambda t: t[1])
+ files.sort(key=lambda t: t.rel_path)
self._send_rendered_template(NAME_TEMPLATE_FILES, {'files': files})
def _send_missing_json(self) -> None:
headers=[('Content-type', 'application/json')])
def _send_playlist(self) -> None:
- tuples: PlaylistTuples = []
- i: int = 0
- while True:
- prev, next_ = None, None
- if len(self.server.player.prev_files) > i:
- prev = self.server.player.prev_files[i]
- if len(self.server.player.next_files) > i:
- next_ = self.server.player.next_files[i]
- if not (prev or next_):
- break
- tuples += [(prev, next_)]
- i += 1
self._send_rendered_template(
NAME_TEMPLATE_PLAYLIST,
{'last_update': self.server.player.last_update,
'running': self.server.player.is_running,
'paused': self.server.player.is_paused,
'current_video': self.server.player.current_file,
- 'tuples': tuples})
+ 'prev_files': self.server.player.prev_files,
+ 'next_files': self.server.player.next_files})