id3taginator 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.idea/.gitignore +8 -0
- data/.idea/ID3Taginator.iml +73 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.rspec +3 -0
- data/.rubocop.yml +26 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +408 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/id3taginator.gemspec +37 -0
- data/lib/id3taginator/audio_file.rb +136 -0
- data/lib/id3taginator/errors/id3_tag_error.rb +12 -0
- data/lib/id3taginator/extensions/argument_check.rb +88 -0
- data/lib/id3taginator/extensions/comparable.rb +28 -0
- data/lib/id3taginator/extensions/encodable.rb +215 -0
- data/lib/id3taginator/extensions/optionable.rb +73 -0
- data/lib/id3taginator/frames/buffer/entities/buffer.rb +26 -0
- data/lib/id3taginator/frames/buffer/rbuf_recommended_buffer_size_frame.rb +59 -0
- data/lib/id3taginator/frames/buffer_frames.rb +32 -0
- data/lib/id3taginator/frames/comment/comm_comment_frame.rb +56 -0
- data/lib/id3taginator/frames/comment/entities/comment.rb +26 -0
- data/lib/id3taginator/frames/comment_frames.rb +42 -0
- data/lib/id3taginator/frames/count/entities/popularimeter.rb +26 -0
- data/lib/id3taginator/frames/count/pcnt_play_counter_frame.rb +40 -0
- data/lib/id3taginator/frames/count/popm_popularimeter_frame.rb +52 -0
- data/lib/id3taginator/frames/count_frames.rb +51 -0
- data/lib/id3taginator/frames/custom_frame.rb +39 -0
- data/lib/id3taginator/frames/custom_frames.rb +54 -0
- data/lib/id3taginator/frames/encryption/aenc_audio_encryption.rb +54 -0
- data/lib/id3taginator/frames/encryption/encr_encryption_method_frame.rb +49 -0
- data/lib/id3taginator/frames/encryption/entities/audio_encryption.rb +28 -0
- data/lib/id3taginator/frames/encryption/entities/encryption_method.rb +26 -0
- data/lib/id3taginator/frames/encryption_frames.rb +77 -0
- data/lib/id3taginator/frames/frameable.rb +75 -0
- data/lib/id3taginator/frames/geo/entities/encapsulated_object.rb +28 -0
- data/lib/id3taginator/frames/geo/geob_general_encapsulated_object_frame.rb +59 -0
- data/lib/id3taginator/frames/geo_frames.rb +41 -0
- data/lib/id3taginator/frames/grouping/entities/group_identification.rb +26 -0
- data/lib/id3taginator/frames/grouping/grid_group_identification_frame.rb +49 -0
- data/lib/id3taginator/frames/grouping/grp1_grouping_frame.rb +40 -0
- data/lib/id3taginator/frames/grouping_frames.rb +61 -0
- data/lib/id3taginator/frames/has_id.rb +51 -0
- data/lib/id3taginator/frames/id3v23_frame_flags.rb +64 -0
- data/lib/id3taginator/frames/id3v24_frame_flags.rb +80 -0
- data/lib/id3taginator/frames/id3v2_frame.rb +249 -0
- data/lib/id3taginator/frames/id3v2_frame_factory.rb +98 -0
- data/lib/id3taginator/frames/ipl/entities/involved_person.rb +24 -0
- data/lib/id3taginator/frames/ipl/ipls_involved_people_frame.rb +48 -0
- data/lib/id3taginator/frames/ipl_frames.rb +31 -0
- data/lib/id3taginator/frames/lyrics/entities/unsync_lyrics.rb +26 -0
- data/lib/id3taginator/frames/lyrics/uslt_unsync_lyrics_frame.rb +56 -0
- data/lib/id3taginator/frames/lyrics_frames.rb +42 -0
- data/lib/id3taginator/frames/mcdi/mcdi_music_cd_identifier_frame.rb +40 -0
- data/lib/id3taginator/frames/mcdi_frames.rb +28 -0
- data/lib/id3taginator/frames/picture/apic_picture_frame.rb +106 -0
- data/lib/id3taginator/frames/picture/entities/picture.rb +32 -0
- data/lib/id3taginator/frames/picture_frames.rb +51 -0
- data/lib/id3taginator/frames/private/entities/private_frame.rb +24 -0
- data/lib/id3taginator/frames/private/priv_private_frame.rb +45 -0
- data/lib/id3taginator/frames/private_frames.rb +40 -0
- data/lib/id3taginator/frames/text/entities/copyright.rb +24 -0
- data/lib/id3taginator/frames/text/entities/date.rb +24 -0
- data/lib/id3taginator/frames/text/entities/part_of_set.rb +24 -0
- data/lib/id3taginator/frames/text/entities/time.rb +24 -0
- data/lib/id3taginator/frames/text/entities/track_number.rb +24 -0
- data/lib/id3taginator/frames/text/entities/user_info.rb +24 -0
- data/lib/id3taginator/frames/text/talb_album_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tbpm_bpm_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tcom_composer_frame.rb +42 -0
- data/lib/id3taginator/frames/text/tcon_genre_frame.rb +104 -0
- data/lib/id3taginator/frames/text/tcop_copyright_frame.rb +55 -0
- data/lib/id3taginator/frames/text/tdat_date_frame.rb +60 -0
- data/lib/id3taginator/frames/text/tdly_playlist_delay_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tenc_encoded_by_frame.rb +40 -0
- data/lib/id3taginator/frames/text/text_writers_frame.rb +43 -0
- data/lib/id3taginator/frames/text/tflt_file_type_frame.rb +71 -0
- data/lib/id3taginator/frames/text/time_time_frame.rb +60 -0
- data/lib/id3taginator/frames/text/tit1_content_group_description_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tit2_title_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tit3_subtitle_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tkey_initial_key_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tlan_language_frame.rb +48 -0
- data/lib/id3taginator/frames/text/tlen_length_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tmed_media_type_frame.rb +40 -0
- data/lib/id3taginator/frames/text/toal_original_album_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tofn_original_filename_frame.rb +40 -0
- data/lib/id3taginator/frames/text/toly_original_writers_frame.rb +43 -0
- data/lib/id3taginator/frames/text/tope_original_artists_frame.rb +43 -0
- data/lib/id3taginator/frames/text/tory_original_release_year_frame.rb +42 -0
- data/lib/id3taginator/frames/text/town_file_owner_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tpe1_artist_frame.rb +43 -0
- data/lib/id3taginator/frames/text/tpe2_album_artist_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tpe3_conductor_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tpe4_modified_by_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tpos_part_of_set_frame.rb +50 -0
- data/lib/id3taginator/frames/text/tpub_publisher_frame.rb +40 -0
- data/lib/id3taginator/frames/text/trck_track_number_frame.rb +50 -0
- data/lib/id3taginator/frames/text/trda_recording_dates_frame.rb +42 -0
- data/lib/id3taginator/frames/text/trsn_internet_radio_station_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tsiz_size_frame.rb +41 -0
- data/lib/id3taginator/frames/text/tsoa_album_sort_order_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tsop_performer_sort_order_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tsot_title_sort_order_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tsrc_isrc_frame.rb +40 -0
- data/lib/id3taginator/frames/text/tsse_encoder_frame.rb +40 -0
- data/lib/id3taginator/frames/text/txxx_user_text_info_frame.rb +51 -0
- data/lib/id3taginator/frames/text/tyer_year_frame.rb +42 -0
- data/lib/id3taginator/frames/text_frames.rb +840 -0
- data/lib/id3taginator/frames/tos/entities/ownership.rb +26 -0
- data/lib/id3taginator/frames/tos/entities/terms_of_use.rb +24 -0
- data/lib/id3taginator/frames/tos/owne_ownership_frame.rb +53 -0
- data/lib/id3taginator/frames/tos/user_terms_of_use_frame.rb +49 -0
- data/lib/id3taginator/frames/tos_frames.rb +54 -0
- data/lib/id3taginator/frames/ufid/entities/ufid_info.rb +24 -0
- data/lib/id3taginator/frames/ufid/ufid_unique_file_identifier_frame.rb +47 -0
- data/lib/id3taginator/frames/ufid_frames.rb +40 -0
- data/lib/id3taginator/frames/url/entities/user_info.rb +24 -0
- data/lib/id3taginator/frames/url/wcom_commercial_url_frame.rb +40 -0
- data/lib/id3taginator/frames/url/wcop_copyright_url_frame.rb +40 -0
- data/lib/id3taginator/frames/url/woaf_official_file_webpage_frame.rb +40 -0
- data/lib/id3taginator/frames/url/woar_official_artist_webpage_frame.rb +40 -0
- data/lib/id3taginator/frames/url/woas_official_source_webpage_frame.rb +40 -0
- data/lib/id3taginator/frames/url/wors_official_radio_station_homepage_frame.rb +40 -0
- data/lib/id3taginator/frames/url/wpay_payment_url_frame.rb +40 -0
- data/lib/id3taginator/frames/url/wpub_official_publisher_webpage_frame.rb +40 -0
- data/lib/id3taginator/frames/url/wxxx_user_url_link_frame.rb +50 -0
- data/lib/id3taginator/frames/url_frames.rb +195 -0
- data/lib/id3taginator/genres.rb +168 -0
- data/lib/id3taginator/header/id3v23_extended_header.rb +37 -0
- data/lib/id3taginator/header/id3v24_extended_header.rb +100 -0
- data/lib/id3taginator/header/id3v2_flags.rb +64 -0
- data/lib/id3taginator/id3v1_tag.rb +156 -0
- data/lib/id3taginator/id3v22_tag.rb +30 -0
- data/lib/id3taginator/id3v23_tag.rb +63 -0
- data/lib/id3taginator/id3v24_tag.rb +75 -0
- data/lib/id3taginator/id3v2_tag.rb +241 -0
- data/lib/id3taginator/options/options.rb +33 -0
- data/lib/id3taginator/util/compress_util.rb +25 -0
- data/lib/id3taginator/util/math_util.rb +68 -0
- data/lib/id3taginator/util/sync_util.rb +65 -0
- data/lib/id3taginator.rb +449 -0
- metadata +198 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class ArtistsFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TP1, :TPE1, :TPE1
|
10
|
+
|
11
|
+
attr_accessor :artists
|
12
|
+
|
13
|
+
# builds the artists frame
|
14
|
+
#
|
15
|
+
# @param artists [Array<String>, String] the artist(s)
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(artists, options = nil, id3_version: 3)
|
21
|
+
supported?('TPE1', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_empty(artists, 'artists')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.artists = artists.is_a?(Array) ? artists : [artists]
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
artists_str = decode_using_encoding_byte(content)
|
32
|
+
@artists = artists_str.split('/').map(&:strip)
|
33
|
+
end
|
34
|
+
|
35
|
+
def content_to_bytes
|
36
|
+
@artists ||= ['[unset]']
|
37
|
+
content = @artists.join('/')
|
38
|
+
encode_and_add_encoding_byte(content)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class AlbumArtistFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TP2, :TPE2, :TPE2
|
10
|
+
|
11
|
+
attr_accessor :album_artist
|
12
|
+
|
13
|
+
# builds the album artist frame
|
14
|
+
#
|
15
|
+
# @param album_artist [String] the album artist
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(album_artist, options = nil, id3_version: 3)
|
21
|
+
supported?('TPE2', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(album_artist, 'album_artist')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.album_artist = album_artist
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@album_artist = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@album_artist)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class ConductorFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TP3, :TPE3, :TPE3
|
10
|
+
|
11
|
+
attr_accessor :conductor
|
12
|
+
|
13
|
+
# builds the conductor frame
|
14
|
+
#
|
15
|
+
# @param conductor [String] the conductor
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(conductor, options = nil, id3_version: 3)
|
21
|
+
supported?('TPE3', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(conductor, 'conductor')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.conductor = conductor
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@conductor = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@conductor)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class ModifiedByFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TP4, :TPE4, :TPE4
|
10
|
+
|
11
|
+
attr_accessor :modified_by
|
12
|
+
|
13
|
+
# builds the modified by frame
|
14
|
+
#
|
15
|
+
# @param modified_by [String] the modified by
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(modified_by, options = nil, id3_version: 3)
|
21
|
+
supported?('TPE4', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(modified_by, 'modified_by')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.modified_by = modified_by
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@modified_by = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@modified_by)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class PartOfSetFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TPA, :TPOS, :TPOS
|
10
|
+
|
11
|
+
attr_accessor :part, :total
|
12
|
+
|
13
|
+
# builds the part of set frame
|
14
|
+
#
|
15
|
+
# @param part [String, Integer] part of the set
|
16
|
+
# @param total [String, Integer, nil] total number of parts
|
17
|
+
# @param options [Options::Options] options to use
|
18
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
19
|
+
#
|
20
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
21
|
+
def self.build_frame(part, total, options = nil, id3_version: 3)
|
22
|
+
supported?('TPOS', id3_version, options)
|
23
|
+
|
24
|
+
argument_not_nil(part, 'part')
|
25
|
+
|
26
|
+
part = part.to_s
|
27
|
+
total = total.to_s unless total.nil?
|
28
|
+
|
29
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
30
|
+
frame.part = part
|
31
|
+
frame.total = total
|
32
|
+
frame
|
33
|
+
end
|
34
|
+
|
35
|
+
def process_content(content)
|
36
|
+
content = decode_using_encoding_byte(content)
|
37
|
+
tmp = content.split('/')
|
38
|
+
@part = tmp[0]
|
39
|
+
@total = tmp[1]
|
40
|
+
end
|
41
|
+
|
42
|
+
def content_to_bytes
|
43
|
+
return encode_and_add_encoding_byte(@part) if @total.nil?
|
44
|
+
|
45
|
+
encode_and_add_encoding_byte("#{@part}/#{@total}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class PublisherFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TPB, :TPUB, :TPUB
|
10
|
+
|
11
|
+
attr_accessor :publisher
|
12
|
+
|
13
|
+
# builds the publisher frame
|
14
|
+
#
|
15
|
+
# @param publisher [String] the publisher
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(publisher, options = nil, id3_version: 3)
|
21
|
+
supported?('TPUB', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_empty(publisher, 'publisher')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.publisher = publisher
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@publisher = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@publisher)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class TrackNumberFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TRK, :TRCK, :TRCK
|
10
|
+
|
11
|
+
attr_accessor :track_number, :total
|
12
|
+
|
13
|
+
# builds the track number frame
|
14
|
+
#
|
15
|
+
# @param track_number [String, Integer] the track number
|
16
|
+
# @param total [String, Integer, nil] the total number of tracks
|
17
|
+
# @param options [Options::Options] options to use
|
18
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
19
|
+
#
|
20
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
21
|
+
def self.build_frame(track_number, total, options = nil, id3_version: 3)
|
22
|
+
supported?('TRCK', id3_version, options)
|
23
|
+
|
24
|
+
argument_not_empty(track_number, 'track_number')
|
25
|
+
|
26
|
+
track_number = track_number.to_s
|
27
|
+
total = total.to_s unless total.nil?
|
28
|
+
|
29
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
30
|
+
frame.track_number = track_number
|
31
|
+
frame.total = total
|
32
|
+
frame
|
33
|
+
end
|
34
|
+
|
35
|
+
def process_content(content)
|
36
|
+
content = decode_using_encoding_byte(content)
|
37
|
+
tmp = content.split('/')
|
38
|
+
@track_number = tmp[0]
|
39
|
+
@total = tmp[1]
|
40
|
+
end
|
41
|
+
|
42
|
+
def content_to_bytes
|
43
|
+
return encode_and_add_encoding_byte(@track_number) if @total.nil?
|
44
|
+
|
45
|
+
encode_and_add_encoding_byte("#{@track_number}/#{@total}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class RecordingDatesFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TRD, :TRDA, :TRDA
|
10
|
+
|
11
|
+
attr_accessor :recording_dates
|
12
|
+
|
13
|
+
# builds the recording dates frame
|
14
|
+
#
|
15
|
+
# @param recording_dates [Array<String>, String] the recording date(s)
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(recording_dates, options = nil, id3_version: 3)
|
21
|
+
supported?('TRDA', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_empty(recording_dates, 'recording_dates')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.recording_dates = recording_dates.is_a?(Array) ? recording_dates : [recording_dates]
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
content = decode_using_encoding_byte(content)
|
32
|
+
@recording_dates = content.split(',').map(&:strip)
|
33
|
+
end
|
34
|
+
|
35
|
+
def content_to_bytes
|
36
|
+
content = @recording_dates.join(', ')
|
37
|
+
encode_and_add_encoding_byte(content)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class InternetRadioStationFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info nil, :TRSN, :TRSN
|
10
|
+
|
11
|
+
attr_accessor :station_name
|
12
|
+
|
13
|
+
# builds the radio station frame
|
14
|
+
#
|
15
|
+
# @param station_name [String] the recording date(s)
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(station_name, options = nil, id3_version: 3)
|
21
|
+
supported?('TRSN', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(station_name, 'station_name')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.station_name = station_name
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@station_name = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@station_name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class SizeFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TSI, :TSIZ, nil
|
10
|
+
|
11
|
+
attr_accessor :size
|
12
|
+
|
13
|
+
# builds the size frame
|
14
|
+
#
|
15
|
+
# @param size [String, Integer] the size in bytes
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(size, options = nil, id3_version: 3)
|
21
|
+
supported?('TSIZ', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(size, 'size')
|
24
|
+
size = size.to_s
|
25
|
+
|
26
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
27
|
+
frame.size = size
|
28
|
+
frame
|
29
|
+
end
|
30
|
+
|
31
|
+
def process_content(content)
|
32
|
+
@size = decode_using_encoding_byte(content)
|
33
|
+
end
|
34
|
+
|
35
|
+
def content_to_bytes
|
36
|
+
encode_and_add_encoding_byte(@size)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class AlbumSortOrderFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info nil, nil, :TSOA
|
10
|
+
|
11
|
+
attr_accessor :album
|
12
|
+
|
13
|
+
# builds the album sort order frame
|
14
|
+
#
|
15
|
+
# @param album [String] the album name to use for sorting
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(album, options = nil, id3_version: 3)
|
21
|
+
supported?('TSOA', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(album, 'album')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.album = album
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@album = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@album)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class PerformerSortOrderFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info nil, nil, :TSOP
|
10
|
+
|
11
|
+
attr_accessor :performer
|
12
|
+
|
13
|
+
# builds the performer sort order frame
|
14
|
+
#
|
15
|
+
# @param performer [String] the performer to use for sorting
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(performer, options = nil, id3_version: 3)
|
21
|
+
supported?('TSOP', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(performer, 'performer')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.performer = performer
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@performer = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@performer)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class TitleSortOrderFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info nil, nil, :TSOT
|
10
|
+
|
11
|
+
attr_accessor :title
|
12
|
+
|
13
|
+
# builds the title sort order frame
|
14
|
+
#
|
15
|
+
# @param title [String] the title to use for sorting
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(title, options = nil, id3_version: 3)
|
21
|
+
supported?('TSOT', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(title, 'title')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.title = title
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@title = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@title)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class ISRCFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TRC, :TSRC, :TSRC
|
10
|
+
|
11
|
+
attr_accessor :isrc
|
12
|
+
|
13
|
+
# builds the ISRC frame
|
14
|
+
#
|
15
|
+
# @param isrc [String] the ISRC number, 12 characters long
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(isrc, options = nil, id3_version: 3)
|
21
|
+
supported?('TSRC', id3_version, options)
|
22
|
+
|
23
|
+
argument_exactly_chars(isrc, 'isrc', 12)
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.isrc = isrc
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@isrc = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@isrc)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class EncoderFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TSS, :TSSE, :TSSE
|
10
|
+
|
11
|
+
attr_accessor :encoder
|
12
|
+
|
13
|
+
# builds the encoder frame
|
14
|
+
#
|
15
|
+
# @param encoder [String] the ISRC number, 12 characters long
|
16
|
+
# @param options [Options::Options] options to use
|
17
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
18
|
+
#
|
19
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
20
|
+
def self.build_frame(encoder, options = nil, id3_version: 3)
|
21
|
+
supported?('TSSE', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(encoder, 'encoder')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.encoder = encoder
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@encoder = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@encoder)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class UserTextInfoFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TXX, :TXXX, :TXXX
|
10
|
+
|
11
|
+
attr_accessor :description, :content
|
12
|
+
|
13
|
+
# builds the user text info frame
|
14
|
+
#
|
15
|
+
# @param description [String] the description
|
16
|
+
# @param content [String] the content
|
17
|
+
# @param options [Options::Options] options to use
|
18
|
+
# @param id3_version [Integer] the id3 version to build the frame for
|
19
|
+
#
|
20
|
+
# @return [Id3v2Frame] the resulting id3v2 frame
|
21
|
+
def self.build_frame(description, content, options = nil, id3_version: 3)
|
22
|
+
supported?('TXXX', id3_version, options)
|
23
|
+
|
24
|
+
argument_not_nil(description, 'description')
|
25
|
+
argument_not_nil(content, 'content')
|
26
|
+
|
27
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
28
|
+
frame.description = description
|
29
|
+
frame.content = content
|
30
|
+
frame
|
31
|
+
end
|
32
|
+
|
33
|
+
def process_content(content)
|
34
|
+
content_io = StringIO.new(content)
|
35
|
+
encoding = find_encoding(content_io.getbyte)
|
36
|
+
|
37
|
+
encoded_description = read_stream_until(content_io, zero_byte(encoding))
|
38
|
+
encoded_content = content_io.read
|
39
|
+
@description = decode(encoded_description, encoding)
|
40
|
+
@content = decode(encoded_content, encoding)
|
41
|
+
end
|
42
|
+
|
43
|
+
def content_to_bytes
|
44
|
+
encoded_description = encode(@description, null_terminated: true)
|
45
|
+
encoded_content = encode(@content)
|
46
|
+
merge(default_encoding_destination_byte, encoded_description, encoded_content)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|