musicfix 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README +0 -2
- data/bin/musicfix +51 -27
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12ba6b8750f8ba21d9d439843de08a22a590ff65
|
4
|
+
data.tar.gz: ef0cf64ea385518284eab1dfc85a0d77f43b5367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86728467e24e4099e13b080d8f3127151939c53bcf234d05e334c195f69f4849c86c4b4c676d99ff72088330acea8e7946575c1f051fd6db3c9fe49938441676
|
7
|
+
data.tar.gz: 3d17efef7167e023755bb0d1a87a4545eaa01602bee11ad59531382a11619c5ac2e69dd739d915047a7f029d3a3e5dd129ddee79b8293e6df57878d56a1605cb
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.1.7
|
2
|
+
* Fix http requests to work with the current API.
|
3
|
+
* All stdout output is valid YAML.
|
4
|
+
* Sort tracklist of output release file in filename order.
|
5
|
+
* Get artwork from the s.pixogs.com domain.
|
6
|
+
|
1
7
|
## 0.1.6
|
2
8
|
* Can now generate release files from audio file tags.
|
3
9
|
* Add the release metadata saving functionality and loading logic.
|
data/README
CHANGED
data/bin/musicfix
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
-
# $Id: musicfix,v 1.60 2014/01/12 17:40:11 lostd Exp $
|
5
|
-
|
6
4
|
require 'rubygems'
|
7
5
|
require 'fileutils'
|
8
6
|
require 'open-uri'
|
@@ -11,7 +9,7 @@ require 'taglib'
|
|
11
9
|
require 'yaml'
|
12
10
|
|
13
11
|
# Headers
|
14
|
-
Ver = '0.1.
|
12
|
+
Ver = '0.1.7'
|
15
13
|
Homepage = 'http://git.2f30.org/musicfix/'
|
16
14
|
Headers = {'User-Agent' => "musicfix/#{Ver} +#{Homepage}"}
|
17
15
|
|
@@ -60,6 +58,9 @@ def mkname n
|
|
60
58
|
n = n.gsub '12"', '12 inch'
|
61
59
|
n = n.gsub "12''", "12 inch"
|
62
60
|
n = n.gsub "12'", "12 inch"
|
61
|
+
n = n.gsub '10"', '10 inch'
|
62
|
+
n = n.gsub "10''", "10 inch"
|
63
|
+
n = n.gsub "10'", "10 inch"
|
63
64
|
n = n.gsub '7"', '7 inch'
|
64
65
|
n = n.gsub "7''", "7 inch"
|
65
66
|
n = n.gsub "7'", "7 inch"
|
@@ -73,7 +74,8 @@ def getimgurl rel
|
|
73
74
|
return nil unless rel['images']
|
74
75
|
img = rel['images'].select {|i| i['type'] == 'primary'}.first ||
|
75
76
|
rel['images'].first
|
76
|
-
img['uri']
|
77
|
+
img['uri'].gsub! 'api.discogs.com/images/R-90', 's.pixogs.com/image/R'
|
78
|
+
img['uri'].gsub! 'api.discogs.com/images/', 's.pixogs.com/image/'
|
77
79
|
end
|
78
80
|
|
79
81
|
# Construct position list from tracks filter
|
@@ -99,7 +101,7 @@ end
|
|
99
101
|
# Make a sane format string also using format description
|
100
102
|
def mkformat format
|
101
103
|
f = []
|
102
|
-
# Ignore in favor of LP/EP/7"/12" descriptions
|
104
|
+
# Ignore in favor of LP/EP/7"/10"/12" descriptions
|
103
105
|
unless format['name'] == "Vinyl"
|
104
106
|
f << format['name']
|
105
107
|
end
|
@@ -118,6 +120,7 @@ def mkshort n
|
|
118
120
|
ft = {
|
119
121
|
'Cassette' => 'Cass',
|
120
122
|
'12"' => '12inch',
|
123
|
+
'10"' => '10inch',
|
121
124
|
'7"' => '7inch',
|
122
125
|
'Mini-Album' => 'MiniAlbum',
|
123
126
|
'Maxi-Single' => 'Maxi',
|
@@ -139,6 +142,9 @@ def mkshort n
|
|
139
142
|
'Numbered' => 'Num',
|
140
143
|
'Unofficial Release' => 'Unofficial',
|
141
144
|
'Single Sided' => 'S/Sided',
|
145
|
+
'File MP3' => 'MP3',
|
146
|
+
'File FLAC' => 'FLAC',
|
147
|
+
'File WAV' => 'WAV',
|
142
148
|
}
|
143
149
|
# Note that prefix substitution is broken
|
144
150
|
ftre = /(#{ft.keys.join('|')})/
|
@@ -195,13 +201,13 @@ end
|
|
195
201
|
cfg['mdir'] = File.expand_path cfg['mdir']
|
196
202
|
|
197
203
|
# Print configuration
|
198
|
-
puts 'Configuration'
|
204
|
+
puts '# Configuration'
|
199
205
|
puts cfg.to_yaml
|
200
206
|
|
201
207
|
# Early file checks
|
202
208
|
if cmd == 'dump' or cmd == 'tags' then
|
203
209
|
if File.exists? relfile then
|
204
|
-
puts "Release file #{relfile} exists!"
|
210
|
+
STDERR.puts "Release file #{relfile} exists!"
|
205
211
|
exit
|
206
212
|
end
|
207
213
|
end
|
@@ -212,11 +218,11 @@ unless cmd == 'dump' then
|
|
212
218
|
# Construct file list
|
213
219
|
fl = Dir['*'].select {|f| File.extname(f).match fmtre}.sort
|
214
220
|
if fl.empty? then
|
215
|
-
puts 'No music files found!'
|
216
|
-
exit
|
221
|
+
STDERR.puts 'No music files found!'
|
222
|
+
exit 1
|
217
223
|
end
|
218
224
|
# Output file list
|
219
|
-
puts 'Files to process'
|
225
|
+
puts '# Files to process'
|
220
226
|
puts fl.to_yaml
|
221
227
|
end
|
222
228
|
|
@@ -226,8 +232,8 @@ if cmd == 'load' then
|
|
226
232
|
if relfile then
|
227
233
|
# The user specified some file
|
228
234
|
unless File.exists? relfile then
|
229
|
-
puts "Release file #{relfile} not found!"
|
230
|
-
exit
|
235
|
+
STDERR.puts "Release file #{relfile} not found!"
|
236
|
+
exit 1
|
231
237
|
end
|
232
238
|
else
|
233
239
|
# Look for 'release.yaml' first
|
@@ -239,14 +245,15 @@ if cmd == 'load' then
|
|
239
245
|
relfile = relfl.sort.first
|
240
246
|
end
|
241
247
|
unless relfile then
|
242
|
-
puts 'No release file found!'
|
243
|
-
exit
|
248
|
+
STDERR.puts 'No release file found!'
|
249
|
+
exit 1
|
244
250
|
end
|
245
251
|
end
|
246
|
-
puts "Loading release data..."
|
252
|
+
STDERR.puts "Loading release data from file..."
|
247
253
|
rel = YAML.load File.open(relfile, 'r')
|
248
254
|
elsif cmd == 'tags' then
|
249
255
|
# Generate release file from audio file tags
|
256
|
+
STDERR.puts "Generating release data from tags..."
|
250
257
|
rel = {}
|
251
258
|
rel['artist'] = []
|
252
259
|
rel['album'] = []
|
@@ -292,20 +299,27 @@ elsif cmd == 'tags' then
|
|
292
299
|
rel['format'] = 'CD'
|
293
300
|
else
|
294
301
|
# Get release data from Discogs
|
295
|
-
puts "Getting release data..."
|
296
|
-
r = YAML.load(open("http://api.discogs.com/
|
297
|
-
Headers))
|
302
|
+
STDERR.puts "Getting release data from Discogs..."
|
303
|
+
r = YAML.load(open("http://api.discogs.com/releases/#{relid}",
|
304
|
+
Headers))
|
298
305
|
mr = if r['master_id'] then
|
299
|
-
YAML.load(open("http://api.discogs.com/
|
300
|
-
Headers))
|
306
|
+
YAML.load(open("http://api.discogs.com/masters/#{r['master_id']}",
|
307
|
+
Headers))
|
301
308
|
end
|
302
309
|
# Tracklist can contain dummy header tracks, strip them
|
303
310
|
tl = r['tracklist'].select {|t| t['position'] != ''}
|
304
311
|
# Apply tracks filter if given
|
305
312
|
if tracks then
|
306
313
|
pl = mkposlist tracks
|
307
|
-
|
314
|
+
unless pl
|
315
|
+
STDERR.puts "Invalid tracks filter: #{tracks}"
|
316
|
+
exit 1
|
317
|
+
end
|
308
318
|
tl = tl.select {|t| pl.include? t['position']}
|
319
|
+
if tl.empty?
|
320
|
+
STDERR.puts "Filter returned no tracks: #{tracks}"
|
321
|
+
exit 1
|
322
|
+
end
|
309
323
|
end
|
310
324
|
# Gather release-wide data
|
311
325
|
rel = {}
|
@@ -320,6 +334,9 @@ else
|
|
320
334
|
if r['genres'] then r['genres'].first end
|
321
335
|
rel['format'] = mkformat r['formats'].first
|
322
336
|
rel['comment'] = "Discogs: #{r['id']}"
|
337
|
+
if tracks then
|
338
|
+
rel['comment'] += ", tracks: #{tracks}"
|
339
|
+
end
|
323
340
|
rel['imgurl'] = getimgurl r
|
324
341
|
rel['tracklist'] = []
|
325
342
|
# Populate tracklist
|
@@ -333,8 +350,10 @@ else
|
|
333
350
|
end
|
334
351
|
|
335
352
|
# Output release info
|
353
|
+
puts '# Release data'
|
336
354
|
puts rel.to_yaml
|
337
355
|
if cmd == 'dump' or cmd == 'tags' then
|
356
|
+
STDERR.puts "Save rdata to #{relfile}"
|
338
357
|
unless fake
|
339
358
|
File.open(relfile, 'w') do |f|
|
340
359
|
f.puts rel.to_yaml
|
@@ -390,7 +409,9 @@ fl.each do |ofname|
|
|
390
409
|
fn = mkname n
|
391
410
|
x = File.extname(ofname).delete('.').downcase
|
392
411
|
nfname = eval cfg['track']
|
393
|
-
|
412
|
+
# Add filename to track descriptor
|
413
|
+
trk['file'] = nfname
|
414
|
+
STDERR.puts "Copy track to #{nfname}"
|
394
415
|
unless fake
|
395
416
|
FileUtils.makedirs(File.dirname nfname)
|
396
417
|
FileUtils.copy(ofname, nfname)
|
@@ -411,7 +432,7 @@ end
|
|
411
432
|
zz = '0' * (mkdiscnum tl.last['pos'].to_s).join.length
|
412
433
|
imgname = eval cfg['image']
|
413
434
|
if rel['imgurl'] then
|
414
|
-
puts "Save image to #{imgname}"
|
435
|
+
STDERR.puts "Save image to #{imgname}"
|
415
436
|
unless fake
|
416
437
|
img = open(rel['imgurl'], Headers).read
|
417
438
|
File.open(imgname, 'wb').write img
|
@@ -419,8 +440,11 @@ if rel['imgurl'] then
|
|
419
440
|
end
|
420
441
|
# Also save the release file for future use
|
421
442
|
relfile = eval cfg['rdata']
|
422
|
-
puts "Save rdata to #{relfile}"
|
443
|
+
STDERR.puts "Save rdata to #{relfile}"
|
423
444
|
unless fake
|
445
|
+
# Sort tracklist in filename order and delete filenames
|
446
|
+
rel['tracklist'].sort_by! {|s| s['file']}
|
447
|
+
rel['tracklist'].each {|s| s.delete 'file'}
|
424
448
|
File.open(relfile, 'w') do |f|
|
425
449
|
f.puts rel.to_yaml
|
426
450
|
end
|
@@ -428,10 +452,10 @@ end
|
|
428
452
|
|
429
453
|
# Execute command if provided
|
430
454
|
if cfg['after'] then
|
431
|
-
|
455
|
+
run = eval cfg['after']
|
456
|
+
STDERR.puts "Executing #{run}"
|
432
457
|
unless fake
|
433
|
-
run
|
434
|
-
`#{run}`
|
458
|
+
puts `#{run}`
|
435
459
|
end
|
436
460
|
end
|
437
461
|
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lazaros Koromilas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01
|
11
|
+
date: 2014-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stringex
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: taglib-ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Musicfix is a music file renamer and tagger with consistency concerns.
|
@@ -46,10 +46,10 @@ executables:
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- bin/musicfix
|
50
|
-
- README
|
51
|
-
- LICENSE
|
52
49
|
- CHANGELOG
|
50
|
+
- LICENSE
|
51
|
+
- README
|
52
|
+
- bin/musicfix
|
53
53
|
homepage: http://git.2f30.org/musicfix/
|
54
54
|
licenses:
|
55
55
|
- BSD
|
@@ -60,17 +60,17 @@ require_paths:
|
|
60
60
|
- lib
|
61
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.
|
73
|
+
rubygems_version: 2.2.2
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Music file renamer and tagger that uses Discogs.com
|