mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-07-29 06:02:06 +00:00
add is_soundtrack and is_compilation flags to album objects
This commit is contained in:
parent
4e1e1b8979
commit
e75ac3e394
@ -86,25 +86,41 @@ class Album:
|
||||
hash: str
|
||||
count: int = 0
|
||||
duration: int = 0
|
||||
is_soundtrack: bool = False
|
||||
is_compilation: bool = False
|
||||
|
||||
def __init__(self, tags):
|
||||
self.title = tags["title"]
|
||||
self.artist = tags["artist"]
|
||||
self.date = tags["date"]
|
||||
self.image = tags["image"]
|
||||
self.hash = helpers.create_album_hash(self.title, self.artist)
|
||||
|
||||
try:
|
||||
self.hash = tags["albumhash"]
|
||||
except KeyError:
|
||||
self.hash = helpers.create_album_hash(self.title, self.artist)
|
||||
|
||||
@property
|
||||
def is_soundtrack(self) -> bool:
|
||||
keywords = ["motion picture", "soundtrack"]
|
||||
for keyword in keywords:
|
||||
if keyword in self.title.lower():
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@property
|
||||
def is_compilation(self) -> bool:
|
||||
return self.artist.lower() == "various artists"
|
||||
|
||||
|
||||
def get_p_track(ptrack):
|
||||
for track in api.TRACKS:
|
||||
if (track.title == ptrack["title"]
|
||||
and track.artists == ptrack["artists"]
|
||||
and ptrack["album"] == track.album):
|
||||
if (
|
||||
track.title == ptrack["title"]
|
||||
and track.artists == ptrack["artists"]
|
||||
and ptrack["album"] == track.album
|
||||
):
|
||||
return track
|
||||
|
||||
|
||||
|
@ -31,6 +31,8 @@ interface AlbumInfo {
|
||||
duration: number;
|
||||
date: string;
|
||||
image: string;
|
||||
is_compilation: boolean;
|
||||
is_soundtrack: boolean;
|
||||
}
|
||||
|
||||
interface Artist {
|
||||
|
Loading…
x
Reference in New Issue
Block a user