v0.31.0: Cassette followed playlists — a friend's playlist in your sidebar
- A followed playlist (the UFO in friend mode) appears in my sidebar with a purple UFO: mixed in with my playlists alphabetically, or inside a folder named after the friend (per-friend, in Sync Settings). It's never a Playlist of mine, so it stays out of the library and its merges. - It plays from the cache. Player's queue accepts friend-track keys, resolved through Cassette: they scrobble to Last.fm but don't count in my play journal. Songs still on their way are grey and skipped. - The cassette column there is hidden by default (right-click the header); pressing one takes the song into my library — straight from the cache if it's there, otherwise by asking for it. - Sync Settings per friend: keep followed songs separate (default) or add them to my library. Unfollowing (right-click) frees their cache. - The bottom bar says when the friend's folder last synced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+29
-4
@@ -418,6 +418,13 @@ class Player(QObject):
|
||||
# here rather than in a sink so both playback paths honor it.
|
||||
self._stop_at_ms = 0
|
||||
self._counted_finish_id: int | None = None
|
||||
# Queue entries are my track ids (int) or, for a friend's followed
|
||||
# playlist, opaque string keys ("cassette:<token>:<their id>")
|
||||
# resolved through this callback — Player stays manager-free about
|
||||
# friends. Plays of friend tracks scrobble but don't count in my
|
||||
# journal.
|
||||
self.track_resolver = None # Callable[[str], Track | None]
|
||||
self._current_key = None
|
||||
self._volume = 1.0 # logical 0..1; what the volume slider shows
|
||||
|
||||
self._local = LocalSink(self)
|
||||
@@ -624,6 +631,7 @@ class Player(QObject):
|
||||
def stop(self):
|
||||
self._sink.stop()
|
||||
self._current_track = None
|
||||
self._current_key = None
|
||||
self.track_changed.emit(None)
|
||||
|
||||
def next(self):
|
||||
@@ -668,7 +676,8 @@ class Player(QObject):
|
||||
AAC). The skip is a loop, not recursion: shuffling into a run of
|
||||
unsupported tracks must not walk the stack down."""
|
||||
while 0 <= self._index < len(self._queue):
|
||||
track = self._manager.library.tracks.get(self._queue[self._index])
|
||||
key = self._queue[self._index]
|
||||
track = self._resolve(key)
|
||||
if track is None:
|
||||
# The queue references a track that's no longer in the library;
|
||||
# there's nothing to locate, so just report and stop.
|
||||
@@ -700,6 +709,7 @@ class Player(QObject):
|
||||
continue
|
||||
|
||||
self._current_track = track
|
||||
self._current_key = key
|
||||
# Arm the custom stop time for this track. It's honored only when
|
||||
# it falls before the end (otherwise the natural finish handles it).
|
||||
if track.stop_time > 0 and (track.total_time == 0
|
||||
@@ -754,8 +764,23 @@ class Player(QObject):
|
||||
def _note_finished(self, track):
|
||||
"""Record a completed play once, guarding against a double count if
|
||||
both the stop-time and end-of-media paths fire for the same track."""
|
||||
if track is None or track.track_id == self._counted_finish_id:
|
||||
if track is None:
|
||||
return
|
||||
self._counted_finish_id = track.track_id
|
||||
self._manager.record_play(track.track_id)
|
||||
key = (self._current_key if track is self._current_track
|
||||
and self._current_key is not None else track.track_id)
|
||||
if key == self._counted_finish_id:
|
||||
return
|
||||
self._counted_finish_id = key
|
||||
if not isinstance(key, str):
|
||||
self._manager.record_play(track.track_id)
|
||||
self.track_finished.emit(track)
|
||||
|
||||
def _resolve(self, key):
|
||||
if isinstance(key, str):
|
||||
return self.track_resolver(key) if self.track_resolver else None
|
||||
return self._manager.library.tracks.get(key)
|
||||
|
||||
@property
|
||||
def current_key(self):
|
||||
"""The queue entry playing: a track id, or a friend track's key."""
|
||||
return self._current_key
|
||||
|
||||
Reference in New Issue
Block a user