id3tag 0.14.2 → 1.1.0

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
  SHA256:
3
- metadata.gz: 8ee2f5e34526388ad61267ade1af0773b4bd85c723b252cc7848a4a692d99281
4
- data.tar.gz: 984577caccfa629dc79ad4b0c49d52a2b7ce08598400084b199e2b4fc1909d8f
3
+ metadata.gz: 071d390948742ea6e37aabbe14326029cf1f61e7e783a282df493ff82d444d05
4
+ data.tar.gz: 74e9674570cb0eecfef7d47f8307f30bdaf9ecbf07563b6e8755009519af53c1
5
5
  SHA512:
6
- metadata.gz: 22617752ac7e06ae319cf97d034c2d358b926252a76957e87899acdace5d130fd9051f43cf769e59e9a3c9d99c52bb417c475c24bcd1c7506a0196d1768d2fb6
7
- data.tar.gz: 6eea548143a08b68522d860ed3f0c8da2ed64590dfd87c7a3a4c7b182799542dfc9396eb8c9578b5686659b5bc013f63eb12b04a928ef771dbf892188051e3ff
6
+ metadata.gz: 22f0aac5137628fcc381f88307d449a3d0870ba8a9fe2ce8acf4101ab367674afbdf3133b5d200669c71c33f2cee86cb7b8dd002b631ca34f9dca894c014f75b
7
+ data.tar.gz: 350be9a1f12bb7098f99a7924bd247e5a41a5f3f42e0a2684f7bb9e2a0342c1ce381b764325197435bb07cbe5c8362de3b3ba6f31b37a0b7a6f61d7f835b13d9
@@ -0,0 +1,48 @@
1
+ module ID3Tag
2
+ module Frames
3
+ module V2
4
+ class ChapterFrame < BasicFrame
5
+ def element_id
6
+ unpacked[:element_id]
7
+ end
8
+
9
+ def start_time
10
+ unpacked[:start_time]
11
+ end
12
+
13
+ def end_time
14
+ unpacked[:end_time]
15
+ end
16
+
17
+ def start_offset
18
+ unpacked[:start_offset]
19
+ end
20
+
21
+ def end_offset
22
+ unpacked[:end_offset]
23
+ end
24
+
25
+ def subframes
26
+ unpacked[:subframes]
27
+ end
28
+
29
+ alias_method :inspectable_content, :element_id
30
+
31
+ private
32
+
33
+ def unpacked
34
+ return @unpacked if defined?(@unpacked)
35
+ @unpacked = {}
36
+ raw_content_io.rewind
37
+ @unpacked[:element_id] = IOUtil.read_until_terminator(raw_content_io, 1)
38
+ @unpacked[:start_time] = raw_content_io.read(4).unpack1("N")
39
+ @unpacked[:end_time] = raw_content_io.read(4).unpack1("N")
40
+ @unpacked[:start_offset] = raw_content_io.read(4).unpack1("N")
41
+ @unpacked[:end_offset] = raw_content_io.read(4).unpack1("N")
42
+ @unpacked[:subframes] = ID3V2FrameParser.new(raw_content_io.read, @major_version_number).frames
43
+ @unpacked
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -24,6 +24,10 @@ module ID3Tag
24
24
  UserTextFrame
25
25
  when /^T/
26
26
  TextFrame
27
+ when /^WXXX$/
28
+ UserUrlFrame
29
+ when /^W/
30
+ UrlFrame
27
31
  when /^(COM|COMM)$/
28
32
  CommentsFrame
29
33
  when /^(ULT|USLT)$/
@@ -36,6 +40,10 @@ module ID3Tag
36
40
  PictureFrame
37
41
  when /^PRIV$/
38
42
  PrivateFrame
43
+ when /^CHAP$/
44
+ ChapterFrame
45
+ when /^CTOC$/
46
+ TableOfContentsFrame
39
47
  else
40
48
  BasicFrame
41
49
  end
@@ -11,7 +11,7 @@ module ID3Tag
11
11
  0x03 => :cover_front, # Cover (front)
12
12
  0x04 => :cover_back, # Cover (back)
13
13
  0x05 => :leaflet_page, # Leaflet page
14
- 0x06 => :media, # Media (e.g. lable side of CD)
14
+ 0x06 => :media, # Media (e.g. label side of CD)
15
15
  0x07 => :lead_artist, # Lead artist/lead performer/soloist
16
16
  0x08 => :artist, # Artist/performer
17
17
  0x09 => :conductor, # Conductor
@@ -0,0 +1,59 @@
1
+ module ID3Tag
2
+ module Frames
3
+ module V2
4
+ class TableOfContentsFrame < BasicFrame
5
+ FLAG_A_TOP_LEVEL_BIT = "00000001".to_i(2)
6
+ FLAG_B_ORDERED_BIT = "00000010".to_i(2)
7
+
8
+ def element_id
9
+ unpacked[:element_id]
10
+ end
11
+
12
+ def top_level?
13
+ unpacked[:flags] & FLAG_A_TOP_LEVEL_BIT > 0
14
+ end
15
+
16
+ def ordered?
17
+ unpacked[:flags] & FLAG_B_ORDERED_BIT > 0
18
+ end
19
+
20
+ def entry_count
21
+ unpacked[:entry_count]
22
+ end
23
+
24
+ def child_element_ids
25
+ unpacked[:child_element_ids]
26
+ end
27
+
28
+ alias_method :content, :child_element_ids
29
+ alias_method :inspectable_content, :content
30
+
31
+ def subframes
32
+ unpacked[:subframes]
33
+ end
34
+
35
+ private
36
+
37
+ def unpacked
38
+ return @unpacked if defined?(@unpacked)
39
+ @unpacked = {}
40
+ raw_content_io.rewind
41
+ @unpacked[:element_id] = IOUtil.read_until_terminator(raw_content_io, 1)
42
+ @unpacked[:flags] = raw_content_io.read(1).unpack1("C")
43
+ @unpacked[:entry_count] = raw_content_io.read(1).unpack1("C")
44
+
45
+ @unpacked[:child_element_ids] = []
46
+ current_entry = 0
47
+ while current_entry < @unpacked[:entry_count]
48
+ @unpacked[:child_element_ids].push(IOUtil.read_until_terminator(raw_content_io, 1))
49
+ current_entry += 1
50
+ end
51
+
52
+ @unpacked[:subframes] = ID3V2FrameParser.new(raw_content_io.read, @major_version_number).frames
53
+
54
+ @unpacked
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -11,7 +11,15 @@ module ID3Tag
11
11
  }
12
12
 
13
13
  def content
14
- @content ||= StringUtil.cut_at_null_byte(encoded_content)
14
+ @content ||= if @major_version_number >= 4
15
+ StringUtil.chomp_null_byte(encoded_content)
16
+ else
17
+ StringUtil.cut_at_null_byte(encoded_content)
18
+ end
19
+ end
20
+
21
+ def contents
22
+ @contents ||= StringUtil.split_by_null_bytes(content)
15
23
  end
16
24
 
17
25
  def inspectable_content
@@ -0,0 +1,14 @@
1
+ module ID3Tag
2
+ module Frames
3
+ module V2
4
+ class UrlFrame < BasicFrame
5
+ def url
6
+ @url ||= StringUtil.cut_at_null_byte(usable_content)
7
+ end
8
+
9
+ alias_method :content, :url
10
+ alias_method :inspectable_content, :content
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ module ID3Tag
2
+ module Frames
3
+ module V2
4
+ class UserUrlFrame < TextFrame
5
+ def description
6
+ @description ||= parts.first
7
+ end
8
+
9
+ def url
10
+ @url ||= parts.last
11
+ end
12
+
13
+ alias_method :content, :url
14
+ alias_method :inspectable_content, :content
15
+
16
+ private
17
+
18
+ def parts
19
+ @parts ||= encoded_content.split(StringUtil::NULL_BYTE, 2)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -40,5 +40,13 @@ module ID3Tag
40
40
  end
41
41
  [before.pack(UTF_8_DIRECTIVE), after.pack(UTF_8_DIRECTIVE)]
42
42
  end
43
+
44
+ def self.split_by_null_bytes(string)
45
+ string.split(NULL_BYTE)
46
+ end
47
+
48
+ def self.chomp_null_byte(string)
49
+ string.chomp(NULL_BYTE)
50
+ end
43
51
  end
44
52
  end
@@ -10,7 +10,7 @@ module ID3Tag
10
10
  current_byte = input_bytes.next
11
11
  output_bytes << current_byte
12
12
  next_byte = input_bytes.peek
13
- if (current_byte == 255) && (next_byte > 224)
13
+ if (current_byte == 255) && ((next_byte >= 224) || (next_byte == 0))
14
14
  output_bytes << 0
15
15
  end
16
16
  end
@@ -20,8 +20,8 @@ module ID3Tag
20
20
  prev_byte = nil
21
21
  loop do
22
22
  current_byte = input_bytes.next
23
- next_byte = input_bytes.peek rescue 0
24
- unless (prev_byte == 255) && (current_byte == 0) && (next_byte > 224)
23
+ next_byte = input_bytes.peek rescue nil
24
+ unless (prev_byte == 255) && (current_byte == 0) && (next_byte != nil) && ((next_byte >= 224) || (next_byte == 0))
25
25
  output_bytes << current_byte
26
26
  end
27
27
  prev_byte = current_byte
@@ -1,3 +1,3 @@
1
1
  module ID3Tag
2
- VERSION = "0.14.2"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/id3tag.rb CHANGED
@@ -23,6 +23,8 @@ require "id3tag/frames/v1/track_nr_frame"
23
23
  require "id3tag/frames/v2/basic_frame"
24
24
  require "id3tag/frames/v2/text_frame"
25
25
  require "id3tag/frames/v2/user_text_frame"
26
+ require "id3tag/frames/v2/url_frame"
27
+ require "id3tag/frames/v2/user_url_frame"
26
28
  require "id3tag/frames/v2/involved_people_list_frame"
27
29
  require "id3tag/frames/v2/unique_file_id_frame"
28
30
  require "id3tag/frames/v2/private_frame"
@@ -30,6 +32,8 @@ require "id3tag/frames/v2/comments_frame"
30
32
  require "id3tag/frames/v2/unsychronized_transcription_frame"
31
33
  require "id3tag/frames/v2/picture_frame"
32
34
  require "id3tag/frames/v2/genre_frame"
35
+ require "id3tag/frames/v2/chapter_frame"
36
+ require "id3tag/frames/v2/table_of_contents_frame"
33
37
  require "id3tag/frames/v2/genre_frame/genre_parser"
34
38
  require "id3tag/frames/v2/genre_frame/genre_parser_pre_24"
35
39
  require "id3tag/frames/v2/genre_frame/genre_parser_24"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: id3tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krists Ozols
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-07 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,6 +131,7 @@ files:
131
131
  - lib/id3tag/frames/v1/text_frame.rb
132
132
  - lib/id3tag/frames/v1/track_nr_frame.rb
133
133
  - lib/id3tag/frames/v2/basic_frame.rb
134
+ - lib/id3tag/frames/v2/chapter_frame.rb
134
135
  - lib/id3tag/frames/v2/comments_frame.rb
135
136
  - lib/id3tag/frames/v2/frame_fabricator.rb
136
137
  - lib/id3tag/frames/v2/frame_flags.rb
@@ -141,10 +142,13 @@ files:
141
142
  - lib/id3tag/frames/v2/involved_people_list_frame.rb
142
143
  - lib/id3tag/frames/v2/picture_frame.rb
143
144
  - lib/id3tag/frames/v2/private_frame.rb
145
+ - lib/id3tag/frames/v2/table_of_contents_frame.rb
144
146
  - lib/id3tag/frames/v2/text_frame.rb
145
147
  - lib/id3tag/frames/v2/unique_file_id_frame.rb
146
148
  - lib/id3tag/frames/v2/unsychronized_transcription_frame.rb
149
+ - lib/id3tag/frames/v2/url_frame.rb
147
150
  - lib/id3tag/frames/v2/user_text_frame.rb
151
+ - lib/id3tag/frames/v2/user_url_frame.rb
148
152
  - lib/id3tag/id3_v1_frame_parser.rb
149
153
  - lib/id3tag/id3_v2_frame_parser.rb
150
154
  - lib/id3tag/id3_v2_tag_header.rb