wahwah 1.6.0 → 1.6.2
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/lib/wahwah/helper.rb +9 -1
- data/lib/wahwah/id3/image_frame_body.rb +2 -2
- data/lib/wahwah/ogg_tag.rb +6 -0
- data/lib/wahwah/tag.rb +4 -2
- data/lib/wahwah/version.rb +1 -1
- data/lib/wahwah.rb +6 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3a02fc03d0532cd3083005e42d0609cc56cec7648027367ba56fa13054538a7
|
4
|
+
data.tar.gz: df4d540b3bd4a721e99efc02ba19e19f369c1ba58ac6e29c6ad84a22fa6adf34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ce069bbe3e5c1db3735f0aa5cb7de9be1de9f0755b8fdce90a163473039041da63351457149e674a61181840fbe0066032fc03b270c6fca030a3c39ee80b64b
|
7
|
+
data.tar.gz: c7edf5a8987c8e54e46b521d3650fe84524dda3911e801ba85eb64ab4df4802e6ff43267b2fbca237924cf9eecc2948bd695e3f339cf48cf0f30eef213ee771c
|
data/lib/wahwah/helper.rb
CHANGED
@@ -22,7 +22,15 @@ module WahWah
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.split_with_terminator(string, terminator_size)
|
25
|
-
|
25
|
+
terminator = ("\x00" * terminator_size).b
|
26
|
+
|
27
|
+
(0...string.size).step(terminator_size).each do |index|
|
28
|
+
if string[index...(index + terminator_size)] == terminator
|
29
|
+
return [string[0...index], string[index + terminator_size..]]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
[]
|
26
34
|
end
|
27
35
|
|
28
36
|
def self.file_format(io)
|
@@ -49,9 +49,9 @@ module WahWah
|
|
49
49
|
# Picture data <binary data>
|
50
50
|
def parse
|
51
51
|
frame_format = @version > 2 ? "CZ*Ca*" : "Ca3Ca*"
|
52
|
-
encoding_id, @mime_type, type_index,
|
52
|
+
encoding_id, @mime_type, type_index, rest_content = @content.unpack(frame_format)
|
53
53
|
encoding = ENCODING_MAPPING[encoding_id]
|
54
|
-
_description, data = Helper.split_with_terminator(
|
54
|
+
_description, data = Helper.split_with_terminator(rest_content, ENCODING_TERMINATOR_SIZE[encoding])
|
55
55
|
|
56
56
|
@value = {data: data, mime_type: mime_type, type: TYPES[type_index]}
|
57
57
|
end
|
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
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.2
|
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-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|