Find the current song's URL and pass it on when possible

This commit is contained in:
Danielle McLean 2024-07-23 13:29:50 +10:00
parent b8bcdc5a83
commit d9c8e0fe28
Signed by: 00dani
GPG key ID: 6854781A0488421C
9 changed files with 79 additions and 21 deletions

View file

@ -3,6 +3,7 @@ from enum import StrEnum
from pathlib import Path
from ..tools.schema.define import schema
from ..tools.schema.fields import Url
from .artwork import Artwork
from .musicbrainz import MusicBrainzIds
@ -14,7 +15,7 @@ class PlaybackState(StrEnum):
@schema("https://cdn.00dani.me/m/schemata/mpd-now-playable/song-v1.json")
@dataclass(slots=True)
@dataclass(slots=True, kw_only=True)
class Song:
#: Whether MPD is currently playing, paused, or stopped. Pretty simple.
state: PlaybackState
@ -30,6 +31,13 @@ class Song:
#: places, so you can safely do the same.
file: Path
#: An absolute URL referring to the current song, if available. If the
#: song's a local file and its absolute path can be determined
#: (mpd-now-playable has been configured with your music directory), then
#: this field will contain a file:// URL. If the song's remote, then MPD
#: itself returns an absolute URL in the first place.
url: Url | None = None
#: The song's title, if it's been tagged with one. Currently only one title
#: is supported, since it doesn't make a lot of sense to tag a single audio
#: file with multiple titles.