musicfix

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

commit 5e18c9451d1210be1e582e1aa0e2fc8552445e17
parent 05f6f9163ada978592443d1450e7d9a4b900a909
Author: lostd <lostd@2f30.org>
Date:   Thu, 27 Jun 2013 14:29:20 +0000

Short but descriptive release format strings

Diffstat:
Mbin/musicfix | 27+++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/bin/musicfix b/bin/musicfix @@ -49,6 +49,7 @@ Stringex::Localization.store_translations :en, :transliterations, syms # Convert to lowercase ASCII without punctuation def mkname n + # These may be in track titles like "(7'' Version)" n = n.gsub '12"', '12 inch' n = n.gsub "12''", "12 inch" n = n.gsub "12'", "12 inch" @@ -56,6 +57,7 @@ def mkname n n = n.gsub "7''", "7 inch" n = n.gsub "7'", "7 inch" n = n.gsub " & ", " and " + # Transliterate n.to_url.gsub '-', '_' end @@ -87,6 +89,27 @@ def mkposlist tracks pl.flatten end +# Make a sane format string also using format description +def mkformat format + if format.descriptions + "#{format.descriptions.first} #{format.name}" + else + "#{format.name}" + end +end + +# Shorten certain common words that appear in format strings +def mkshort n + n = n.gsub "Album CD", "CD" + n = n.gsub "LP Vinyl", "LP" + n = n.gsub "EP Vinyl", "EP" + n = n.gsub '12" Vinyl', '12inch' + n = n.gsub '7" Vinyl', '7inch' + n = n.gsub "Cassette", "Cass" + n = n.gsub "Limited Edition", "Ltd" + n = n.gsub "Compilation", "Comp" +end + # Parse command line usage = '' usage << "Usage: musicfix relid [tracks]\n" @@ -174,7 +197,7 @@ else rel['masteryear'] = rel['masteryear'].slice(0..3) rel['genre'] = if r.styles then r.styles.first end || if r.genres then r.genres.first end - rel['format'] = r.formats.first.name + rel['format'] = mkformat r.formats.first rel['comment'] = "Discogs: #{r.id}" rel['imgurl'] = getimgurl r rel['tracklist'] = [] @@ -208,7 +231,7 @@ v = rel['format'] c = rel['comment'] fba = mkname ba fb = mkname b -fv = mkname v +fv = mkname (mkshort v) # Internal use only tl = rel['tracklist']