subclient

Subsonic ncurses client
git clone https://git.e1e0.net/subclient.git
Log | Files | Refs | README

commit 91748eeb2ea31ec1cb39581d1cd1e37dc2239e0c
parent 0ef70cefb10db474ab4984a0e941c0a5a75f9f85
Author: Paco Esteban <paco@e1e0.net>
Date:   Sun, 29 Aug 2021 18:31:42 +0200

play more than one song

Now it plays from the selected song till the end of the disc.
A lot of work to be done, as we still cannot sync info with mpv and the
downloaded songs are not removed from /tmp after being played nor we
reuse them like a cache.

Diffstat:
Msubclient/player.py | 20+++++++++++---------
Msubclient/subclient.py | 4++--
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/subclient/player.py b/subclient/player.py @@ -12,15 +12,17 @@ class Player: self.stop() for s in playlist: stream = self.orig.get_song_stream(s) - with tempfile.NamedTemporaryFile() as fp: - while True: - chunk = stream.read(512*1024) - if not chunk: - break - fp.write(chunk) - fp.seek(0) - self.mpv.play(fp.name) - self.mpv.wait_for_property('eof-reached') + fp = tempfile.NamedTemporaryFile(prefix='subclient_song_', + delete=False) + while True: + chunk = stream.read(512*1024) + if not chunk: + break + fp.write(chunk) + fp.seek(0) + self.mpv.loadfile(fp.name, 'append-play') + fp.close() + # self.mpv.wait_for_property('eof-reached') def exit(self): self.mpv.terminate() diff --git a/subclient/subclient.py b/subclient/subclient.py @@ -98,8 +98,8 @@ class SubClient: self.player.set_pause(not self.player.is_paused()) elif c in [curses.KEY_ENTER, '\r', '\n']: if self.nav_list_type == self.SONGS: - self.player.play( - [self.nav_list[self.nav_top + self.nav_selected]]) + playlist = self.nav_list[self.nav_top + self.nav_selected:self.nav_bottom] + self.player.play(playlist) def load_list(self): for i, t in enumerate(