wahwah 1.6.1 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wahwah/mp4/atom.rb +2 -1
- data/lib/wahwah/ogg_tag.rb +6 -0
- data/lib/wahwah/tag.rb +26 -23
- data/lib/wahwah/version.rb +1 -1
- data/lib/wahwah.rb +6 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fed1451a524177200ca3ccdb13b6cc809fdc9f4913ed613f5cceb29ac316380
|
4
|
+
data.tar.gz: ab6aac50fa7b73c55843a722ac0e34cd77da57f5a2b968a4ccf9491c53196743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70edb86e41aad8f729d186d6f90c54c2e834528b6a0b3570f8ff3b15270d87e12df906a9d2e14d57f70349efe975cb61074591d2f8787f64285b06b7eb1a3a2e
|
7
|
+
data.tar.gz: 1629bb5729a89dd1088d1b4601e549ed5b53a45fa5d25fe286b24aab760bb7b81da8f56476a90d39a66e6b883200d504a2c4c0270f170e7df89999fd20d3770d
|
data/lib/wahwah/mp4/atom.rb
CHANGED
@@ -44,7 +44,6 @@ module WahWah
|
|
44
44
|
# This can often be usefully treated as a four-character field with a mnemonic value .
|
45
45
|
def initialize
|
46
46
|
@size, @type = @file_io.read(HEADER_SIZE)&.unpack("Na4")
|
47
|
-
return unless valid?
|
48
47
|
|
49
48
|
# If the size field of an atom is set to 1, the type field is followed by a 64-bit extended size field,
|
50
49
|
# which contains the actual size of the atom as a 64-bit unsigned integer.
|
@@ -53,6 +52,8 @@ module WahWah
|
|
53
52
|
# If the size field of an atom is set to 0, which is allowed only for a top-level atom,
|
54
53
|
# designates the last atom in the file and indicates that the atom extends to the end of the file.
|
55
54
|
@size = @file_io.size if @size == 0
|
55
|
+
return unless valid?
|
56
|
+
|
56
57
|
@size -= HEADER_SIZE
|
57
58
|
end
|
58
59
|
|
data/lib/wahwah/ogg_tag.rb
CHANGED
@@ -55,6 +55,12 @@ module WahWah
|
|
55
55
|
Ogg::FlacTag.new(identification_packet, comment_packet)
|
56
56
|
end
|
57
57
|
|
58
|
+
# Eagerly calculate duration and bitrate when open from path
|
59
|
+
if from_path
|
60
|
+
@duration = parse_duration
|
61
|
+
@bitrate = parse_bitrate
|
62
|
+
end
|
63
|
+
|
58
64
|
@bit_depth = parse_bit_depth
|
59
65
|
end
|
60
66
|
|
data/lib/wahwah/tag.rb
CHANGED
@@ -3,30 +3,31 @@
|
|
3
3
|
module WahWah
|
4
4
|
class Tag
|
5
5
|
INTEGER_ATTRIBUTES = %i[disc disc_total track track_total]
|
6
|
-
INSPECT_ATTRIBUTES = %i[
|
6
|
+
INSPECT_ATTRIBUTES = %i[
|
7
|
+
title
|
8
|
+
artist
|
9
|
+
album
|
10
|
+
albumartist
|
11
|
+
composer
|
12
|
+
comments
|
13
|
+
track
|
14
|
+
track_total
|
15
|
+
genre
|
16
|
+
year
|
17
|
+
disc
|
18
|
+
disc_total
|
19
|
+
lyrics
|
20
|
+
duration
|
21
|
+
bitrate
|
22
|
+
sample_rate
|
23
|
+
bit_depth
|
24
|
+
file_size
|
25
|
+
]
|
7
26
|
|
8
|
-
attr_reader(
|
9
|
-
:title,
|
10
|
-
:artist,
|
11
|
-
:album,
|
12
|
-
:albumartist,
|
13
|
-
:composer,
|
14
|
-
:comments,
|
15
|
-
:track,
|
16
|
-
:track_total,
|
17
|
-
:genre,
|
18
|
-
:year,
|
19
|
-
:disc,
|
20
|
-
:disc_total,
|
21
|
-
:lyrics,
|
22
|
-
:duration,
|
23
|
-
:bitrate,
|
24
|
-
:sample_rate,
|
25
|
-
:bit_depth,
|
26
|
-
:file_size
|
27
|
-
)
|
27
|
+
attr_reader(*INSPECT_ATTRIBUTES)
|
28
28
|
|
29
|
-
def initialize(io)
|
29
|
+
def initialize(io, from_path: false)
|
30
|
+
@from_path = from_path
|
30
31
|
@file_size = io.size
|
31
32
|
@file_io = io
|
32
33
|
|
@@ -43,7 +44,7 @@ module WahWah
|
|
43
44
|
|
44
45
|
def inspect
|
45
46
|
inspect_id = ::Kernel.format "%x", (object_id * 2)
|
46
|
-
inspect_attributes_values = INSPECT_ATTRIBUTES.map { |attr_name| "#{attr_name}
|
47
|
+
inspect_attributes_values = INSPECT_ATTRIBUTES.map { |attr_name| "#{attr_name}: #{send(attr_name).inspect}" }.join(", ")
|
47
48
|
|
48
49
|
"<#{self.class.name}:0x#{inspect_id} #{inspect_attributes_values}>"
|
49
50
|
end
|
@@ -58,6 +59,8 @@ module WahWah
|
|
58
59
|
|
59
60
|
private
|
60
61
|
|
62
|
+
attr_accessor :from_path
|
63
|
+
|
61
64
|
def parse
|
62
65
|
raise WahWahNotImplementedError, "The parse method is not implemented"
|
63
66
|
end
|
data/lib/wahwah/version.rb
CHANGED
data/lib/wahwah.rb
CHANGED
@@ -61,13 +61,13 @@ module WahWah
|
|
61
61
|
}.freeze
|
62
62
|
|
63
63
|
def self.open(path_or_io)
|
64
|
-
with_io path_or_io do |io|
|
64
|
+
with_io path_or_io do |io, from_path|
|
65
65
|
file_format = Helper.file_format io
|
66
66
|
|
67
67
|
raise WahWahArgumentError, "No supported format found" unless support_formats.include? file_format
|
68
68
|
|
69
69
|
FORMATE_MAPPING.each do |tag, formats|
|
70
|
-
break const_get(tag).new(io) if formats.include?(file_format)
|
70
|
+
break const_get(tag).new(io, **from_path) if formats.include?(file_format)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -84,10 +84,11 @@ module WahWah
|
|
84
84
|
raise WahWahArgumentError, "File is unreadable" unless File.readable? path_or_io
|
85
85
|
raise WahWahArgumentError, "File is empty" unless File.size(path_or_io) > 0
|
86
86
|
|
87
|
-
path_or_io.open
|
87
|
+
path_or_io.open do |io|
|
88
|
+
block.call(io, from_path: true)
|
89
|
+
end
|
88
90
|
else
|
89
|
-
|
90
|
-
block.call path_or_io
|
91
|
+
block.call(path_or_io, from_path: false)
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wahwah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aidewoode
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
178
|
+
rubygems_version: 3.4.19
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Audio metadata reader ruby gem
|