musicfix 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +13 -8
- data/bin/musicfix +58 -22
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f5c80d51297e9111600c9203d0623943d250d8b
|
|
4
|
+
data.tar.gz: 8ddb775d3aa6f2a3c83497a3b9aa159bb47d708f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cac8a4e9c952c4301c111bb650f40f73c7a645af434bba9969a11fde6d007c83098002293e9e0df70a106e9cf6c0352dfbc0632c02ecb9ecf42e02bbf262885
|
|
7
|
+
data.tar.gz: 3e761cb2de179b64a7456db4c0d3a8dfcc19a343db7bff57815e492808111e280ecc936bf8f8290cf91ac998af3a40a004bb67da6289b4108cc119d2a0694893
|
data/README
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# $Id: README,v 1.
|
|
1
|
+
# $Id: README,v 1.13 2013/06/27 15:30:07 lostd Exp $
|
|
2
2
|
|
|
3
3
|
# Description
|
|
4
4
|
|
|
@@ -18,12 +18,12 @@ to the program. Enjoy!
|
|
|
18
18
|
|
|
19
19
|
# Usage
|
|
20
20
|
|
|
21
|
-
$ musicfix relid [tracks]
|
|
22
|
-
$ musicfix dump relid [relfile]
|
|
23
|
-
$ musicfix load [relfile]
|
|
21
|
+
$ musicfix [fake] relid [tracks]
|
|
22
|
+
$ musicfix [fake] dump relid [relfile]
|
|
23
|
+
$ musicfix [fake] load [relfile]
|
|
24
24
|
|
|
25
25
|
More sophisticated track selection can be performed by providing
|
|
26
|
-
a
|
|
26
|
+
a tracks selector command line argument of the form:
|
|
27
27
|
|
|
28
28
|
"1--3,5,8"
|
|
29
29
|
"A2--A4,B3"
|
|
@@ -32,14 +32,19 @@ a second command line argument of the form:
|
|
|
32
32
|
Alternatively, YAML metadata files can be used (`release.yaml` by default)
|
|
33
33
|
in order to dump information from Discogs.com and/or load the information
|
|
34
34
|
from file. This way you can generate a base release file, edit to
|
|
35
|
-
your needs, and then use it for tagging and renaming.
|
|
35
|
+
your needs, and then use it for tagging and renaming. The fake prefix
|
|
36
|
+
on all commands results in no files to be copied/written and no cover
|
|
37
|
+
artwork to be downloaded.
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
# Configuration
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
In the simplest case no configuration is needed! The music files are
|
|
43
|
+
copied to the ~/music directory, which is created if needed. If you
|
|
44
|
+
want to change that, create a `~/.musicfixrc` configuration file
|
|
45
|
+
containing:
|
|
41
46
|
|
|
42
|
-
mdir: ~/music
|
|
47
|
+
mdir: ~/music/fixed
|
|
43
48
|
|
|
44
49
|
Furthermore, templates are used for the naming of music files
|
|
45
50
|
and the cover artwork image. The defaults are:
|
data/bin/musicfix
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# encoding: utf-8
|
|
3
3
|
|
|
4
|
-
# $Id: musicfix,v 1.
|
|
4
|
+
# $Id: musicfix,v 1.39 2013/08/06 10:42:41 lostd Exp $
|
|
5
5
|
|
|
6
6
|
require 'rubygems'
|
|
7
7
|
require 'fileutils'
|
|
@@ -48,7 +48,9 @@ syms = {"≠" => "not equals"}
|
|
|
48
48
|
Stringex::Localization.store_translations :en, :transliterations, syms
|
|
49
49
|
|
|
50
50
|
# Convert to lowercase ASCII without punctuation
|
|
51
|
+
# Convert "Jean-Michel Jarre" to "jean_michel_jarre"
|
|
51
52
|
def mkname n
|
|
53
|
+
# These may be in track titles like "(7'' Version)"
|
|
52
54
|
n = n.gsub '12"', '12 inch'
|
|
53
55
|
n = n.gsub "12''", "12 inch"
|
|
54
56
|
n = n.gsub "12'", "12 inch"
|
|
@@ -56,6 +58,7 @@ def mkname n
|
|
|
56
58
|
n = n.gsub "7''", "7 inch"
|
|
57
59
|
n = n.gsub "7'", "7 inch"
|
|
58
60
|
n = n.gsub " & ", " and "
|
|
61
|
+
# Transliterate
|
|
59
62
|
n.to_url.gsub '-', '_'
|
|
60
63
|
end
|
|
61
64
|
|
|
@@ -87,11 +90,38 @@ def mkposlist tracks
|
|
|
87
90
|
pl.flatten
|
|
88
91
|
end
|
|
89
92
|
|
|
93
|
+
# Make a sane format string also using format description
|
|
94
|
+
def mkformat format
|
|
95
|
+
if format.descriptions
|
|
96
|
+
"#{format.descriptions.first} #{format.name}"
|
|
97
|
+
else
|
|
98
|
+
"#{format.name}"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Shorten certain common words that appear in format strings
|
|
103
|
+
def mkshort n
|
|
104
|
+
n = n.gsub "Album CD", "CD"
|
|
105
|
+
n = n.gsub "LP Vinyl", "LP"
|
|
106
|
+
n = n.gsub "EP Vinyl", "EP"
|
|
107
|
+
n = n.gsub "Mini-Album Vinyl", "MiniLP"
|
|
108
|
+
n = n.gsub '12" Vinyl', '12inch'
|
|
109
|
+
n = n.gsub '7" Vinyl', '7inch'
|
|
110
|
+
n = n.gsub "Cassette", "Cass"
|
|
111
|
+
n = n.gsub "Limited Edition", "Ltd"
|
|
112
|
+
n = n.gsub "Compilation", "Comp"
|
|
113
|
+
n = n.gsub "Reissue", "RE"
|
|
114
|
+
n = n.gsub "Enhanced", "Enh"
|
|
115
|
+
n = n.gsub "Unofficial Release", "Unofficial"
|
|
116
|
+
end
|
|
117
|
+
|
|
90
118
|
# Parse command line
|
|
91
119
|
usage = ''
|
|
92
|
-
usage << "Usage: musicfix relid [tracks]\n"
|
|
93
|
-
usage << " musicfix dump relid [relfile]\n"
|
|
94
|
-
usage << " musicfix load [relfile]\n"
|
|
120
|
+
usage << "Usage: musicfix [fake] relid [tracks]\n"
|
|
121
|
+
usage << " musicfix [fake] dump relid [relfile]\n"
|
|
122
|
+
usage << " musicfix [fake] load [relfile]\n"
|
|
123
|
+
fake = ARGV[0] == 'fake'
|
|
124
|
+
ARGV.delete 'fake'
|
|
95
125
|
cmd = ARGV[0] || (puts usage; exit)
|
|
96
126
|
case cmd
|
|
97
127
|
when 'load' then
|
|
@@ -106,7 +136,7 @@ end
|
|
|
106
136
|
|
|
107
137
|
# Default configuration
|
|
108
138
|
cfg = {}
|
|
109
|
-
cfg['mdir'] = '
|
|
139
|
+
cfg['mdir'] = '~/music'
|
|
110
140
|
cfg['track'] = '"#{mdir}/#{fba}-#{my}-#{fb}-#{fv}/#{d}#{fn}-#{fa}-#{ft}.#{x}"'
|
|
111
141
|
cfg['image'] = '"#{mdir}/#{fba}-#{my}-#{fb}-#{fv}/#{zz}-#{fba}-#{fb}_cover.jpg"'
|
|
112
142
|
#cfg['after'] = '"mpc update #{fba}-#{my}-#{fb}-#{fv}"'
|
|
@@ -174,7 +204,7 @@ else
|
|
|
174
204
|
rel['masteryear'] = rel['masteryear'].slice(0..3)
|
|
175
205
|
rel['genre'] = if r.styles then r.styles.first end ||
|
|
176
206
|
if r.genres then r.genres.first end
|
|
177
|
-
rel['format'] = r.formats.first
|
|
207
|
+
rel['format'] = mkformat r.formats.first
|
|
178
208
|
rel['comment'] = "Discogs: #{r.id}"
|
|
179
209
|
rel['imgurl'] = getimgurl r
|
|
180
210
|
rel['tracklist'] = []
|
|
@@ -191,8 +221,10 @@ end
|
|
|
191
221
|
# Output release info
|
|
192
222
|
puts rel.to_yaml
|
|
193
223
|
if cmd == 'dump' then
|
|
194
|
-
|
|
195
|
-
|
|
224
|
+
unless fake
|
|
225
|
+
File.open(relfile, 'w') do |f|
|
|
226
|
+
f.puts rel.to_yaml
|
|
227
|
+
end
|
|
196
228
|
end
|
|
197
229
|
exit
|
|
198
230
|
end
|
|
@@ -208,7 +240,7 @@ v = rel['format']
|
|
|
208
240
|
c = rel['comment']
|
|
209
241
|
fba = mkname ba
|
|
210
242
|
fb = mkname b
|
|
211
|
-
fv = mkname v
|
|
243
|
+
fv = mkname (mkshort v)
|
|
212
244
|
# Internal use only
|
|
213
245
|
tl = rel['tracklist']
|
|
214
246
|
|
|
@@ -245,17 +277,19 @@ fl.each do |ofname|
|
|
|
245
277
|
x = File.extname(ofname).delete('.').downcase
|
|
246
278
|
nfname = eval cfg['track']
|
|
247
279
|
puts "Copy track to #{nfname}"
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
280
|
+
unless fake
|
|
281
|
+
FileUtils.makedirs(File.dirname nfname)
|
|
282
|
+
FileUtils.copy(ofname, nfname)
|
|
283
|
+
TagLib::FileRef.open(nfname) do |f|
|
|
284
|
+
f.tag.artist = a
|
|
285
|
+
f.tag.album = b
|
|
286
|
+
f.tag.title = t
|
|
287
|
+
f.tag.track = tn
|
|
288
|
+
f.tag.year = y.to_i
|
|
289
|
+
f.tag.genre = g
|
|
290
|
+
f.tag.comment = c
|
|
291
|
+
f.save
|
|
292
|
+
end
|
|
259
293
|
end
|
|
260
294
|
end
|
|
261
295
|
|
|
@@ -264,8 +298,10 @@ zz = '0' * (mkdiscnum tl.last['pos'].to_s).join.length
|
|
|
264
298
|
imgname = eval cfg['image']
|
|
265
299
|
if rel['imgurl'] then
|
|
266
300
|
puts "Save cover to #{imgname}"
|
|
267
|
-
|
|
268
|
-
|
|
301
|
+
unless fake
|
|
302
|
+
img = open(rel['imgurl'], {"User-Agent" => "Mozilla 5.0"}).read
|
|
303
|
+
File.open(imgname, 'wb').write img
|
|
304
|
+
end
|
|
269
305
|
end
|
|
270
306
|
|
|
271
307
|
# Execute command if provided
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: musicfix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lazaros Koromilas
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-
|
|
11
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: discogs-wrapper
|
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
83
83
|
version: '0'
|
|
84
84
|
requirements: []
|
|
85
85
|
rubyforge_project:
|
|
86
|
-
rubygems_version: 2.0.
|
|
86
|
+
rubygems_version: 2.0.3
|
|
87
87
|
signing_key:
|
|
88
88
|
specification_version: 4
|
|
89
89
|
summary: Music file renamer and tagger that uses Discogs.com
|