batch_audio_convert 0.1.7-x86_64-linux → 0.2.1-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5707491472052fb2053ba324e7b2a9f6c7ab01e9
4
- data.tar.gz: e9dc094da2e51dd7b79c06942bf0cb54ed2771b1
3
+ metadata.gz: 77b87c437ae6410f25e5943663a914079c34706c
4
+ data.tar.gz: 585e6d1358755f4e7e6344f8167cd6c8eaed4a8a
5
5
  SHA512:
6
- metadata.gz: c0bc202fe5463a9b29ff4fbed584cec6e13fd745785a408ce32b857f4fdd07632e8d2a76ab683940717304bd41c187c36faa1f89209355016f063721b791afc1
7
- data.tar.gz: f9f448e64fc88f6a74996ddc18f575d03a8cfe6b16daf8735457845c0b710702915cac6707c5e55f095274604f8ceeb4e14e2e66ae6287b442a2890b1a914962
6
+ metadata.gz: 0aec9988efd9079db5a2593633b24e7ddcf06d1908378e57650e971882c18db598ffdff42c7a46a29bb171fce949ad87cfd63c9cacf1c614e7c440a93dfa746c
7
+ data.tar.gz: 7dcbe4aa7c5f6661c0452a12f9d5e6cd8c360a78b4633649ea9408e692eddfd736245ef09bfd5ecf7f3a73e2979aa4f43c04aec644e1ddb836a6e8e743ea6588
@@ -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
- spec.add_runtime_dependency 'easy_app_helper', '~> 2.0'
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
@@ -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
- # Providing this data is optional but brings better logging and online help
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
- tags = {}
62
- TagLib::FileRef.open(file) do |file_ref|
63
- tag = file_ref.tag
64
- TAGS.each do |tag_name|
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::FileRef.open(file) do |file_ref|
75
- tag = file_ref.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.send("#{tag_name.to_s}=", tags[tag_name])
83
+ tag.add_field tag_name, value.first
78
84
  end
79
- file_ref.save
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(true)
105
+ tag = file_ref.id3v2_tag
100
106
  tags.each do |tag_name, value|
101
- tag.send("#{tag_name.to_s}=", tags[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
@@ -6,5 +6,5 @@
6
6
  ################################################################################
7
7
 
8
8
  module BatchAudioConvert
9
- VERSION = '0.1.7'
9
+ VERSION = '0.2.1'
10
10
  end
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.1.7
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: 2017-06-10 00:00:00.000000000 Z
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: easy_app_helper
42
+ name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :runtime
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: '2.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: taglib-ruby
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: pry
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.4.5.1
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