Make Queue.current nullable, since MPD may be stopped
This commit is contained in:
parent
b41339a8c5
commit
7dfd3f85e4
3 changed files with 7 additions and 5 deletions
|
@ -104,7 +104,7 @@
|
||||||
"Queue": {
|
"Queue": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"current": {
|
"current": {
|
||||||
"description": "The zero-based index of the current song in MPD's queue.",
|
"description": "The zero-based index of the current song in MPD's queue. If MPD is currently stopped, then there is no current song in the queue, indicated by None.",
|
||||||
"title": "Current",
|
"title": "Current",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,8 +9,8 @@ from .to_song import to_song
|
||||||
|
|
||||||
def to_queue(mpd: MpdState) -> Queue:
|
def to_queue(mpd: MpdState) -> Queue:
|
||||||
return Queue(
|
return Queue(
|
||||||
current=int(mpd.current["pos"]),
|
current=option_fmap(int, mpd.current.get("pos")),
|
||||||
next=int(mpd.status["nextsong"]),
|
next=int(mpd.status.get("nextsong", 0)),
|
||||||
length=int(mpd.status["playlistlength"]),
|
length=int(mpd.status["playlistlength"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,10 @@ from dataclasses import dataclass
|
||||||
|
|
||||||
@dataclass(slots=True)
|
@dataclass(slots=True)
|
||||||
class Queue:
|
class Queue:
|
||||||
#: The zero-based index of the current song in MPD's queue.
|
#: The zero-based index of the current song in MPD's queue. If MPD is
|
||||||
current: int
|
#: currently stopped, then there is no current song in the queue, indicated
|
||||||
|
#: by None.
|
||||||
|
current: int | None
|
||||||
#: The index of the next song to be played, taking into account random and
|
#: The index of the next song to be played, taking into account random and
|
||||||
#: repeat playback settings.
|
#: repeat playback settings.
|
||||||
next: int
|
next: int
|
||||||
|
|
Loading…
Add table
Reference in a new issue