unitf-tag 0.1.27 → 0.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/.gitignore +0 -2
- data/.vscode/tasks.json +1 -1
- data/CHANGELOG.md +4 -0
- data/bin/test.rb +4 -7
- data/docs/taglib.md +47 -0
- data/exe/tag +8 -7
- data/lib/unitf/tag/auto_tags.rb +5 -6
- data/lib/unitf/tag/file.rb +48 -23
- data/lib/unitf/tag/version.rb +1 -1
- data/lib/unitf/tag.rb +0 -1
- data/test-data/Foo/Bar/.autotag +2 -0
- data/test-data/Foo/Bar/2025/qq250916.mp3 +0 -0
- data/test-data/Test Artist/Test Album/04 - Test Song.mp3 +0 -0
- data/test-data/WFMU/BJ/2025/bj250915.mp3 +0 -0
- data/test-data/cover.jpg +0 -0
- data/test-data/song.mp3 +0 -0
- data/unitf-tag.gemspec +0 -4
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e8a3abd8e593009ee730ed4ee98c85f9f0b5665cdccf7ac1ea68b0f29e793a6
|
4
|
+
data.tar.gz: 2b62f8700524ba32f9961b14c129869a98b4e0fbf304c05173f9e059820d8bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5a1dd21d9cddb72642a99e8d0f1274f6e95a3fc76e80d9bb71838c6addc201814ac3dd0ff1d38482af6464ab37eddd5cd643d70240bf7fdf5fba80866d9c156
|
7
|
+
data.tar.gz: 6e7d036234644964322c41dd0dcc4d8e9982c76c6abc4dd430c28a88431f635194da76826c153dcd249b6c0e4a0d26c2e2892b74f75f8063d7ece32fdb99cca7
|
data/.gitignore
CHANGED
data/.vscode/tasks.json
CHANGED
data/CHANGELOG.md
CHANGED
data/bin/test.rb
CHANGED
@@ -4,10 +4,7 @@ require 'unitf/tag'
|
|
4
4
|
|
5
5
|
UnitF::Log.to_console
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# file.update do |f|
|
12
|
-
# f.auto_tag!
|
13
|
-
# end
|
7
|
+
UnitF::Tag.update('test-data/song.mp3') do |file|
|
8
|
+
puts "FILE: #{file}"
|
9
|
+
file.tag.artist = "Update #{Time.now.to_s}"
|
10
|
+
end
|
data/docs/taglib.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# taglib Notes
|
2
|
+
Notes on `taglib` and `taglib-ruby` issues
|
3
|
+
|
4
|
+
**GitHub**
|
5
|
+
- https://github.com/taglib/taglib
|
6
|
+
- https://github.com/robinst/taglib-ruby
|
7
|
+
|
8
|
+
## Custom TagLib 1.13.1 Build on MacOS
|
9
|
+
```
|
10
|
+
curl -O https://taglib.org/releases/taglib-1.13.1.tar.gz
|
11
|
+
tar xvf taglib-1.13.1.tar.gz
|
12
|
+
cd taglib-1.13.1
|
13
|
+
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/taglib1 -DCMAKE_BUILD_TYPE=Release .
|
14
|
+
make
|
15
|
+
sudo make install
|
16
|
+
```
|
17
|
+
|
18
|
+
```
|
19
|
+
TAGLIB_DIR=/usr/local/taglib1 gem install taglib-ruby --version '< 2'
|
20
|
+
```
|
21
|
+
|
22
|
+
## Custom Build on Linux
|
23
|
+
```
|
24
|
+
git clone https://github.com/taglib/taglib.git
|
25
|
+
cd taglib/
|
26
|
+
git submodule update --init
|
27
|
+
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/taglib -DCMAKE_BUILD_TYPE=Release .
|
28
|
+
make
|
29
|
+
make install
|
30
|
+
```
|
31
|
+
|
32
|
+
```
|
33
|
+
TAGLIB_DIR=/usr/local/taglib gem install taglib-ruby --version '>= 2'
|
34
|
+
```
|
35
|
+
|
36
|
+
### Taglib error w/ taglib 2.0.2
|
37
|
+
```
|
38
|
+
root@homer:/nas/music2/WFMU# gem install /tmp/unitf-tag-0.1.27.gem
|
39
|
+
Successfully installed unitf-tag-0.1.27
|
40
|
+
Parsing documentation for unitf-tag-0.1.27
|
41
|
+
Installing ri documentation for unitf-tag-0.1.27
|
42
|
+
Done installing documentation for unitf-tag after 0 seconds
|
43
|
+
1 gem installed
|
44
|
+
root@homer:/nas/music2/WFMU# tag
|
45
|
+
<internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:136:in `require': /usr/local/lib64/gems/ruby/taglib-ruby-2.0.0/taglib_base.so: undefined symbol: _ZN6TagLib4File11removeBlockElm - /usr/local/lib64/gems/ruby/taglib-ruby-2.0.0/taglib_base.so (LoadError)
|
46
|
+
from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:136:in `require'
|
47
|
+
```
|
data/exe/tag
CHANGED
@@ -100,21 +100,22 @@ end
|
|
100
100
|
|
101
101
|
files.each do |file|
|
102
102
|
UnitF::Log.info("Processing file: #{file}")
|
103
|
-
|
104
|
-
|
103
|
+
|
104
|
+
file.update do |f|
|
105
|
+
f.properties!(properties) unless properties.empty?
|
105
106
|
|
106
107
|
actions.each do |action|
|
107
108
|
case action
|
108
109
|
when :cover
|
109
|
-
|
110
|
+
f.cover!(opt[:cover])
|
110
111
|
when :delete_cover
|
111
|
-
|
112
|
+
f.delete_cover!
|
112
113
|
when :auto_cover
|
113
|
-
|
114
|
+
f.auto_cover!
|
114
115
|
when :auto_tag
|
115
|
-
|
116
|
+
f.auto_tag!
|
116
117
|
when :auto_tags
|
117
|
-
puts "\tauto_tags: #{
|
118
|
+
puts "\tauto_tags: #{f.auto_tags}\n\n"
|
118
119
|
end
|
119
120
|
end
|
120
121
|
end
|
data/lib/unitf/tag/auto_tags.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module UnitF
|
2
2
|
module Tag
|
3
3
|
class AutoTags < Hash
|
4
|
-
def initialize(
|
4
|
+
def initialize(file_path)
|
5
5
|
super
|
6
6
|
|
7
|
-
|
8
|
-
@
|
9
|
-
@dirname = pathname.realpath.dirname
|
7
|
+
@file_path = ::File.realpath(file_path.to_s)
|
8
|
+
@dirname = ::File.dirname(@file_path)
|
10
9
|
|
11
10
|
merge!(from_path)
|
12
11
|
merge!(from_file)
|
@@ -25,7 +24,7 @@ module UnitF
|
|
25
24
|
def from_path
|
26
25
|
tags = {}
|
27
26
|
|
28
|
-
tags[:title] = ::File.basename(@
|
27
|
+
tags[:title] = ::File.basename(@file_path)
|
29
28
|
tags[:track] = tags[:title].match(/^\s*\d+/).to_s.to_i
|
30
29
|
|
31
30
|
# Specific formatting for dated radio
|
@@ -39,7 +38,7 @@ module UnitF
|
|
39
38
|
|
40
39
|
path_parts = @dirname.to_s.split('/')
|
41
40
|
tags[:artist] = path_parts[-2]
|
42
|
-
tags[:album] =
|
41
|
+
tags[:album] = path_parts[-1]
|
43
42
|
|
44
43
|
tags
|
45
44
|
end
|
data/lib/unitf/tag/file.rb
CHANGED
@@ -6,24 +6,22 @@ require 'json'
|
|
6
6
|
|
7
7
|
module UnitF
|
8
8
|
module Tag
|
9
|
-
class File
|
10
|
-
|
11
|
-
super(::File.absolute_path(file_path.to_s))
|
12
|
-
end
|
9
|
+
class File
|
10
|
+
attr_accessor :path, :realpath, :dirname, :extname
|
13
11
|
|
14
|
-
def
|
15
|
-
raise Error, "
|
12
|
+
def initialize(file_path)
|
13
|
+
raise Error, "Invalid file #{file_path}" unless ::File.exist?(file_path)
|
16
14
|
|
17
|
-
@
|
18
|
-
|
15
|
+
@path = ::File.path(file_path.to_s)
|
16
|
+
@realpath = ::File.realpath(path)
|
17
|
+
@dirname = ::File.dirname(path)
|
18
|
+
@extname = ::File.extname(path)
|
19
19
|
|
20
|
-
|
21
|
-
@file&.save
|
20
|
+
raise Error, "Unknown file type: #{file_path}" unless mp3? || flac?
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
@
|
26
|
-
@file = nil
|
23
|
+
def to_s
|
24
|
+
@path
|
27
25
|
end
|
28
26
|
|
29
27
|
def format_json
|
@@ -40,7 +38,7 @@ module UnitF
|
|
40
38
|
|
41
39
|
def info
|
42
40
|
{
|
43
|
-
file: realpath
|
41
|
+
file: realpath,
|
44
42
|
artist: tag.artist,
|
45
43
|
album: tag.album,
|
46
44
|
title: tag.title,
|
@@ -91,15 +89,18 @@ module UnitF
|
|
91
89
|
true
|
92
90
|
rescue StandardError => e
|
93
91
|
UnitF::Log.error("Failed to auto-cover file #{e}")
|
92
|
+
puts e.backtrace
|
94
93
|
false
|
95
94
|
end
|
96
95
|
|
97
96
|
def auto_tags
|
98
|
-
@auto_tags ||= UnitF::Tag::AutoTags.new(
|
97
|
+
@auto_tags ||= UnitF::Tag::AutoTags.new(path)
|
99
98
|
end
|
100
99
|
|
101
100
|
def auto_tag!
|
102
101
|
UnitF::Log.info("Auto tagging #{self}")
|
102
|
+
UnitF::Log.info(auto_tags)
|
103
|
+
|
103
104
|
tag.album = auto_tags[:album]
|
104
105
|
tag.artist = auto_tags[:artist]
|
105
106
|
tag.title = auto_tags[:title]
|
@@ -116,21 +117,45 @@ module UnitF
|
|
116
117
|
end
|
117
118
|
|
118
119
|
def update
|
119
|
-
open
|
120
|
-
|
120
|
+
open do |file|
|
121
|
+
if block_given?
|
122
|
+
yield(file)
|
123
|
+
file.save || (raise Error, "Failed to save file #{file}")
|
124
|
+
end
|
121
125
|
end
|
122
126
|
end
|
123
127
|
|
124
|
-
def open
|
128
|
+
def open
|
125
129
|
file = if flac?
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
+
UnitF::Tag::FLAC.new(path)
|
131
|
+
elsif mp3?
|
132
|
+
UnitF::Tag::MP3.new(path)
|
133
|
+
end
|
130
134
|
yield(file) if block_given?
|
131
|
-
file.save if auto_save
|
132
135
|
file.close
|
133
136
|
end
|
137
|
+
|
138
|
+
#
|
139
|
+
# Methods that use @file, which comes from child classes
|
140
|
+
#
|
141
|
+
def tag
|
142
|
+
raise Error, "File is not open #{self.class.name}" if @file&.tag.nil?
|
143
|
+
|
144
|
+
@file&.tag
|
145
|
+
end
|
146
|
+
|
147
|
+
def save
|
148
|
+
raise Error, "File is not open #{self.class.name}" if @file&.tag.nil?
|
149
|
+
|
150
|
+
@file&.save
|
151
|
+
end
|
152
|
+
|
153
|
+
def close
|
154
|
+
raise Error, "File is not open #{self.class.name}" if @file&.tag.nil?
|
155
|
+
|
156
|
+
@file&.close
|
157
|
+
@file = nil
|
158
|
+
end
|
134
159
|
end
|
135
160
|
end
|
136
161
|
end
|
data/lib/unitf/tag/version.rb
CHANGED
data/lib/unitf/tag.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/test-data/cover.jpg
ADDED
Binary file
|
data/test-data/song.mp3
ADDED
Binary file
|
data/unitf-tag.gemspec
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'lib/unitf/tag/version'
|
4
|
-
# require 'rbconfig'
|
5
|
-
|
6
|
-
# taglib_ruby_version = '>= 2.0.0' unless RbConfig::CONFIG['host_os'].match?(/linux/)
|
7
|
-
# taglib_ruby_version = '1.1.3' if RbConfig::CONFIG['host_os'].match?(/linux/)
|
8
4
|
|
9
5
|
Gem::Specification.new do |spec|
|
10
6
|
spec.name = 'unitf-tag'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unitf-tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Baron
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: logger
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- README.md
|
72
72
|
- Rakefile
|
73
73
|
- bin/test.rb
|
74
|
+
- docs/taglib.md
|
74
75
|
- exe/tag
|
75
76
|
- exe/unitf-autotags
|
76
77
|
- lib/unitf/tag.rb
|
@@ -82,6 +83,12 @@ files:
|
|
82
83
|
- lib/unitf/tag/helpers.rb
|
83
84
|
- lib/unitf/tag/mp3.rb
|
84
85
|
- lib/unitf/tag/version.rb
|
86
|
+
- test-data/Foo/Bar/.autotag
|
87
|
+
- test-data/Foo/Bar/2025/qq250916.mp3
|
88
|
+
- test-data/Test Artist/Test Album/04 - Test Song.mp3
|
89
|
+
- test-data/WFMU/BJ/2025/bj250915.mp3
|
90
|
+
- test-data/cover.jpg
|
91
|
+
- test-data/song.mp3
|
85
92
|
- unitf-tag.gemspec
|
86
93
|
homepage: https://github.com/mattbaron/unitf-tag
|
87
94
|
licenses:
|