mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
add is_soundtrack and is_compilation flags to album objects
This commit is contained in:
+20
-4
@@ -86,25 +86,41 @@ class Album:
|
|||||||
hash: str
|
hash: str
|
||||||
count: int = 0
|
count: int = 0
|
||||||
duration: int = 0
|
duration: int = 0
|
||||||
|
is_soundtrack: bool = False
|
||||||
|
is_compilation: bool = False
|
||||||
|
|
||||||
def __init__(self, tags):
|
def __init__(self, tags):
|
||||||
self.title = tags["title"]
|
self.title = tags["title"]
|
||||||
self.artist = tags["artist"]
|
self.artist = tags["artist"]
|
||||||
self.date = tags["date"]
|
self.date = tags["date"]
|
||||||
self.image = tags["image"]
|
self.image = tags["image"]
|
||||||
self.hash = helpers.create_album_hash(self.title, self.artist)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.hash = tags["albumhash"]
|
self.hash = tags["albumhash"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.hash = helpers.create_album_hash(self.title, self.artist)
|
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):
|
def get_p_track(ptrack):
|
||||||
for track in api.TRACKS:
|
for track in api.TRACKS:
|
||||||
if (track.title == ptrack["title"]
|
if (
|
||||||
and track.artists == ptrack["artists"]
|
track.title == ptrack["title"]
|
||||||
and ptrack["album"] == track.album):
|
and track.artists == ptrack["artists"]
|
||||||
|
and ptrack["album"] == track.album
|
||||||
|
):
|
||||||
return track
|
return track
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ interface AlbumInfo {
|
|||||||
duration: number;
|
duration: number;
|
||||||
date: string;
|
date: string;
|
||||||
image: string;
|
image: string;
|
||||||
|
is_compilation: boolean;
|
||||||
|
is_soundtrack: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Artist {
|
interface Artist {
|
||||||
|
|||||||
Reference in New Issue
Block a user