musicfix 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README +13 -8
  3. data/bin/musicfix +58 -22
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e6161997b72e0c71c437d4b84534a4c3ae0ad66
4
- data.tar.gz: c5dfe3555ee3ba7d9350d0dfb85e4d9fc965e6ea
3
+ metadata.gz: 4f5c80d51297e9111600c9203d0623943d250d8b
4
+ data.tar.gz: 8ddb775d3aa6f2a3c83497a3b9aa159bb47d708f
5
5
  SHA512:
6
- metadata.gz: 90d4d7d82ad86c294ac6253a20cf612b425bbb6050a4fcb2d965ec4f093a1f816c42a5d68dae2f7334cdea8062837a21d57f4f1b122507095a1a26d6a7d0a9ac
7
- data.tar.gz: 039b2873127b44bc800b9a0c1b29c93ba8785c883feb9ef9b945659ba55c47334372e6ec841b57659f44c5fa5791d49a1560f3cec89488fe74a76f5325072d70
6
+ metadata.gz: 7cac8a4e9c952c4301c111bb650f40f73c7a645af434bba9969a11fde6d007c83098002293e9e0df70a106e9cf6c0352dfbc0632c02ecb9ecf42e02bbf262885
7
+ data.tar.gz: 3e761cb2de179b64a7456db4c0d3a8dfcc19a343db7bff57815e492808111e280ecc936bf8f8290cf91ac998af3a40a004bb67da6289b4108cc119d2a0694893
data/README CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: README,v 1.11 2013/02/02 09:44:52 lostd Exp $
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 second command line argument of the form:
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
- The simplest `~/.musicfixrc` configuration file only contains:
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:
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- # $Id: musicfix,v 1.30 2013/06/13 23:09:01 lostd Exp $
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'] = '/var/music'
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.name
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
- File.open(relfile, 'w') do |f|
195
- f.puts rel.to_yaml
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
- FileUtils.makedirs(File.dirname nfname)
249
- FileUtils.copy(ofname, nfname)
250
- TagLib::FileRef.open(nfname) do |f|
251
- f.tag.artist = a
252
- f.tag.album = b
253
- f.tag.title = t
254
- f.tag.track = tn
255
- f.tag.year = y.to_i
256
- f.tag.genre = g
257
- f.tag.comment = c
258
- f.save
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
- img = open(rel['imgurl'], {"User-Agent" => "Mozilla"}).read
268
- File.open(imgname, 'wb').write img
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.2
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-06-15 00:00:00.000000000 Z
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.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