mp3file 1.1.1 → 1.1.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/mp3file/mp3_file.rb +29 -12
- data/lib/mp3file/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da11954d17d2192242abc2017940101590ad797b
|
4
|
+
data.tar.gz: 0018b0f2fabb9aa7582722aaf3c8a1985a004479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0e6fe9ae807f7981faf6332de40a7791666823bd9d55e94ebf2dbf89e16b3cb60dcefb46d603fe17b81fac974247887b379b4972ad8c76683f00c3c6a766246
|
7
|
+
data.tar.gz: f9e290a4928af6d4de7c68e82aa16913513745cc11c4157549289b3534b9b89e5737447d267abee81aacdeb0d3883a27eb5c3ec166f458d2a1cc603f5392d8e1
|
data/lib/mp3file/mp3_file.rb
CHANGED
@@ -116,6 +116,10 @@ module Mp3file
|
|
116
116
|
@file.seek(@id3v2_tag.size, IO::SEEK_SET)
|
117
117
|
end
|
118
118
|
|
119
|
+
# Count how many bytes we had to skip while searching for a
|
120
|
+
# frame.
|
121
|
+
@skipped_bytes = 0
|
122
|
+
|
119
123
|
# Some files have more than one ID3v2 tag. If we can't find an
|
120
124
|
# MP3 header in the next 4k, try reading another ID3v2 tag and
|
121
125
|
# repeat.
|
@@ -124,20 +128,28 @@ module Mp3file
|
|
124
128
|
# Try to find the first MP3 header.
|
125
129
|
@first_header_offset, @first_header = get_next_header(@file)
|
126
130
|
rescue InvalidMP3FileError
|
127
|
-
|
128
|
-
|
131
|
+
if @id3v2_tag
|
132
|
+
end_of_tags = @id3v2_tag.size + @extra_id3v2_tags.map(&:last).map(&:size).reduce(:+).to_i
|
133
|
+
@file.seek(end_of_tags, IO::SEEK_SET)
|
129
134
|
|
130
|
-
tag = nil
|
131
|
-
begin
|
132
|
-
tag = ID3v2::Tag.new(@file)
|
133
|
-
rescue ID3v2::InvalidID3v2TagError
|
134
135
|
tag = nil
|
135
|
-
|
136
|
-
|
136
|
+
begin
|
137
|
+
tag = ID3v2::Tag.new(@file)
|
138
|
+
rescue ID3v2::InvalidID3v2TagError
|
139
|
+
tag = nil
|
140
|
+
@file.seek(end_of_tags, IO::SEEK_SET)
|
141
|
+
end
|
137
142
|
|
138
|
-
|
139
|
-
|
140
|
-
|
143
|
+
if tag
|
144
|
+
@extra_id3v2_tags << [ end_of_tags, tag ]
|
145
|
+
|
146
|
+
# Start the counter of skipped bytes over again, since we're
|
147
|
+
# starting the search for the first header over again.
|
148
|
+
@skipped_bytes = 0
|
149
|
+
retry
|
150
|
+
else
|
151
|
+
raise
|
152
|
+
end
|
141
153
|
else
|
142
154
|
raise
|
143
155
|
end
|
@@ -251,8 +263,13 @@ module Mp3file
|
|
251
263
|
# end
|
252
264
|
end
|
253
265
|
|
266
|
+
@skipped_bytes += header_offset - initial_header_offset
|
267
|
+
if @skipped_bytes > 2048
|
268
|
+
raise InvalidMP3FileError, "Had to skip > 2048 bytes in between headers."
|
269
|
+
end
|
270
|
+
|
254
271
|
# if initial_header_offset != header_offset
|
255
|
-
# puts "Had to skip past #{header_offset - initial_header_offset} to find the next header."
|
272
|
+
# puts "Had to skip past #{header_offset - initial_header_offset} to find the next header. header_offset = #{header_offset} header = #{header.inspect}"
|
256
273
|
# end
|
257
274
|
|
258
275
|
[ header_offset, header ]
|
data/lib/mp3file/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mp3file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Watts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|