Sha256: 8f8fa71d3a1276a91471df012da790f37cf00a42cd74e03aafe08a242861c23a

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

module PlexSymlinker
  module FileTypes
    # {
    #   "TDRC": "1968",
    #   "TIT2": "Seite B",
    #   "TKEY": "C",
    #   "TBPM": "120",
    #   "TPE1": "Winnetou",
    #   "TALB": "Winnetou 3 - 3. Folge",
    #   "TPE2": "alb-artist: Winnetou",
    #   "TCON": "Hörspiel",
    #   "APIC": "[image/jpeg]",
    #   "TRCK": "2/2",
    #   "TXXX": "[PERFORMER_NAME] PERFORMER_NAME a performer"
    # }
    class Mp3 < AudioFile
      tag_reader :album, "TALB"
      tag_reader :genre, "TCON"
      tag_reader :title, "TIT2"
      tag_reader :year, "TDRC"
      tag_reader :artist, "TPE1"
      tag_reader :track_number, "TRCK"

      def tags
        @tags ||= TagLib::MPEG::File.open(path) { |file|
          Hash[file.id3v2_tag.frame_list.map { |f| [f.frame_id, f.to_s] }]
        }
      end

      def album_artist
        tags["TPE2"] || artist
      end
    end
  end
end

PlexSymlinker::FileTypes::AudioFile.register_type :mp3, PlexSymlinker::FileTypes::Mp3

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plex_symlinker-0.1.1 lib/plex_symlinker/file_types/mp3.rb
plex_symlinker-0.1.0 lib/plex_symlinker/file_types/mp3.rb