mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
add methods to get recently played items
This commit is contained in:
+28
-3
@@ -1,11 +1,36 @@
|
||||
from attr import dataclass
|
||||
from dataclasses import dataclass
|
||||
from typing import Literal
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass
|
||||
class Track:
|
||||
"""
|
||||
Track play logger model
|
||||
"""
|
||||
|
||||
id: int
|
||||
trackhash: str
|
||||
duration: int
|
||||
timestamp: int
|
||||
timestamp: int
|
||||
source: str
|
||||
userid: int
|
||||
|
||||
type = "track"
|
||||
type_src = None
|
||||
|
||||
def __post_init__(self):
|
||||
prefix_map = {
|
||||
"al:": "album",
|
||||
"ar:": "artist",
|
||||
"pl:": "playlist",
|
||||
"fo:": "folder",
|
||||
}
|
||||
|
||||
for prefix, srctype in prefix_map.items():
|
||||
if self.source.startswith(prefix):
|
||||
try:
|
||||
self.type_src = self.source.split(":", 1)[1]
|
||||
except IndexError:
|
||||
pass
|
||||
self.type = srctype
|
||||
break
|
||||
|
||||
@@ -11,13 +11,13 @@ class Playlist:
|
||||
"""Creates playlist objects"""
|
||||
|
||||
id: int
|
||||
image: str
|
||||
image: str | None
|
||||
last_updated: str
|
||||
name: str
|
||||
settings: str | dict
|
||||
trackhashes: str | list[str]
|
||||
|
||||
thumb: str = ""
|
||||
thumb: str | None = ""
|
||||
count: int = 0
|
||||
duration: int = 0
|
||||
has_image: bool = False
|
||||
|
||||
Reference in New Issue
Block a user