Compare commits

..

No commits in common. "511abd591d119ecb7de32ef8bedf2cae10cac70c" and "d3b5d86bca2392e4f3f40bcef315e76eb900c83e" have entirely different histories.

2 changed files with 21 additions and 25 deletions

View File

@ -9,11 +9,11 @@ def process_mp3(mp3_path)
dirname = File.dirname(mp3_path) dirname = File.dirname(mp3_path)
current_info, stderr, status = Open3.capture3("id3info", mp3_path) current_info, stderr, status = Open3.capture3("id3info", mp3_path)
current_info.force_encoding("ASCII-8BIT") current_info.force_encoding("ASCII-8BIT")
#if current_info =~ /TIT2\s.*: (.*)/ if current_info =~ /TIT2\s.*: (.*)/
# title = $1 title = $1
#else else
title = File.basename(mp3_path).sub(/\.mp3$/, "") title = File.basename(mp3_path).sub(/\.mp3$/, "")
#end end
artist = File.basename(File.dirname(File.dirname(mp3_path))) artist = File.basename(File.dirname(File.dirname(mp3_path)))
album = File.basename(File.dirname(mp3_path)) album = File.basename(File.dirname(mp3_path))
if current_info =~ /TYER\s.*: (.*)/ if current_info =~ /TYER\s.*: (.*)/
@ -33,9 +33,8 @@ def process_mp3(mp3_path)
args += %W[--track=#{track_number}] if track_number args += %W[--track=#{track_number}] if track_number
args += %W[--release-year=#{year}] if year args += %W[--release-year=#{year}] if year
# 2017 Outback likes to show picture for OTHER but not FRONT_COVER... # 2017 Outback likes to show picture for OTHER but not FRONT_COVER...
#args += %W[--add-image=#{album_art}:OTHER] if album_art args += %W[--add-image=#{album_art}:OTHER] if album_art
args += [mp3_path] args += [mp3_path]
system("eyeD3", "--remove-all", mp3_path)
system("eyeD3", *args) system("eyeD3", *args)
end end

View File

@ -35,7 +35,7 @@ def choose_artwork(mp3s, jpgs):
if len(mp3s) < min_mp3s_for_album: if len(mp3s) < min_mp3s_for_album:
return None return None
if len(jpgs) == 0: if len(jpgs) == 0:
sys.stderr.write("No .jpg files found in %s\n" % (os.path.dirname(mp3s[0]))) sys.stderr.write("No .jpg files found\n")
return None return None
if len(jpgs) > 1: if len(jpgs) > 1:
sys.stderr.write("Multiple .jpg album artwork files found\n") sys.stderr.write("Multiple .jpg album artwork files found\n")
@ -61,7 +61,7 @@ def clean_tag(mp3, tagname):
orig_text = tag.text[0] orig_text = tag.text[0]
new_text = clean_title(orig_text) new_text = clean_title(orig_text)
if new_text != orig_text: if new_text != orig_text:
sys.stdout.write("Changing %s from \"%s\" to \"%s\" for %s\n" % (tagname, orig_text, new_text, mp3.filename)) sys.stdout.write("Changing %s from \"%s\" to \"%s\"\n" % (tagname, orig_text, new_text))
tag.text = [new_text] tag.text = [new_text]
return True return True
return False return False
@ -69,7 +69,6 @@ def clean_tag(mp3, tagname):
def process_mp3(mp3_path, artwork_path): def process_mp3(mp3_path, artwork_path):
mp3 = mutagen.mp3.MP3(mp3_path) mp3 = mutagen.mp3.MP3(mp3_path)
current_tags = mp3.tags current_tags = mp3.tags
if current_tags is not None:
changed = False changed = False
changed = clean_tag(mp3, "TIT2") or changed changed = clean_tag(mp3, "TIT2") or changed
changed = clean_tag(mp3, "TALB") or changed changed = clean_tag(mp3, "TALB") or changed
@ -84,8 +83,6 @@ def process_mp3(mp3_path, artwork_path):
if changed and not dry_run: if changed and not dry_run:
sys.stdout.write("Writing %s\n" % mp3_path) sys.stdout.write("Writing %s\n" % mp3_path)
mp3.save() mp3.save()
else:
sys.stdout.write("Warning: no tags found for %s\n" % (mp3_path))
def main(argv): def main(argv):
base_dir = "." base_dir = "."