rewrite search functions as classes

This commit is contained in:
geoffrey45
2022-05-18 18:04:01 +03:00
parent 8405efede0
commit 4040b99518
9 changed files with 170 additions and 32 deletions
+20 -1
View File
@@ -32,8 +32,11 @@ class Track:
albumhash: str
def __init__(self, tags):
try:
self.trackid = tags["_id"]["$oid"]
except KeyError:
print(tags)
self.trackid = tags["_id"]["$oid"]
self.title = tags["title"]
self.artists = tags["artists"].split(", ")
self.albumartist = tags["albumartist"]
@@ -49,6 +52,22 @@ class Track:
self.albumhash = tags["albumhash"]
@dataclass(slots=True)
class Artist:
"""
Artist class
"""
artistid: str
name: str
image: str
def __init__(self, tags):
self.artistid = tags["_id"]["$oid"]
self.name = tags["name"]
self.image = tags["image"]
@dataclass
class Album:
"""