unitf-tag 0.1.6 → 0.1.8
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/.rubocop.yml +5 -0
- data/.vscode/tasks.json +1 -1
- data/bin/test.rb +3 -4
- data/exe/{rtag → tag} +23 -17
- data/lib/unitf/tag/file.rb +33 -0
- data/lib/unitf/tag/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68404fe4f09503662b8fa2f52479ce65d14f5c9eea0d6928e99a10599c468be8
|
4
|
+
data.tar.gz: 398a8ea66bcfa0dcc33d3fafb1e51f6fcd305c4377644df6a3d5ad94f3786647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94f7d7c34b182095ea849846ebbb811e2f964d50d74aff54a8e9648193b366ada30028216440f53a96ce3b7133a4d40e9cdf2ee565479df5b07a15958b174a0b
|
7
|
+
data.tar.gz: 0475211c72702358a985acece10e4af18ac3f36c2d3869807f329a03391d80b16e64968d2aa852b4c55a70776c3ec149aec091fd7336cf77ae076858617fe04c
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.vscode/tasks.json
CHANGED
data/bin/test.rb
CHANGED
@@ -2,10 +2,9 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
require 'unitf/tag'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
file = UnitF::Tag::FLAC.new(file_str)
|
5
|
+
UnitF::Log.to_console
|
8
6
|
|
7
|
+
file = UnitF::Tag::File.new('/Users/mbaron/tmp/WFMU/BJ/bj211119.mp3')
|
9
8
|
file.open do |o|
|
10
|
-
|
9
|
+
puts o.auto_tags
|
11
10
|
end
|
data/exe/{rtag → tag}
RENAMED
@@ -5,15 +5,13 @@ $LOAD_PATH.unshift("#{__dir__}/../lib")
|
|
5
5
|
require 'logger'
|
6
6
|
require 'optparse'
|
7
7
|
require 'unitf/tag'
|
8
|
+
require 'unitf/logging'
|
8
9
|
|
9
|
-
|
10
|
+
UnitF::Log.to_console
|
10
11
|
|
11
12
|
actions = []
|
12
13
|
files = []
|
13
|
-
opt = {
|
14
|
-
recursive: false,
|
15
|
-
force: false
|
16
|
-
}
|
14
|
+
opt = {}
|
17
15
|
|
18
16
|
targets = OptionParser.new do |opts|
|
19
17
|
opts.on('-r', '--recursive', 'Auto Cover') do
|
@@ -67,6 +65,11 @@ targets = OptionParser.new do |opts|
|
|
67
65
|
opt[:title] = arg
|
68
66
|
end
|
69
67
|
|
68
|
+
opts.on('--year YEAR', 'Song Year') do |arg|
|
69
|
+
actions << :year
|
70
|
+
opt[:year] = arg.to_i
|
71
|
+
end
|
72
|
+
|
70
73
|
opts.on('--genre GENRE', 'Genre') do |arg|
|
71
74
|
actions << :genre
|
72
75
|
opt[:genre] = arg
|
@@ -76,7 +79,7 @@ end.parse!
|
|
76
79
|
files = UnitF::Tag::FileSet.new(targets)
|
77
80
|
|
78
81
|
if files.size.zero?
|
79
|
-
|
82
|
+
UnitF::Log.error('Cannot find any files to operate on')
|
80
83
|
end
|
81
84
|
|
82
85
|
if actions.size.zero?
|
@@ -85,42 +88,45 @@ if actions.size.zero?
|
|
85
88
|
end
|
86
89
|
|
87
90
|
files.each do |file|
|
88
|
-
|
91
|
+
UnitF::Log.info("Processing file: #{file}")
|
89
92
|
file.open do |o|
|
90
93
|
actions.each do |action|
|
91
94
|
case action
|
92
95
|
when :delete_cover
|
93
|
-
|
96
|
+
UnitF::Log.info('Delete cover')
|
94
97
|
o.delete_cover!
|
95
98
|
when :auto_cover
|
96
99
|
unless o.cover?
|
97
|
-
|
100
|
+
UnitF::Log.info("Auto Cover #{file.cover_path}")
|
98
101
|
begin
|
99
102
|
o.auto_cover!
|
100
103
|
rescue => e
|
101
|
-
|
104
|
+
UnitF::Log.error("Failed to auto-cover file #{e}")
|
102
105
|
end
|
103
106
|
end
|
104
107
|
when :auto_tag
|
105
|
-
|
108
|
+
UnitF::Log.info('Auto Tag')
|
106
109
|
o.auto_tag!
|
107
110
|
when :artist
|
108
|
-
|
111
|
+
UnitF::Log.info("Setting artist to #{opt[:artist]}")
|
109
112
|
o.tag.artist = opt[:artist]
|
110
113
|
when :album
|
111
|
-
|
114
|
+
UnitF::Log.info("Setting album to #{opt[:album]}")
|
112
115
|
o.tag.album = opt[:album]
|
113
116
|
when :title
|
114
|
-
|
117
|
+
UnitF::Log.info("Setting title to #{opt[:title]}")
|
115
118
|
o.tag.title = opt[:title]
|
116
119
|
when :genre
|
117
|
-
|
120
|
+
UnitF::Log.info("Setting genre to #{opt[:genre]}")
|
118
121
|
o.tag.genre = opt[:genre]
|
119
122
|
when :track
|
120
|
-
|
123
|
+
UnitF::Log.info("Setting track to #{opt[:track]}")
|
121
124
|
o.tag.genre = opt[:track]
|
125
|
+
when :year
|
126
|
+
UnitF::Log.info("Setting year to #{opt[:year]}")
|
127
|
+
o.tag.year = opt[:year]
|
122
128
|
end
|
123
129
|
end
|
124
|
-
o.save ||
|
130
|
+
o.save || UnitF::Log.error("Unable to save changes to #{file}")
|
125
131
|
end
|
126
132
|
end
|
data/lib/unitf/tag/file.rb
CHANGED
@@ -77,7 +77,40 @@ module UnitF
|
|
77
77
|
cover!(cover_path)
|
78
78
|
end
|
79
79
|
|
80
|
+
def manual_auto_tags
|
81
|
+
UnitF::Log.info(auto_tag_path)
|
82
|
+
tags = {}
|
83
|
+
return {} unless ::File.exist?(auto_tag_path)
|
84
|
+
::File.read(auto_tag_path).each_line do |line|
|
85
|
+
line.chomp!
|
86
|
+
UnitF::Log.info(line)
|
87
|
+
tag, value = line.split(/\s*=\s*/)
|
88
|
+
tags[tag.to_sym] = value
|
89
|
+
end
|
90
|
+
tags
|
91
|
+
rescue
|
92
|
+
{}
|
93
|
+
end
|
94
|
+
|
95
|
+
def auto_tags
|
96
|
+
manual_tags = manual_auto_tags
|
97
|
+
tags = {}
|
98
|
+
|
99
|
+
tags[:title] = ::File.basename(realpath.to_path)
|
100
|
+
track = tags[:title].match(/^\s*\d+/).to_s.to_i
|
101
|
+
tags[:title].gsub!(/\.\w+$/, '')
|
102
|
+
tags[:title].gsub!(/^\d*\s*(-|\.)*\s*/, '')
|
103
|
+
path_parts = realpath.dirname.to_path.split('/')
|
104
|
+
tags[:album] = path_parts[-1]
|
105
|
+
tags[:artist] = path_parts[-2]
|
106
|
+
|
107
|
+
tags.merge(manual_auto_tags)
|
108
|
+
end
|
109
|
+
|
80
110
|
def auto_tag!
|
111
|
+
UnitF::Log.info("Auto tagging #{to_s}")
|
112
|
+
manual_auto_tags
|
113
|
+
|
81
114
|
title = ::File.basename(realpath.to_path)
|
82
115
|
|
83
116
|
# This must come before gsubbing the title
|
data/lib/unitf/tag/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unitf-tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Baron
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: taglib-ruby
|
@@ -42,7 +42,7 @@ description: Audio File Tagging
|
|
42
42
|
email:
|
43
43
|
- mwb@unitf.net
|
44
44
|
executables:
|
45
|
-
-
|
45
|
+
- tag
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
@@ -59,7 +59,7 @@ files:
|
|
59
59
|
- bin/console
|
60
60
|
- bin/setup
|
61
61
|
- bin/test.rb
|
62
|
-
- exe/
|
62
|
+
- exe/tag
|
63
63
|
- lib/unitf/tag.rb
|
64
64
|
- lib/unitf/tag/export/exporter.rb
|
65
65
|
- lib/unitf/tag/file.rb
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
96
|
+
rubygems_version: 3.3.26
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Audio File Tagging
|