Module: EasyTag::Attributes

Defined in:
lib/easytag/attributes/mp3.rb,
lib/easytag/attributes/mp3.rb,
lib/easytag/attributes/mp4.rb,
lib/easytag/attributes/mp4.rb,
lib/easytag/attributes/base.rb

Defined Under Namespace

Modules: ItemType, Type Classes: BaseAttribute, MP3Attribute, MP4Attribute

Constant Summary collapse

MP3_ATTRIB_ARGS =
[
# title
{
  :name         => :title,
  :id3v2_frames => ['TIT2'],
  :id3v1_tag    => :title,
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# title_sort_order
#   TSOT - (v2.4 only)
#   XSOT - Musicbrainz Picard custom
{
  :name         => :title_sort_order,
  :id3v2_frames => ['TSOT', 'XSOT'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# subtitle
{
  :name         => :subtitle,
  :id3v2_frames => ['TIT3'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# artist
{
  :name         => :artist,
  :id3v2_frames => ['TPE1'],
  :id3v1_tag    => :artist,
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# artist_sort_order
#   TSOP - (v2.4 only)
#   XSOP - Musicbrainz Picard custom
{
  :name         => :artist_sort_order,
  :id3v2_frames => ['TSOP', 'XSOP'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# album_artist
{
  :name         => :album_artist,
  :id3v2_frames => ['TPE2'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# album_artist_sort_order
{
  :name         => :album_artist_sort_order,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :albumartistsort},
  :type         => Type::STRING,
},

# album
{
  :name         => :album,
  :id3v2_frames => ['TALB'],
  :id3v1_tag    => :album,
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# compilation?
{
  :name         => :compilation?,
  :id3v2_frames => ['TCMP'],
  :handler      => :read_first_id3,
  :type         => Type::BOOLEAN,
  # TODO: remove is_flag option, determine boolean value implicitly 
  :options      => {:is_flag => true},
},

# album_sort_order
#   TSOA - (v2.4 only)
#   XSOA - Musicbrainz Picard custom
{
  :name         => :album_sort_order,
  :id3v2_frames => ['TSOA', 'XSOA'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# genre
{
  :name         => :genre,
  :id3v2_frames => ['TCON'],
  :id3v1_tag    => :genre,
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# disc_subtitle
{
  :name         => :disc_subtitle,
  :id3v2_frames => ['TSST'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# media
{
  :name         => :media,
  :id3v2_frames => ['TMED'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# label
{
  :name         => :label,
  :id3v2_frames => ['TPUB'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# encoded_by
{
  :name         => :encoded_by,
  :id3v2_frames => ['TENC'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# encoder_settings
{
  :name         => :encoder_settings,
  :id3v2_frames => ['TSSE'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# group
{
  :name         => :group,
  :id3v2_frames => ['TIT1'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# composer
{
  :name         => :composer,
  :id3v2_frames => ['TCOM'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# conductor
{
  :name         => :conductor,
  :id3v2_frames => ['TPE3'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# remixer
{
  :name         => :remixer,
  :id3v2_frames => ['TPE4'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# lyrics
{
  :name         => :lyrics,
  :id3v2_frames => ['USLT'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# lyricist
{
  :name         => :lyricist,
  :id3v2_frames => ['TEXT'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# copyright
{
  :name         => :copyright,
  :id3v2_frames => ['TCOP'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# bpm
{
  :name         => :bpm,
  :id3v2_frames => ['TBPM'],
  :handler      => :read_first_id3,
  :type         => Type::INT,
},

# mood
{
  :name         => :mood,
  :id3v2_frames => ['TMOO'],
  :handler      => :read_first_id3,
  :type         => Type::STRING,
},

# track_num
{
  :name         => :track_num,
  :id3v2_frames => ['TRCK'],
  :id3v1_tag    => :track,
  :default      => [0, 0],
  :handler      => :read_int_pair,
  :type         => Type::INT_LIST, # don't know if this will ever be useful
},

# disc_num
{
  :name         => :disc_num,
  :id3v2_frames => ['TPOS'],
  :default      => [0, 0],
  :handler      => :read_int_pair,
  :type         => Type::INT_LIST, # don't know if this will ever be useful
},

# original_date
#   TDOR - orig release date (v2.4 only)
#   TORY - orig release year (v2.3)
{
  :name         => :original_date,
  :id3v2_frames => ['TDOR', 'TORY'],
  :handler      => :read_first_id3,
  :type         => Type::DATETIME,
},

# comments
{
  :name         => :comments,
  :id3v2_frames => ['COMM'],
  :id3v1_tag    => :comment,
  :handler      => :read_all_id3,
  :default      => [],
  :options      => { :compact => true, :delete_empty => true }
},

# comment
{
  :name         => :comment,
  :handler      => lambda { |iface| iface.comments.first },
  :type         => Type::STRING,
},

# album_art
{
  :name         => :album_art,
  :id3v2_frames => ['APIC'],
  :handler      => :read_all_id3,
  :default      => [],
},

# date
{
  :name         => :date,
  :handler      => :read_date,
  :type         => Type::DATETIME,
},

# year
{
  :name         => :year,
  :handler      => lambda { |iface| iface.date.nil? ? 0 : iface.date.year }
},

# apple_id
{
  :name         => :apple_id,
  :handler      => :read_default,
  :type         => Type::STRING,
},

# user_info
{
  :name         => :user_info,
  :id3v2_frames => ['TXXX'],
  :handler      => :read_field_list_as_key_value,
  :default      => {},
  :options     => {:field_list => true},
},

# user_info_normalized
{
  :name         => :user_info_normalized,
  :id3v2_frames => ['TXXX'],
  :handler      => :read_field_list_as_key_value,
  :default      => {},
  :options     => {:normalize => true, 
    :to_sym => true,
    :field_list => true },
},

# asin
{
  :name         => :asin,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :asin},
  :type         => Type::STRING,
},

#
# MusicBrainz Attributes
#

# musicbrainz_track_id
{
  :name         => :musicbrainz_track_id,
  :handler      => :read_ufid,
  :handler_opts => {:owner => 'http://musicbrainz.org'},
  :type         => Type::STRING,
},

# musicbrainz_album_artist_id
{
  :name         => :musicbrainz_album_artist_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_artist_id},
  :type         => Type::STRING,
},

# musicbrainz_artist_id
{
  :name         => :musicbrainz_artist_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_artist_id},
  :type         => Type::LIST,
},

# musicbrainz_album_id
{
  :name         => :musicbrainz_album_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_id},
  :type         => Type::STRING,
},

# musicbrainz_album_status
{
  :name         => :musicbrainz_album_status,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_status},
  :type         => Type::STRING,
},

# musicbrainz_album_type
{
  :name         => :musicbrainz_album_type,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_type},
  :type         => Type::LIST,
},


# musicbrainz_release_group_id
{
  :name         => :musicbrainz_release_group_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_release_group_id},
  :type         => Type::STRING,
},

# musicbrainz_album_release_country
{
  :name         => :musicbrainz_album_release_country,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_release_country},
  :type         => Type::STRING,
},

#
# Audio Properties
#
 
# length 
{
  :name         => :length,
  :aliases      => [:duration],
  :handler      => :read_audio_property,
  :handler_opts => {:key => :length},
  :type         => Type::INT,
},

# bitrate
{
  :name         => :bitrate,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :bitrate},
  :type         => Type::INT,
},

# sample_rate
{
  :name         => :sample_rate,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :sample_rate},
  :type         => Type::INT,
},

# channels
{
  :name         => :channels,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :channels},
  :type         => Type::INT,
},

# copyrighted?
{
  :name         => :copyrighted?,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :copyrighted?},
  :type         => Type::BOOLEAN,
},

# layer
{
  :name         => :layer,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :layer},
  :type         => Type::INT,
},

# original?
{
  :name         => :original?,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :original?},
  :type         => Type::BOOLEAN,
},

# protection_enabled?
{
  :name         => :protection_enabled?,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :protection_enabled},
  :type         => Type::BOOLEAN,
},
]
MP4_ATTRIB_ARGS =
[
# title
{
  :name       => :title,
  :item_ids   => ['©nam'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# title_sort_order
{
  :name       => :title_sort_order,
  :item_ids   => ['sonm'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# artist
{
  :name       => :artist,
  :item_ids   => ['©ART'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# artist_sort_order
{
  :name       => :artist_sort_order,
  :item_ids   => ['soar'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# album_artist
{
  :name       => :album_artist,
  :item_ids   => ['aART'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# album_artist_sort_order
{
  :name       => :album_artist_sort_order,
  :item_ids   => ['soaa'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# album
{
  :name       => :album,
  :item_ids   => ['©alb'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# album_sort_order
{
  :name       => :album_sort_order,
  :item_ids   => ['soal'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# genre
{
  :name       => :genre,
  :item_ids   => ['©gen'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# comments
{
  :name       => :comments,
  :item_ids   => ['©cmt'],
  :handler    => :read_first_item,
  :item_type  => ItemType::STRING_LIST,
  :default    => [],
},

# comment
{
  :name       => :comment,
  :handler    => lambda { |iface| iface.comments.first },
  :type       => Type::STRING,
},

# lyrics
{
  :name       => :lyrics,
  :item_ids   => ['©lyr'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# date
{
  :name       => :date,
  :item_ids   => ['©day'],
  :handler    => :read_first_item,
  :type       => Type::DATETIME,
  :default    => nil,
},

# original_date
{
  :name       => :original_date,
  :handler    => :read_default,
  :type       => Type::DATETIME,

},

# year
{
  :name       => :year,
  :handler    => lambda { |iface| iface.date.nil? ? 0 : iface.date.year }
},

# apple_id
{
  :name       => :apple_id,
  :item_ids   => ['apid'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# encoded_by
{
  :name       => :encoded_by,
  :item_ids   => ['©enc'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# encoder_settings
{
  :name       => :encoder_settings,
  :item_ids   => ['©too'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# group
{
  :name       => :group,
  :item_ids   => ['©grp'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# compilation?
{
  :name       => :compilation?,
  :item_ids   => ['cpil'],
  :handler    => :read_first_item,
  :type       => Type::BOOLEAN,
  :item_type  => ItemType::BOOL,
},

# bpm
{
  :name       => :bpm,
  :item_ids   => ['tmpo'],
  :handler    => :read_first_item,
  :item_type  => ItemType::INT,
  :default    => 0,
},

# mood
{
  :name       => :mood,
  :item_ids   => ['mood'],
  :handler    => :read_first_item,
  :item_type  => ItemType::STRING,
  :type       => Type::STRING,
},

# copyright
{
  :name       => :copyright,
  :item_ids   => ['cprt'],
  :handler    => :read_first_item,
  :type       => Type::STRING,
},

# track_num
{
  :name       => :track_num,
  :item_ids   => ['trkn'],
  :handler    => :read_first_item,
  :item_type  => ItemType::INT_PAIR,
  :default    => [0, 0],
},

# disc_num
{
  :name       => :disc_num,
  :item_ids   => ['disk'],
  :handler    => :read_first_item,
  :item_type  => ItemType::INT_PAIR,
  :default    => [0, 0],
},

# album_art
{
  :name       => :album_art,
  :item_ids   => ['covr'],
  :handler    => :read_first_item,
  :item_type  => ItemType::COVER_ART_LIST,
  :default    => [],
},

# user_info
{
  :name       => :user_info,
  :handler    => :read_user_info,
  :default    => {},
},

# user_info_normalized
{
  :name       => :user_info_normalized,
  :handler    => :read_user_info,
  :default    => {},
  :options    => {:normalize => true, :to_sym => true},
},

# subtitle
{
  :name       => :subtitle,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :subtitle},
  :type       => Type::STRING,
},

# disc_subtitle
{
  :name       => :disc_subtitle,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :discsubtitle},
  :type       => Type::STRING,
},

# media
{
  :name       => :media,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :media},
  :type       => Type::STRING,
},

# label
{
  :name       => :label,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :label},
  :type       => Type::STRING,
},

# composer
{
  :name       => :composer,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :composer},
  :type       => Type::STRING,
},

# conductor
{
  :name       => :conductor,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :conductor},
  :type       => Type::STRING,
},

# remixer
{
  :name       => :remixer,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :remixer},
  :type       => Type::STRING,
},

# lyricist
{
  :name       => :lyricist,
  :handler    => :user_info_lookup,
  :handler_opts => {:key => :lyricist},
  :type       => Type::STRING,
},

# asin
{
  :name         => :asin,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :asin},
  :type         => Type::STRING,
},

#
# MusicBrainz Attributes
#

# musicbrainz_track_id
{
  :name         => :musicbrainz_track_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_track_id},
  :type         => Type::STRING,
},

# musicbrainz_album_artist_id
{
  :name         => :musicbrainz_album_artist_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_artist_id},
  :type         => Type::STRING,
},

# musicbrainz_artist_id
{
  :name         => :musicbrainz_artist_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_artist_id},
  :type         => Type::LIST,
},

# musicbrainz_album_id
{
  :name         => :musicbrainz_album_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_id},
  :type         => Type::STRING,
},

# musicbrainz_album_status
{
  :name         => :musicbrainz_album_status,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_status},
  :type         => Type::STRING,
},

# musicbrainz_album_type
{
  :name         => :musicbrainz_album_type,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_type},
  :type         => Type::LIST,
},


# musicbrainz_release_group_id
{
  :name         => :musicbrainz_release_group_id,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_release_group_id},
  :type         => Type::STRING,
},

# musicbrainz_album_release_country
{
  :name         => :musicbrainz_album_release_country,
  :handler      => :user_info_lookup,
  :handler_opts => {:key => :musicbrainz_album_release_country},
  :type         => Type::STRING,
},

#
# Audio Properties
#

# length 
{
  :name         => :length,
  :aliases      => [:duration],
  :handler      => :read_audio_property,
  :handler_opts => {:key => :length},
  :type         => Type::INT,
},

# bitrate
{
  :name         => :bitrate,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :bitrate},
  :type         => Type::INT,
},

# sample_rate
{
  :name         => :sample_rate,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :sample_rate},
  :type         => Type::INT,
},

# channels
{
  :name         => :channels,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :channels},
  :type         => Type::INT,
},

# bits_per_sample
{
  :name         => :bits_per_sample,
  :handler      => :read_audio_property,
  :handler_opts => {:key => :bits_per_sample},
  :type         => Type::INT,
},
 
# NOTE: Not supported by ruby-easytag 0.6.0
## encrypted?
#{
  #:name         => :encrypted?,
  #:handler      => :read_audio_property,
  #:handler_opts => {:key => :encrypted?},
  #:type         => Type::BOOLEAN,
#},
]