{% block body %}
-<a href="#playing">#playing</a>
+<a href="#playing">jump to playing</a>
<button onclick="player_command('rebuild')">rebuild</button>
+<button onclick="player_command('empty')">empty</button>
<hr />
<table id="playlist_rows">
</table>
self.server.player.next()
elif 'rebuild' == command:
self.server.player.load_files_and_mpv()
+ elif 'empty' == command:
+ self.server.player.load_files_and_mpv(empty=True)
elif command.startswith('jump_'):
self.server.player.jump_to(int(command.split('_')[1]))
elif command.startswith('up_'):
self._mpv.command('loadfile', path, 'append')
self._idx = 0
- def load_files_and_mpv(self) -> None:
+ def load_files_and_mpv(self, empty: bool = False) -> None:
"""Collect filtered files into playlist, shuffle, start player."""
- with DbConn() as conn:
- known_files = {f.full_path: f for f in VideoFile.get_filtered(
- conn, self.filter_path, self.needed_tags)}
- self.playlist = [known_files[p] for p in PATH_DOWNLOADS.iterdir()
- if p in known_files
- and p.is_file()
- and p.suffix[1:] in LEGAL_EXTENSIONS]
- shuffle(self.playlist)
+ if empty:
+ self.playlist = []
+ else:
+ with DbConn() as conn:
+ known_files = {f.full_path: f for f in VideoFile.get_filtered(
+ conn, self.filter_path, self.needed_tags)}
+ self.playlist = [known_files[p] for p in PATH_DOWNLOADS.iterdir()
+ if p in known_files
+ and p.is_file()
+ and p.suffix[1:] in LEGAL_EXTENSIONS]
+ shuffle(self.playlist)
self._kill_mpv()
self._start_mpv()