diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-13 13:06:56 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-13 13:06:56 +0100 |
| commit | fe55526cbc6015c4268ee155f21bcb11de5609b5 (patch) | |
| tree | 64b176513e7e63e8fdf170e026d4da078bce5185 /tests | |
| parent | ab2ebfd768bcc11f9c9124c15d9da700b9352587 (diff) | |
| download | deck-it-fe55526cbc6015c4268ee155f21bcb11de5609b5.tar.gz deck-it-fe55526cbc6015c4268ee155f21bcb11de5609b5.zip | |
feat(music): covers for embedded art and videos
Haruna sends an embedded audio cover inline as a data:image URL, which
the module dropped, and clears mpris:artUrl for every video on purpose
so the task manager shows the live window. Serve both at
/api/music/image/<key>: the data URL decoded, a local video as one
ffmpeg frame (thumbnail filter, 480 px wide), made on first request and
kept until the track changes. Only the current track's key answers, so
the tablet names a key, never a path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_music.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_music.py b/tests/test_music.py index fe603cb..878c5f8 100644 --- a/tests/test_music.py +++ b/tests/test_music.py @@ -49,6 +49,28 @@ class Music(unittest.TestCase): st = music.make({"run": fake}).state() self.assertAlmostEqual(st["length"], 65.82, places=2) + def _state(self, art, url, frame=None): + out = "\x1f".join(["Playing", "t", "", "", "1", "0", art, "haruna", url]) + fake = lambda cmd, timeout=2: {"metadata": out, "get-volume": ""}[cmd[1]] + m = music.make({"run": fake, "frame": frame or (lambda path: b"")}) + return m, m.state() + + def test_embedded_cover_served_decoded(self): + m, st = self._state("data:image/png;base64,aGVsbG8=", "file:///a/song.flac") + key = st["art"].rsplit("/", 1)[1] + self.assertEqual(m.image(key), (b"hello", "image/png")) + self.assertIsNone(m.image("other")) + + def test_video_gets_a_frame(self): + paths = [] + m, st = self._state("", "file:///v/a%20clip.mp4", + lambda path: paths.append(path) or b"jpeg") + self.assertEqual(m.image(st["art"].rsplit("/", 1)[1]), (b"jpeg", "image/jpeg")) + self.assertEqual(paths, ["/v/a clip.mp4"]) + + def test_audio_without_cover_has_no_art(self): + self.assertIsNone(self._state("", "file:///a/song.flac")[1]["art"]) + def test_action_commands(self): self.assertEqual(music.BASE_ACTIONS["next"], ["playerctl", "next"]) |
