sane-tag-music: improve idempotency
This commit is contained in:
@@ -446,8 +446,9 @@ class Tags:
|
||||
|
||||
if self.producer:
|
||||
producer = clean_fields_for_fs(self.producer)
|
||||
formatted_album = clean_fields_for_fs([artist, album])
|
||||
return os.path.join(producer, formatted_album, filename)
|
||||
if artist != "Various.Artists":
|
||||
album = clean_fields_for_fs([artist, album])
|
||||
return os.path.join(producer, album, filename)
|
||||
else:
|
||||
return os.path.join(artist, album, filename)
|
||||
|
||||
@@ -490,10 +491,14 @@ class Tags:
|
||||
tags.title = [ new_title ]
|
||||
|
||||
def parse_track(track: str) -> None:
|
||||
track = os.path.splitext(track)[0]
|
||||
track_parts = [p.strip() for p in track.split(' - ')]
|
||||
basename = os.path.splitext(track)[0]
|
||||
track_parts = [p.strip() for p in basename.split(' - ')]
|
||||
if len(track_parts) == 1:
|
||||
parse_title(track)
|
||||
parse_title(track_parts[0])
|
||||
if len(track) > 2 and track[0] in "0123456789" and track[1] in "0123456789" and track[2] == "-":
|
||||
# parse this as a track i've already encoded.
|
||||
# this is necessary for files which don't support metadata, like lyric files.
|
||||
parse_track(track.replace("-", " - "))
|
||||
elif len(track_parts) == 2:
|
||||
if tags.albumartist and loose_compare_str(track_parts[0], tags.albumartist[0]):
|
||||
# `AlbumArtist - track`
|
||||
@@ -893,7 +898,15 @@ class Gatherer:
|
||||
"""
|
||||
for root in self.roots:
|
||||
_tags_seen, files = self.files_below(root)
|
||||
yield from files
|
||||
for file_, tags in files:
|
||||
ftags = file_.tags_on_disk()
|
||||
if ftags == Tags():
|
||||
ftags = Tags.from_path(file_.path_)
|
||||
if ftags.is_artist_item(file_.ext):
|
||||
# we can't generalize *any* tags to an artist item (e.g. Justice/artist.png)
|
||||
yield file_, Tags()
|
||||
else:
|
||||
yield file_, tags
|
||||
|
||||
def files_below(self, root: str) -> tuple[Tags, list[tuple[MediaFile, Tags]]]:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user