mp3file 1.1.1 → 1.1.2

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: bdcc2442876710b6da53f59179d328091eced9a5
4
- data.tar.gz: af34504fee2f1e9ace71b702b17dc8e2074d8055
3
+ metadata.gz: da11954d17d2192242abc2017940101590ad797b
4
+ data.tar.gz: 0018b0f2fabb9aa7582722aaf3c8a1985a004479
5
5
  SHA512:
6
- metadata.gz: c51ba93dcbd12cf6565a038be1ba2925717446d53e99bb4615083bb414e50d3fbd1925dbe2ab4e35d4acbd7d99ffc229e7beed2dc11eb10001c5c3e5c37361fd
7
- data.tar.gz: d4c6da6e050d7899d62a0a6db55f577c8f5f0b0b0bae236a3669d7673cc226e639b7dd7d52e0806f4b20ea347f4a0df5fab349a48c86ea9351c76a24cd249b9e
6
+ metadata.gz: a0e6fe9ae807f7981faf6332de40a7791666823bd9d55e94ebf2dbf89e16b3cb60dcefb46d603fe17b81fac974247887b379b4972ad8c76683f00c3c6a766246
7
+ data.tar.gz: f9e290a4928af6d4de7c68e82aa16913513745cc11c4157549289b3534b9b89e5737447d267abee81aacdeb0d3883a27eb5c3ec166f458d2a1cc603f5392d8e1
@@ -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
- end_of_tags = @id3v2_tag.size + @extra_id3v2_tags.map(&:last).map(&:size).reduce(:+).to_i
128
- @file.seek(end_of_tags, IO::SEEK_SET)
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
- @file.seek(end_of_tags, IO::SEEK_SET)
136
- end
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
- if tag
139
- @extra_id3v2_tags << [ end_of_tags, tag ]
140
- retry
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 ]
@@ -1,3 +1,3 @@
1
1
  module Mp3file
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
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.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-17 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec