taffy 1.1.2 → 1.2.0
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.md +43 -35
- data/bin/taffy +50 -12
- data/taffy.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b285af0466eca45d0e54a7b679e98603a260e13
|
4
|
+
data.tar.gz: c04e0465d601f3f6e077cc4cceffded7817ac745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 660e523484ccd5d24db1adb78da2876379b55e9b9e82d2db11d29b4d874d87c031cb7267ed71c7ef6e2fe903e7c2a47832f8d6eca3f60b7a3ff05ce7f4c5aeb2
|
7
|
+
data.tar.gz: debe7f81f2e4235f33b0f345be2bf2228ab94530f42f80ae5952fb077461d43a91a7f259548db58e0ec5d100038d3090b70a61c9767a8678b8f360a8c14419a8
|
data/README.md
CHANGED
@@ -2,48 +2,56 @@ Taffy
|
|
2
2
|
=====
|
3
3
|
Taffy is a command-line tool for reading and writing audio metadata, as
|
4
4
|
supported by [TagLib](http://taglib.github.io/). That means it can edit
|
5
|
-
tags for MP3, Ogg Vorbis, FLAC, WAV, and MP4 files, along with
|
6
|
-
other file formats
|
5
|
+
tags for MP3, Ogg Vorbis, FLAC, WAV, and MP4 files, along with several
|
6
|
+
other file formats.
|
7
7
|
|
8
8
|
Installation
|
9
9
|
------------
|
10
|
+
If installing via `gem`, you must have already installed your
|
11
|
+
distribution's TagLib package, usually called `taglib`, `taglib-devel`,
|
12
|
+
or `libtag1-dev`. Then run:
|
13
|
+
|
10
14
|
gem install taffy
|
11
15
|
|
16
|
+
If you use Arch Linux or a derivative, you may also install via the [AUR
|
17
|
+
package](https://aur.archlinux.org/packages/taffy/).
|
18
|
+
|
12
19
|
Usage
|
13
20
|
-----
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
21
|
+
Usage: taffy [options] file ...
|
22
|
+
|
23
|
+
Tag options:
|
24
|
+
-l, --album ALBUM Set album tag
|
25
|
+
-r, --artist ARTIST Set artist tag
|
26
|
+
-c, --comment COMMENT Set comment tag
|
27
|
+
-g, --genre GENRE Set genre tag
|
28
|
+
-t, --title TITLE Set title tag
|
29
|
+
-n, --track TRACK Set track tag
|
30
|
+
-y, --year YEAR Set year tag
|
31
|
+
--no-album Clear album tag
|
32
|
+
--no-artist Clear artist tag
|
33
|
+
--no-comment Clear comment tag
|
34
|
+
--no-genre Clear genre tag
|
35
|
+
--no-title Clear title tag
|
36
|
+
--no-track Clear track tag
|
37
|
+
--no-year Clear year tag
|
38
|
+
--clear Clear all tags
|
39
|
+
|
40
|
+
Filename options:
|
41
|
+
--extract SPEC Extract tags from filename
|
42
|
+
--rename SPEC Rename file based on tags
|
43
|
+
|
44
|
+
If no options are given, file tags are printed instead.
|
45
|
+
|
46
|
+
In a filename spec, a sequence such as %R or %r stands for
|
47
|
+
the corresponding tag, in this case the artist name. In a
|
48
|
+
filename, %R leaves letter case intact, while %r downcases
|
49
|
+
the tag. A sequence such as %_t maps special characters in
|
50
|
+
the tag to the given substitute, in this case an underscore.
|
51
|
+
|
52
|
+
Other options:
|
53
|
+
-h, --help Show this message and exit
|
54
|
+
--version Show version and exit
|
47
55
|
|
48
56
|
Examples
|
49
57
|
--------
|
data/bin/taffy
CHANGED
@@ -5,7 +5,7 @@ require 'shellwords'
|
|
5
5
|
|
6
6
|
require 'taglib'
|
7
7
|
|
8
|
-
VERSION = [1,
|
8
|
+
VERSION = [1, 2, 0]
|
9
9
|
|
10
10
|
FIELDS = [
|
11
11
|
['l', 'album', String],
|
@@ -18,8 +18,8 @@ FIELDS = [
|
|
18
18
|
]
|
19
19
|
|
20
20
|
actions = []
|
21
|
-
rename_spec = nil
|
22
|
-
status = 0
|
21
|
+
extract_spec = rename_spec = nil
|
22
|
+
$status = 0
|
23
23
|
|
24
24
|
options = OptionParser.new do |opts|
|
25
25
|
opts.banner += " file ..."
|
@@ -49,6 +49,9 @@ options = OptionParser.new do |opts|
|
|
49
49
|
opts.separator ""
|
50
50
|
opts.separator "Filename options:"
|
51
51
|
|
52
|
+
opts.on("--extract SPEC", String, "Extract tags from filename") do |spec|
|
53
|
+
extract_spec = spec
|
54
|
+
end
|
52
55
|
opts.on("--rename SPEC", String, "Rename file based on tags") do |spec|
|
53
56
|
rename_spec = spec
|
54
57
|
end
|
@@ -57,10 +60,10 @@ options = OptionParser.new do |opts|
|
|
57
60
|
opts.separator "If no options are given, file tags are printed instead."
|
58
61
|
opts.separator ""
|
59
62
|
opts.separator "In a filename spec, a sequence such as %R or %r stands for"
|
60
|
-
opts.separator "the corresponding tag, in this case the artist name.
|
61
|
-
opts.separator "leaves letter case intact, while %r downcases
|
62
|
-
opts.separator "sequence such as %_t maps special characters in
|
63
|
-
opts.separator "to the given substitute, in this case an underscore."
|
63
|
+
opts.separator "the corresponding tag, in this case the artist name. In a"
|
64
|
+
opts.separator "filename, %R leaves letter case intact, while %r downcases"
|
65
|
+
opts.separator "the tag. A sequence such as %_t maps special characters in"
|
66
|
+
opts.separator "the tag to the given substitute, in this case an underscore."
|
64
67
|
opts.separator ""
|
65
68
|
opts.separator "Other options:"
|
66
69
|
|
@@ -98,6 +101,30 @@ def print_info(filename, tag)
|
|
98
101
|
puts
|
99
102
|
end
|
100
103
|
|
104
|
+
def extract(tag, spec, filename)
|
105
|
+
name = File.basename(filename)
|
106
|
+
name = name.slice(0, name.size - File.extname(name).size)
|
107
|
+
regexp = Regexp.new(spec.gsub(/%(\W|_)?([lrcgt])/, '(.+)').
|
108
|
+
gsub(/%(\W|_)?([ny])/, '(\d+)'))
|
109
|
+
if filematch = regexp.match(name)
|
110
|
+
i = 1
|
111
|
+
loop do
|
112
|
+
specmatch = /%(?:\W|_)?([lrcgtny])/.match(spec)
|
113
|
+
break unless specmatch
|
114
|
+
FIELDS.each do |f|
|
115
|
+
next if f[0] != specmatch[1]
|
116
|
+
val = 'ny'.include?(f[0]) ? filematch[i].to_i : filematch[i]
|
117
|
+
tag.send("#{f[1]}=", val)
|
118
|
+
end
|
119
|
+
spec = specmatch.post_match
|
120
|
+
i += 1
|
121
|
+
end
|
122
|
+
else
|
123
|
+
warn("#{filename} did not match extraction spec")
|
124
|
+
$status = 2
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
101
128
|
def rename(tag, spec)
|
102
129
|
spec = spec.dup
|
103
130
|
|
@@ -117,22 +144,33 @@ ARGV.each do |filename|
|
|
117
144
|
TagLib::FileRef.open(filename) do |fileref|
|
118
145
|
if fileref.null?
|
119
146
|
warn("Could not open file: #{filename}")
|
120
|
-
status = 2
|
147
|
+
$status = 2
|
121
148
|
next
|
122
149
|
end
|
123
150
|
|
124
|
-
if
|
151
|
+
if extract_spec
|
152
|
+
extract(fileref.tag, extract_spec, filename)
|
153
|
+
fileref.save
|
154
|
+
end
|
155
|
+
|
156
|
+
if actions.empty? and !(extract_spec or rename_spec)
|
125
157
|
print_info(filename, fileref.tag)
|
126
|
-
|
158
|
+
elsif !actions.empty?
|
127
159
|
actions.each { |action| action.call(fileref.tag) }
|
128
160
|
fileref.save
|
129
161
|
end
|
130
162
|
|
131
163
|
if rename_spec
|
132
164
|
name = rename(fileref.tag, rename_spec) + File.extname(filename)
|
133
|
-
|
165
|
+
path = File.join(File.dirname(filename), name)
|
166
|
+
if File.exist?(path)
|
167
|
+
warn("Cannot rename; file exists: #{name}")
|
168
|
+
$status = 2
|
169
|
+
else
|
170
|
+
File.rename(filename, path)
|
171
|
+
end
|
134
172
|
end
|
135
173
|
end
|
136
174
|
end
|
137
175
|
|
138
|
-
exit(status)
|
176
|
+
exit($status)
|
data/taffy.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'taffy'
|
3
|
-
s.version = '1.
|
4
|
-
s.date = '2015-04-
|
3
|
+
s.version = '1.2.0'
|
4
|
+
s.date = '2015-04-29'
|
5
5
|
s.summary = 'A command-line audio tagging tool'
|
6
6
|
s.description = "A command-line tool for reading and writing audio \
|
7
7
|
metadata.".squeeze(' ')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taffy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mulcahy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|