add is_soundtrack and is_compilation flags to album objects

This commit is contained in:
geoffrey45 2022-06-07 16:47:44 +03:00
parent 4e1e1b8979
commit e75ac3e394
2 changed files with 22 additions and 4 deletions

View File

@ -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

View File

@ -31,6 +31,8 @@ interface AlbumInfo {
duration: number;
date: string;
image: string;
is_compilation: boolean;
is_soundtrack: boolean;
}
interface Artist {