mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-10 04:57:45 +00:00
use create_hash to compare album titles for is_single
+ add a few string checks for album.is_single
This commit is contained in:
parent
55a41f4f19
commit
e5f18f9301
@ -68,6 +68,7 @@ def extract_date(date_str: str | None, filepath: str) -> int:
|
|||||||
try:
|
try:
|
||||||
return int(date_str.split("-")[0])
|
return int(date_str.split("-")[0])
|
||||||
except: # pylint: disable=bare-except
|
except: # pylint: disable=bare-except
|
||||||
|
# TODO: USE FILEPATH LAST-MOD DATE instead of current date
|
||||||
return datetime.date.today().today().year
|
return datetime.date.today().today().year
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
from .track import Track
|
from .track import Track
|
||||||
from .artist import Artist
|
from .artist import Artist
|
||||||
|
from ..utils.hashing import create_hash
|
||||||
|
|
||||||
|
|
||||||
@dataclass(slots=True)
|
@dataclass(slots=True)
|
||||||
@ -105,16 +106,22 @@ class Album:
|
|||||||
return self.title.strip().endswith(" EP")
|
return self.title.strip().endswith(" EP")
|
||||||
|
|
||||||
def check_is_single(self, tracks: list[Track]):
|
def check_is_single(self, tracks: list[Track]):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Checks if the album is a single.
|
Checks if the album is a single.
|
||||||
"""
|
"""
|
||||||
|
keywords = ["single version", "- single"]
|
||||||
|
for keyword in keywords:
|
||||||
|
if keyword in self.title.lower():
|
||||||
|
self.is_single = True
|
||||||
|
return
|
||||||
|
|
||||||
if (
|
if (
|
||||||
len(tracks) == 1
|
len(tracks) == 1
|
||||||
and tracks[0].title.lower() == self.title.lower()
|
and create_hash(tracks[0].title) == create_hash(self.title) # if they have the same title
|
||||||
|
|
||||||
# and tracks[0].track == 1
|
# and tracks[0].track == 1
|
||||||
# and tracks[0].disc == 1
|
# and tracks[0].disc == 1
|
||||||
# Todo: Are the above commented checks necessary?
|
# TODO: Review -> Are the above commented checks necessary?
|
||||||
):
|
):
|
||||||
self.is_single = True
|
self.is_single = True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user