mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +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
|
||||
|
||||
Reference in New Issue
Block a user