def __init__(self) -> None:
self.last_update = PlayerUpdateId('')
- self._load_filenames()
+ self.load_files()
self._mpv: Optional[MPV] = None
self._kill_queue: Queue = Queue()
self._monitoring_kill = False
Thread(target=kill_on_queue_get, daemon=True).start()
- def _load_filenames(self) -> None:
+ def load_files(self) -> None:
+ """Collect files in PATH_DOWNLOADS DB-known and of legal extension."""
conn = DbConnection()
known_files = {f.full_path: f for f in VideoFile.get_all(conn)}
conn.commit_close()
self._mpv = None
self._signal_update()
+ @property
+ def empty(self) -> bool:
+ """Return if playlist empty."""
+ return 0 == len(self._files)
+
@property
def current_file(self) -> Optional[VideoFile]:
"""Return what we assume is the currently playing file."""
def reload(self) -> None:
"""Close MPV, re-read (and re-shuffle) filenames, then re-start MPV."""
self._kill_mpv()
- self._load_filenames()
+ self.load_files()
self._start_mpv()
self._signal_update()
headers=[('Content-type', 'application/json')])
def _send_playlist(self) -> None:
+ if self.server.player.empty:
+ self.server.player.load_files()
self._send_rendered_template(
NAME_TEMPLATE_PLAYLIST,
{'last_update': self.server.player.last_update,