taffy 1.3.2 → 1.4.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/.gitignore +1 -0
- data/LICENSE +1 -1
- data/README.md +5 -1
- data/bin/taffy +24 -6
- data/taffy.gemspec +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c59b3b99ae79f14bb9562aa46f0a47521e4c63e8d6c399131d9e915705aa4c
|
4
|
+
data.tar.gz: d34948bbe7c36a177eff310b65aca989c4f5e7432fcbe5c860173a8a4b226d06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57200fdecd3b1fa98036c0ed20646e4ec9127faff5483bd4e68e984c78de1ba1cb0e852167ead1dc53532b6a670cc54c0121e8d4bbaae3bf69d5bec9139e168b
|
7
|
+
data.tar.gz: ecac7926ac03bfd179b7a243836dea1eab14cd2860c2ed5132509fd826bc38beb5e1c3d422fe032306a6f1aaa67448c83fbc83892084de9b8b0066ef6e1ba1aa
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,7 @@ Usage
|
|
40
40
|
Filename options:
|
41
41
|
--extract SPEC Extract tags from filename
|
42
42
|
--rename SPEC Rename file based on tags
|
43
|
+
--rename-fs SPEC Like --rename; see below
|
43
44
|
|
44
45
|
If no options are given, file tags are printed instead.
|
45
46
|
|
@@ -48,6 +49,9 @@ Usage
|
|
48
49
|
filename, %R leaves letter case intact, while %r downcases
|
49
50
|
the tag. A sequence such as %_t maps special characters in
|
50
51
|
the tag to the given substitute, in this case an underscore.
|
52
|
+
--rename remaps all characters that need to be escaped in
|
53
|
+
the shell, while --rename-fs remaps only characters that
|
54
|
+
are invalid in filenames.
|
51
55
|
|
52
56
|
Other options:
|
53
57
|
-h, --help Show this message and exit
|
@@ -65,7 +69,7 @@ Tag a series of files with an artist, album, and year:
|
|
65
69
|
|
66
70
|
Tag an audio file, then rename it to "14 - Queen of the Mole People.mp3":
|
67
71
|
|
68
|
-
taffy -n 14 -t "Queen of the Mole People" --rename "%n - %T" song.mp3
|
72
|
+
taffy -n 14 -t "Queen of the Mole People" --rename-fs "%n - %T" song.mp3
|
69
73
|
|
70
74
|
Etymology
|
71
75
|
---------
|
data/bin/taffy
CHANGED
@@ -5,7 +5,7 @@ require 'shellwords'
|
|
5
5
|
|
6
6
|
require 'taglib'
|
7
7
|
|
8
|
-
VERSION = [1,
|
8
|
+
VERSION = [1, 4, 0]
|
9
9
|
|
10
10
|
FIELDS = [
|
11
11
|
['l', 'album', String],
|
@@ -17,8 +17,11 @@ FIELDS = [
|
|
17
17
|
['y', 'year', Integer],
|
18
18
|
]
|
19
19
|
|
20
|
+
RENAME_CHARS = /[ `~!#$%^&*()=[{}\\|;:",<>\/?]|\\]/
|
21
|
+
RENAME_FS_CHARS = /[<>:"\/\\|?*]/
|
22
|
+
|
20
23
|
actions = []
|
21
|
-
extract_spec = rename_spec = nil
|
24
|
+
extract_spec = rename_spec = special_chars = nil
|
22
25
|
$status = 0
|
23
26
|
|
24
27
|
options = OptionParser.new do |opts|
|
@@ -60,6 +63,11 @@ options = OptionParser.new do |opts|
|
|
60
63
|
end
|
61
64
|
opts.on("--rename SPEC", String, "Rename file based on tags") do |spec|
|
62
65
|
rename_spec = spec
|
66
|
+
special_chars = RENAME_CHARS
|
67
|
+
end
|
68
|
+
opts.on("--rename-fs SPEC", String, "Like --rename; see below") do |spec|
|
69
|
+
rename_spec = spec
|
70
|
+
special_chars = RENAME_FS_CHARS
|
63
71
|
end
|
64
72
|
|
65
73
|
opts.separator ""
|
@@ -70,6 +78,9 @@ options = OptionParser.new do |opts|
|
|
70
78
|
opts.separator "filename, %R leaves letter case intact, while %r downcases"
|
71
79
|
opts.separator "the tag. A sequence such as %_t maps special characters in"
|
72
80
|
opts.separator "the tag to the given substitute, in this case an underscore."
|
81
|
+
opts.separator "--rename remaps all characters that need to be escaped in"
|
82
|
+
opts.separator "the shell, while --rename-fs remaps only characters that"
|
83
|
+
opts.separator "are invalid in filenames."
|
73
84
|
opts.separator ""
|
74
85
|
opts.separator "Other options:"
|
75
86
|
|
@@ -131,7 +142,14 @@ def extract(tag, spec, filename)
|
|
131
142
|
end
|
132
143
|
end
|
133
144
|
|
134
|
-
def
|
145
|
+
def strip_special_chars(str, subchar, special_chars)
|
146
|
+
# removing single quotes is usually better than remapping them
|
147
|
+
str.delete(special_chars == RENAME_CHARS ? "'" : '')
|
148
|
+
.gsub(special_chars, subchar).gsub(/(#{subchar})+/, subchar)
|
149
|
+
.gsub(/(^#{subchar}|#{subchar}$)/, '') || '_'
|
150
|
+
end
|
151
|
+
|
152
|
+
def rename(tag, spec, special_chars)
|
135
153
|
spec = spec.dup
|
136
154
|
|
137
155
|
FIELDS.each do |f|
|
@@ -139,8 +157,7 @@ def rename(tag, spec)
|
|
139
157
|
tag_string = tag_string.rjust(2, '0') if f[1] == 'track'
|
140
158
|
spec.gsub!(/%(\W|_)?(#{f[0]}|#{f[0].upcase})/) do |match|
|
141
159
|
sub = $2 == f[0] ? tag_string.downcase : tag_string
|
142
|
-
sub
|
143
|
-
sub == '' ? '_' : sub
|
160
|
+
strip_special_chars(sub, $1 || '', special_chars)
|
144
161
|
end
|
145
162
|
end
|
146
163
|
|
@@ -180,7 +197,8 @@ ARGV.each do |filename|
|
|
180
197
|
end
|
181
198
|
|
182
199
|
if rename_spec
|
183
|
-
name = rename(fileref.tag, rename_spec) +
|
200
|
+
name = rename(fileref.tag, rename_spec, special_chars) +
|
201
|
+
File.extname(filename)
|
184
202
|
path = File.join(File.dirname(filename), name)
|
185
203
|
if File.exist?(path)
|
186
204
|
warn("Cannot rename; file exists: #{name}")
|
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 = '2018-
|
3
|
+
s.version = '1.4.0'
|
4
|
+
s.date = '2018-05-20'
|
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.4.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: 2018-
|
11
|
+
date: 2018-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|
@@ -37,6 +37,7 @@ executables:
|
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
+
- ".gitignore"
|
40
41
|
- LICENSE
|
41
42
|
- README.md
|
42
43
|
- bin/taffy
|