fix: updating the tracksort on songs
This commit is contained in:
parent
38f3b1da1d
commit
d71c2f19e7
@ -144,7 +144,7 @@ def cli():
|
||||
genre=genre,
|
||||
download_all=arguments.all,
|
||||
direct_download_url=arguments.url,
|
||||
process_metadata_anyway=arguments.force_post_process or arguments.test
|
||||
process_metadata_anyway=True or arguments.test
|
||||
)
|
||||
|
||||
|
||||
|
@ -320,40 +320,16 @@ class Album(Base):
|
||||
return
|
||||
|
||||
tracksort_map: Dict[int, Song] = {
|
||||
song.tracksort: song for song in self.song_collection if song.tracksort is not None
|
||||
song.tracksort: song for song in self.song_collection if song.tracksort != 0
|
||||
}
|
||||
|
||||
# place the songs, with set tracksort attribute according to it
|
||||
for tracksort, song in tracksort_map.items():
|
||||
index = tracksort - 1
|
||||
|
||||
"""
|
||||
I ONLY modify the `Collection._data` attribute directly,
|
||||
to bypass the mapping of the attributes, because I will add the item in the next step
|
||||
"""
|
||||
existing_list = self.song_collection.shallow_list
|
||||
for i in range(1, len(existing_list) + 1):
|
||||
if i not in tracksort_map:
|
||||
tracksort_map[i] = existing_list.pop(0)
|
||||
tracksort_map[i].tracksort = i
|
||||
|
||||
"""
|
||||
but for some reason, neither
|
||||
`self.song_collection._data.index(song)`
|
||||
`self.song_collection._data.remove(song)`
|
||||
get the right object.
|
||||
|
||||
I have NO FUCKING CLUE why xD
|
||||
But I just implemented it myself.
|
||||
"""
|
||||
for old_index, temp_song in enumerate(self.song_collection._data):
|
||||
if song is temp_song:
|
||||
break
|
||||
|
||||
# the list can't be empty
|
||||
del self.song_collection._data[old_index]
|
||||
self.song_collection._data.insert(index, song)
|
||||
|
||||
# fill in the empty tracksort attributes
|
||||
for i, song in enumerate(self.song_collection):
|
||||
if song.tracksort is not None:
|
||||
continue
|
||||
song.tracksort = i + 1
|
||||
|
||||
def compile(self, merge_into: bool = False):
|
||||
"""
|
||||
|
@ -335,7 +335,7 @@ class Page:
|
||||
music_object: DatabaseObject,
|
||||
genre: str,
|
||||
download_all: bool = False,
|
||||
process_metadata_anyway: bool = False
|
||||
process_metadata_anyway: bool = True
|
||||
) -> DownloadResult:
|
||||
naming_dict: NamingDict = NamingDict({"genre": genre})
|
||||
|
||||
@ -362,7 +362,7 @@ class Page:
|
||||
naming_dict: NamingDict,
|
||||
download_all: bool = False,
|
||||
skip_details: bool = False,
|
||||
process_metadata_anyway: bool = False
|
||||
process_metadata_anyway: bool = True
|
||||
) -> DownloadResult:
|
||||
trace(f"downloading {type(music_object).__name__} [{music_object.title_string}]")
|
||||
skip_next_details = skip_details
|
||||
@ -381,7 +381,6 @@ class Page:
|
||||
if isinstance(music_object, Album):
|
||||
music_object.update_tracksort()
|
||||
|
||||
|
||||
naming_dict.add_object(music_object)
|
||||
|
||||
if isinstance(music_object, Song):
|
||||
@ -400,7 +399,7 @@ class Page:
|
||||
|
||||
return download_result
|
||||
|
||||
def _download_song(self, song: Song, naming_dict: NamingDict, process_metadata_anyway: bool = False):
|
||||
def _download_song(self, song: Song, naming_dict: NamingDict, process_metadata_anyway: bool = True):
|
||||
if "genre" not in naming_dict and song.genre is not None:
|
||||
naming_dict["genre"] = song.genre
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user