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,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class FileTypeFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TFT, :TFLT, :TFLT
|
10
|
+
|
11
|
+
attr_accessor :file_type
|
12
|
+
|
13
|
+
# builds the writers frame
|
14
|
+
#
|
15
|
+
# @param file_type [Symbol, String] the file type, all FileTypes are in Text::FileTypes
|
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(file_type = :MPEG_1_2_LAYER_III, options = nil, id3_version: 3)
|
21
|
+
supported?('TFLT', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(file_type, 'file_type')
|
24
|
+
|
25
|
+
raise ArgumentError, "File_type isn't valid: #{file_type}" unless FileTypes.valid?(file_type)
|
26
|
+
|
27
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
28
|
+
frame.file_type = file_type
|
29
|
+
frame
|
30
|
+
end
|
31
|
+
|
32
|
+
def process_content(content)
|
33
|
+
@file_type = FileTypes.type_by_value(decode_using_encoding_byte(content))
|
34
|
+
end
|
35
|
+
|
36
|
+
def content_to_bytes
|
37
|
+
content = FileTypes.type(@file_type)
|
38
|
+
encode_and_add_encoding_byte(content)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module FileTypes
|
43
|
+
MPEG_AUDIO = 'MPG'
|
44
|
+
MPEG_1_2_LAYER_I = '/1'
|
45
|
+
MPEG_1_2_LAYER_II = '/2'
|
46
|
+
MPEG_1_2_LAYER_III = '/3'
|
47
|
+
MPEG_2_5 = '/2.5'
|
48
|
+
AAC = '/AAC'
|
49
|
+
VQF = 'VQF'
|
50
|
+
PCM = 'PCM'
|
51
|
+
|
52
|
+
def self.type(type)
|
53
|
+
return MPEG_1_2_LAYER_III unless valid?(type)
|
54
|
+
|
55
|
+
const_get(type)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.type_by_value(value)
|
59
|
+
res = constants.find { |c| const_get(c) == value }
|
60
|
+
res.nil? ? :MPEG_1_2_LAYER_III : res
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.valid?(type)
|
64
|
+
const_get(type)
|
65
|
+
rescue NameError
|
66
|
+
false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class TimeFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TIM, :TIME, :TIME
|
10
|
+
|
11
|
+
attr_accessor :hours, :minutes
|
12
|
+
|
13
|
+
# builds the time frame
|
14
|
+
#
|
15
|
+
# @param hours [String, Integer] the hours
|
16
|
+
# @param minutes [String, Integer] the minutes
|
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(hours, minutes, options = nil, id3_version: 3)
|
22
|
+
supported?('TIME', id3_version, options)
|
23
|
+
|
24
|
+
argument_not_nil(hours, 'hours')
|
25
|
+
argument_not_nil(minutes, 'minutes')
|
26
|
+
hours = pad_right(hours.to_s, 2)
|
27
|
+
minutes = pad_right(minutes.to_s, 2)
|
28
|
+
argument_less_than_chars(hours, 'hours', 2)
|
29
|
+
argument_less_than_chars(minutes, 'minutes', 2)
|
30
|
+
|
31
|
+
hours = pad_right(hours, 2, '0')
|
32
|
+
minutes = pad_right(minutes, 2, '0')
|
33
|
+
|
34
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
35
|
+
frame.hours = hours
|
36
|
+
frame.minutes = minutes
|
37
|
+
frame
|
38
|
+
end
|
39
|
+
|
40
|
+
def process_content(content)
|
41
|
+
content = decode_using_encoding_byte(content)
|
42
|
+
if content.length != 4
|
43
|
+
@hours = '0'
|
44
|
+
@minutes = '0'
|
45
|
+
else
|
46
|
+
@hours = content[0..1]
|
47
|
+
@minutes = content[2..3]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def content_to_bytes
|
52
|
+
@hours ||= '0'
|
53
|
+
@minutes ||= '0'
|
54
|
+
content = "#{pad_right(@hours.to_s, 2, '0')}#{pad_right(@minutes.to_s, 2, '0')}"
|
55
|
+
encode_and_add_encoding_byte(content)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class ContentGroupDescriptionFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TT1, :TIT1, :TIT1
|
10
|
+
|
11
|
+
attr_accessor :content_description
|
12
|
+
|
13
|
+
# builds the content group description frame
|
14
|
+
#
|
15
|
+
# @param content_description [String] the content group description
|
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(content_description, options = nil, id3_version: 3)
|
21
|
+
supported?('TIT1', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(content_description, 'content_description')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.content_description = content_description
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@content_description = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@content_description)
|
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 TitleFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TT2, :TIT2, :TIT2
|
10
|
+
|
11
|
+
attr_accessor :title
|
12
|
+
|
13
|
+
# builds the title frame
|
14
|
+
#
|
15
|
+
# @param title [String] the title
|
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?('TIT2', 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 SubtitleFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TT3, :TIT3, :TIT3
|
10
|
+
|
11
|
+
attr_accessor :subtitle
|
12
|
+
|
13
|
+
# builds the subtitle frame
|
14
|
+
#
|
15
|
+
# @param subtitle [String] the subtitle
|
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(subtitle, options = nil, id3_version: 3)
|
21
|
+
supported?('TIT3', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(subtitle, 'subtitle')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.subtitle = subtitle
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@subtitle = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@subtitle)
|
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 InitialKeyFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TKE, :TKEY, :TKEY
|
10
|
+
|
11
|
+
attr_accessor :initial_key
|
12
|
+
|
13
|
+
# builds the initial key frame
|
14
|
+
#
|
15
|
+
# @param initial_key [String] the initial key, can have up to 3 characters
|
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(initial_key, options = nil, id3_version: 3)
|
21
|
+
supported?('TKEY', id3_version, options)
|
22
|
+
|
23
|
+
argument_less_than_chars(initial_key, 'initial_key', 3)
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.initial_key = initial_key
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@initial_key = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@initial_key)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class LanguageFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TLA, :TLAN, :TLAN
|
10
|
+
|
11
|
+
attr_accessor :languages
|
12
|
+
|
13
|
+
# builds the language frame
|
14
|
+
#
|
15
|
+
# @param languages [Array<String>, String] the 3 character language(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(languages, options = nil, id3_version: 3)
|
21
|
+
supported?('TLAN', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_empty(languages, 'languages')
|
24
|
+
|
25
|
+
langs = languages.is_a?(Array) ? languages : [languages]
|
26
|
+
|
27
|
+
raise ArgumentError, 'Languages should be 3 characters, ISO-639-2.' if langs.any? { |l| l.length != 3 }
|
28
|
+
|
29
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
30
|
+
frame.languages = langs
|
31
|
+
frame
|
32
|
+
end
|
33
|
+
|
34
|
+
def process_content(content)
|
35
|
+
languages_str = decode_using_encoding_byte(content)
|
36
|
+
@languages = languages_str.split("\x00").map(&:strip)
|
37
|
+
end
|
38
|
+
|
39
|
+
def content_to_bytes
|
40
|
+
@languages ||= ['und']
|
41
|
+
content = @languages.join("\x00")
|
42
|
+
content += "\x00" if @languages.length > 1
|
43
|
+
encode_and_add_encoding_byte(content)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class LengthFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TLE, :TLEN, :TLEN
|
10
|
+
|
11
|
+
attr_accessor :length
|
12
|
+
|
13
|
+
# builds the length frame
|
14
|
+
#
|
15
|
+
# @param length [String, Integer] the length in ms
|
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(length, options = nil, id3_version: 3)
|
21
|
+
supported?('TLEN', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(length, 'length')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.length = length.to_s
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@length = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@length)
|
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 MediaTypeFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TMT, :TMED, :TMED
|
10
|
+
|
11
|
+
attr_accessor :media_type
|
12
|
+
|
13
|
+
# builds the media type frame
|
14
|
+
#
|
15
|
+
# @param media_type [String] the media type
|
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(media_type, options = nil, id3_version: 3)
|
21
|
+
supported?('TMED', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(media_type, 'media_type')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.media_type = media_type
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@media_type = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@media_type)
|
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 OriginalAlbumFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TOT, :TOAL, :TOAL
|
10
|
+
|
11
|
+
attr_accessor :original_album
|
12
|
+
|
13
|
+
# builds the original album frame
|
14
|
+
#
|
15
|
+
# @param original_album [String] the original album
|
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(original_album, options = nil, id3_version: 3)
|
21
|
+
supported?('TOAL', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(original_album, 'original_album')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.original_album = original_album
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@original_album = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@original_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 OriginalFilenameFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TOF, :TOFN, :TOFN
|
10
|
+
|
11
|
+
attr_accessor :original_filename
|
12
|
+
|
13
|
+
# builds the original filename frame
|
14
|
+
#
|
15
|
+
# @param original_filename [String] the original filename
|
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(original_filename, options = nil, id3_version: 3)
|
21
|
+
supported?('TOFN', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(original_filename, 'original_filename')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.original_filename = original_filename
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@original_filename = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@original_filename)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class OriginalWritersFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TOL, :TOLY, :TOLY
|
10
|
+
|
11
|
+
attr_accessor :original_writers
|
12
|
+
|
13
|
+
# builds the original writers frame
|
14
|
+
#
|
15
|
+
# @param original_writers [Array<String>, String] the original writer(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(original_writers, options = nil, id3_version: 3)
|
21
|
+
supported?('TOLY', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_empty(original_writers, 'original_writers')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.original_writers = original_writers.is_a?(Array) ? original_writers : [original_writers]
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
writers_str = decode_using_encoding_byte(content)
|
32
|
+
@original_writers = writers_str.split('/').map(&:strip)
|
33
|
+
end
|
34
|
+
|
35
|
+
def content_to_bytes
|
36
|
+
@original_writers ||= ['[unset]']
|
37
|
+
content = @original_writers.join('/')
|
38
|
+
encode_and_add_encoding_byte(content)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class OriginalArtistsFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TOA, :TOPE, :TOPE
|
10
|
+
|
11
|
+
attr_accessor :original_artists
|
12
|
+
|
13
|
+
# builds the original artists frame
|
14
|
+
#
|
15
|
+
# @param original_artists [Array<String>, String] the original 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(original_artists, options = nil, id3_version: 3)
|
21
|
+
supported?('TOPE', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_empty(original_artists, 'original_artists')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.original_artists = original_artists.is_a?(Array) ? original_artists : [original_artists]
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
artists_str = decode_using_encoding_byte(content)
|
32
|
+
@original_artists = artists_str.split('/').map(&:strip)
|
33
|
+
end
|
34
|
+
|
35
|
+
def content_to_bytes
|
36
|
+
@original_artists ||= ['[unset]']
|
37
|
+
content = @original_artists.join('/')
|
38
|
+
encode_and_add_encoding_byte(content)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Id3Taginator
|
4
|
+
module Frames
|
5
|
+
module Text
|
6
|
+
class OriginalReleaseYearFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info :TOR, :TORY, :TORY
|
10
|
+
|
11
|
+
attr_accessor :original_release_year
|
12
|
+
|
13
|
+
# builds the original release year frame
|
14
|
+
#
|
15
|
+
# @param original_release_year [String, Integer] the original release year as a 4 character string, e.g. 2020
|
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(original_release_year, options = nil, id3_version: 3)
|
21
|
+
supported?('TORY', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(original_release_year, 'original_release_year')
|
24
|
+
original_release_year = original_release_year.to_s
|
25
|
+
argument_exactly_chars(original_release_year, 'original_release_year', 4)
|
26
|
+
|
27
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
28
|
+
frame.original_release_year = original_release_year
|
29
|
+
frame
|
30
|
+
end
|
31
|
+
|
32
|
+
def process_content(content)
|
33
|
+
@original_release_year = decode_using_encoding_byte(content)
|
34
|
+
end
|
35
|
+
|
36
|
+
def content_to_bytes
|
37
|
+
encode_and_add_encoding_byte(@original_release_year)
|
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 FileOwnerFrame < Id3v2Frame
|
7
|
+
include HasId
|
8
|
+
|
9
|
+
frame_info nil, :TOWN, :TOWN
|
10
|
+
|
11
|
+
attr_accessor :file_owner
|
12
|
+
|
13
|
+
# builds the file owner frame
|
14
|
+
#
|
15
|
+
# @param file_owner [String] the file owner
|
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(file_owner, options = nil, id3_version: 3)
|
21
|
+
supported?('TOWN', id3_version, options)
|
22
|
+
|
23
|
+
argument_not_nil(file_owner, 'file_owner')
|
24
|
+
|
25
|
+
frame = new(frame_id(id3_version, options), 0, build_id3_flags(id3_version), '')
|
26
|
+
frame.file_owner = file_owner
|
27
|
+
frame
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_content(content)
|
31
|
+
@file_owner = decode_using_encoding_byte(content)
|
32
|
+
end
|
33
|
+
|
34
|
+
def content_to_bytes
|
35
|
+
encode_and_add_encoding_byte(@file_owner)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|