batch_audio_convert 0.2.0-x86_64-linux → 0.2.1-x86_64-linux
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/batch_audio_convert.gemspec +1 -1
- data/bin/batch_audio_convert +1 -2
- data/lib/batch_audio_convert/audio_utils.rb +38 -17
- data/lib/batch_audio_convert/version.rb +2 -2
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b87c437ae6410f25e5943663a914079c34706c
|
4
|
+
data.tar.gz: 585e6d1358755f4e7e6344f8167cd6c8eaed4a8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aec9988efd9079db5a2593633b24e7ddcf06d1908378e57650e971882c18db598ffdff42c7a46a29bb171fce949ad87cfd63c9cacf1c614e7c440a93dfa746c
|
7
|
+
data.tar.gz: 7dcbe4aa7c5f6661c0452a12f9d5e6cd8c360a78b4633649ea9408e692eddfd736245ef09bfd5ecf7f3a73e2979aa4f43c04aec644e1ddb836a6e8e743ea6588
|
data/batch_audio_convert.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency 'bundler'
|
23
23
|
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'pry'
|
24
25
|
|
25
26
|
spec.add_runtime_dependency 'easy_app_helper', '~> 3.0'
|
26
27
|
spec.add_runtime_dependency 'taglib-ruby'
|
27
|
-
spec.add_runtime_dependency 'pry'
|
28
28
|
|
29
29
|
end
|
data/bin/batch_audio_convert
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
|
10
10
|
require 'easy_app_helper'
|
11
11
|
require 'batch_audio_convert'
|
12
|
-
require 'pry'
|
13
12
|
|
14
13
|
|
15
14
|
class BatchAudioConvertApp
|
@@ -20,7 +19,7 @@ class BatchAudioConvertApp
|
|
20
19
|
APP_NAME = 'batch_audio_convert'
|
21
20
|
|
22
21
|
def initialize
|
23
|
-
#
|
22
|
+
# Providing this data is optional but brings better logging and online help
|
24
23
|
config.describes_application(app_name: APP_NAME, app_version: VERSION, app_description: DESCRIPTION)
|
25
24
|
add_cmd_line_options
|
26
25
|
end
|
@@ -10,12 +10,22 @@ require 'taglib'
|
|
10
10
|
|
11
11
|
module AudioUtils
|
12
12
|
|
13
|
-
TAGS = [:title, :artist, :comment, :genre, :album, :track, :year]
|
14
|
-
|
15
13
|
OGG_ENC_CMD = 'oggenc -q##OGGQUALITY## -o "##OGGFILE##" "##WAVFILE##"'
|
16
14
|
FLAC_DEC_CMD = 'flac -d -f -o "##WAVFILE##" "##FLACFILE##"'
|
17
15
|
MP3_ENC_CMD = 'lame -h -b ##MP3QUALITY## "##WAVFILE##" "##MP3FILE##"'
|
18
16
|
|
17
|
+
# From ID3V2 Reference https://web.archive.org/web/20161117211455/http://id3.org/d3v2.3.0
|
18
|
+
MP3_TAGS = {
|
19
|
+
'ALBUM' => 'TALB',
|
20
|
+
'ARTIST' => 'TPE1',
|
21
|
+
'ALBUMARTIST' => 'TPE2',
|
22
|
+
'TITLE' => 'TIT2',
|
23
|
+
'COPYRIGHT' => 'TCOP',
|
24
|
+
'DATE' => 'TDRC',
|
25
|
+
'TRACKNUMBER' => 'TRCK'
|
26
|
+
}.freeze
|
27
|
+
|
28
|
+
|
19
29
|
def flac_to_ogg (origin, destination)
|
20
30
|
flac_to origin, destination do |temp_file, tags|
|
21
31
|
run_command build_ogg_cmd(temp_file.path, destination)
|
@@ -58,25 +68,21 @@ module AudioUtils
|
|
58
68
|
|
59
69
|
def flac_tags(file)
|
60
70
|
puts_and_logs ' - Reading FLAC tags'
|
61
|
-
|
62
|
-
|
63
|
-
tag
|
64
|
-
|
65
|
-
tags[tag_name] = tag.send(tag_name)
|
66
|
-
end
|
71
|
+
TagLib::FLAC::File.open(file) do |file_handle|
|
72
|
+
tag = file_handle.xiph_comment
|
73
|
+
logger.debug tag.field_list_map.inspect
|
74
|
+
tag.field_list_map
|
67
75
|
end
|
68
|
-
logger.debug tags.inspect
|
69
|
-
tags
|
70
76
|
end
|
71
77
|
|
72
78
|
def set_ogg_tags(file, tags)
|
73
79
|
puts_and_logs ' - Writing OGG tags'
|
74
|
-
TagLib::
|
75
|
-
tag =
|
80
|
+
TagLib::Ogg::Vorbis::File.open(file) do |file_handle|
|
81
|
+
tag = file_handle.tag
|
76
82
|
tags.each do |tag_name, value|
|
77
|
-
tag.
|
83
|
+
tag.add_field tag_name, value.first
|
78
84
|
end
|
79
|
-
|
85
|
+
file_handle.save
|
80
86
|
end
|
81
87
|
end
|
82
88
|
|
@@ -96,13 +102,28 @@ module AudioUtils
|
|
96
102
|
def set_mp3_tags(file, tags)
|
97
103
|
puts_and_logs ' - Writing MP3 tags'
|
98
104
|
TagLib::MPEG::File.open(file) do |file_ref|
|
99
|
-
tag = file_ref.id3v2_tag
|
105
|
+
tag = file_ref.id3v2_tag
|
100
106
|
tags.each do |tag_name, value|
|
101
|
-
tag.send("#{tag_name
|
107
|
+
# tag.send("#{tag_name}=", value.first)
|
108
|
+
unless MP3_TAGS.keys.include? tag_name
|
109
|
+
logger.warn "Ignoring tag '#{tag_name}' ! Not handled !"
|
110
|
+
next
|
111
|
+
end
|
112
|
+
|
113
|
+
logger.debug "Processing original tag '#{tag_name}' as '#{MP3_TAGS[tag_name]}' ID3V2 tag..."
|
114
|
+
frame = TagLib::ID3v2::TextIdentificationFrame.new(MP3_TAGS[tag_name], TagLib::String::UTF8)
|
115
|
+
val = if tag_name == 'TRACKNUMBER'
|
116
|
+
tags['TRACKTOTAL'] ? "#{value.first}/#{tags['TRACKTOTAL'].first}" : value.first
|
117
|
+
else
|
118
|
+
value.first
|
119
|
+
end
|
120
|
+
logger.debug " - #{MP3_TAGS[tag_name]} => #{val}"
|
121
|
+
frame.text = val
|
122
|
+
tag.add_frame frame
|
102
123
|
end
|
103
124
|
file_ref.save
|
104
125
|
end
|
105
|
-
end
|
126
|
+
end
|
106
127
|
|
107
128
|
def build_mp3_cmd(origin, destination)
|
108
129
|
config[:'mp3-quality'] ||= 256
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batch_audio_convert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: x86_64-linux
|
6
6
|
authors:
|
7
7
|
- L.Briais
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,35 +39,35 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: easy_app_helper
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '3.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: taglib-ruby
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.14.4
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Converts FLAC audio files to OGG or MP3 format while keeping tags and tree
|