musicfix

music file renamer and tagger
git clone git://git.2f30.org/musicfix
Log | Files | Refs | README | LICENSE

commit f2415ddcc7e3466781d50e92d0b947b05ee0cae8
parent 311974660fc4ab20adeaeb9cf3e6c27097a99fda
Author: lostd <lostd@2f30.org>
Date:   Sat, 13 Dec 2014 12:20:36 +0200

Rework the release format string code

Diffstat:
Mbin/musicfix | 87++++++++++++++++++++++++++++++++++++++++++-------------------------------------
1 file changed, 46 insertions(+), 41 deletions(-)

diff --git a/bin/musicfix b/bin/musicfix @@ -98,57 +98,62 @@ def mkposlist tracks pl.flatten end +# Formats we care about and their abbreviations +# http://www.discogs.com/search/#more_facets_format_exact +# Ignore "Vinyl" in favor of "LP"/"EP"/'7"'/'10"'/'12"' descriptions +# Ignore "File" in favor of "MP3"/"WAV"/"FLAC" descriptions +# Avoid too generic descriptions such as "Album" +# Avoid too specific descriptions such as "Green", "Gatefold" +@ft = { + 'CD' => 'CD', + 'CDr' => 'CDr', + 'LP' => 'LP', + 'EP' => 'EP', + 'Cassette' => 'Cass', + '12"' => '12inch', + '10"' => '10inch', + '7"' => '7inch', + 'Mini-Album' => 'MiniAlbum', + 'Maxi-Single' => 'Maxi', + 'Picture Disc' => 'Pic', + 'Flexi-disc' => 'Flexi', + 'Promo' => 'Promo', + 'Reissue' => 'RE', + 'Remastered' => 'RM', + 'Remaster' => 'RM', + 'Repress' => 'RP', + 'Mispress' => 'MP', + 'Test Pressing' => 'TP', + 'Enhanced' => 'Enh', + 'Digipak ' => 'Dig', + 'Box Set' => 'Box', + 'Limited Edition' => 'Ltd', + 'Club Edition' => 'Club', + 'Compilation' => 'Comp', + 'Sampler' => 'Smplr', + 'Numbered' => 'Num', + 'Unofficial Release' => 'Unofficial', + 'Single Sided' => 'S/Sided', + 'MP3' => 'MP3', + 'AAC' => 'AAC', + 'FLAC' => 'FLAC', + 'WAV' => 'WAV', +} + # Make a sane format string also using format description def mkformat format f = [] - # Ignore in favor of LP/EP/7"/10"/12" descriptions - unless format['name'] == "Vinyl" - f << format['name'] - end - if format['descriptions'] - # Too general - format['descriptions'].delete "Album" - unless format['descriptions'].empty? - f << format['descriptions'].first - end + ([format['name']] + format['descriptions']).each do |d| + f << d if @ft.keys.include? d end f.join ' ' end # Shorten certain common words that appear in format strings def mkshort n - ft = { - 'Cassette' => 'Cass', - '12"' => '12inch', - '10"' => '10inch', - '7"' => '7inch', - 'Mini-Album' => 'MiniAlbum', - 'Maxi-Single' => 'Maxi', - 'Picture Disc' => 'Pic', - 'Flexi-disc' => 'Flexi', - 'Reissue' => 'RE', - 'Remastered' => 'RM', - 'Remaster' => 'RM', - 'Repress' => 'RP', - 'Mispress' => 'MP', - 'Test Pressing' => 'TP', - 'Enhanced' => 'Enh', - 'Digipak ' => 'Dig', - 'Box Set' => 'Box', - 'Limited Edition' => 'Ltd', - 'Club Edition' => 'Club', - 'Compilation' => 'Comp', - 'Sampler' => 'Smplr', - 'Numbered' => 'Num', - 'Unofficial Release' => 'Unofficial', - 'Single Sided' => 'S/Sided', - 'File MP3' => 'MP3', - 'File FLAC' => 'FLAC', - 'File WAV' => 'WAV', - } # Note that prefix substitution is broken - ftre = /(#{ft.keys.join('|')})/ - n.gsub(ftre, ft) + ftre = /(#{@ft.keys.join('|')})/ + n.gsub(ftre, @ft) end # Return single item if array is full of duplicates