From 994711b887a23d29e2504e912d9d4b68344ab118 Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Sun, 16 Apr 2023 18:05:52 +0300 Subject: [PATCH] rename album title in track object after extract feat from album title --- app/models/album.py | 2 +- app/models/track.py | 6 +++++- app/store/tracks.py | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/album.py b/app/models/album.py index 9794639..42693c8 100644 --- a/app/models/album.py +++ b/app/models/album.py @@ -47,7 +47,7 @@ class Album: self.albumartists.extend([Artist(a) for a in featured if a.lower() not in original_lower]) from ..store.tracks import TrackStore - TrackStore.append_track_artists(self.albumhash, featured) + TrackStore.append_track_artists(self.albumhash, featured, self.title) self.albumartists_hashes = "-".join(a.artisthash for a in self.albumartists) diff --git a/app/models/track.py b/app/models/track.py index c2ac466..d3a73a5 100644 --- a/app/models/track.py +++ b/app/models/track.py @@ -85,9 +85,13 @@ class Track: def recreate_artists_hash(self): self.artist_hashes = "-".join(a.artisthash for a in self.artist) - def add_artists(self, artists: list[str]): + def rename_album(self, new_album: str): + self.album = new_album + + def add_artists(self, artists: list[str], new_album_title: str): for artist in artists: if create_hash(artist) not in self.artist_hashes: self.artist.append(ArtistMinimal(artist)) self.recreate_artists_hash() + self.rename_album(new_album_title) diff --git a/app/store/tracks.py b/app/store/tracks.py index 0b3bd6b..74aea45 100644 --- a/app/store/tracks.py +++ b/app/store/tracks.py @@ -98,11 +98,11 @@ class TrackStore: track.is_favorite = False @classmethod - def append_track_artists(cls, albumhash: str, artists: list[str]): + def append_track_artists(cls, albumhash: str, artists: list[str], new_album_title:str): tracks = cls.get_tracks_by_albumhash(albumhash) for track in tracks: - track.add_artists(artists) + track.add_artists(artists, new_album_title) # ================================================ # ================== GETTERS =====================