rename album title in track object after extract feat from album title

This commit is contained in:
geoffrey45 2023-04-16 18:05:52 +03:00
parent ac4be71e7b
commit 76604be1db
3 changed files with 8 additions and 4 deletions

View File

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

View File

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

View File

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