Socket
Book a DemoInstallSign in
Socket

tagfile

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tagfile

0.0.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

TagFile

TagFile is a simple Class for building objects from binary audio files. It currently supports .flac, .mp3, & .ogg file formats. Using the ultra-fast TagLib2, TagFile extracts embedded metadata and builds a hash from user-defined values. This hash can be easily serialized and persisted in a database or document store.

Example usage

class Track < TagFile::Document
  extract_tag_for :artist, :album
end

track = Track.new('valid_file.flac')
track.tags => {artist: 'artist', album: 'album'}

Extractions

In order to build '#tags' you must specify which tags to use. The following tags can be extracted:

Embedded tags (from TagLib2)

  • album
  • artist
  • genre
  • title
  • track
  • year

Custom tags (from TagFile)

  • path
  • filename
  • format
class Track < TagFile::Document
  extract_tag_for :artist

  # extract_tag_for :artist, :path, :title
  # extract_tag_for :all
  # extract_tag_for :all, except: [:artist, :album]
end

Verifications

TagFile includes several user-specified verifications. While path and format have built-in verifications, format can be customized to verify a subset of formats. Note: all valid TagFile objects will have a filename, length, path, and format attribute by default.

class Track < TagFile::Document
  extract_tag_for :artist

  verify_tag_for :artist
end

class Track < TagFile::Document
  extract_tags_for :all

  verify_tag_for :artist, :album
  # verify_tag_for :all
  # verify_tag_for :all, except: [:artist, :genre]
  # verify_format_is :flac, :mp3
end

Errors

With custom verifications in place, all errors are written to '#errors'.

class Track < TagFile::Document
  extract_tag_for :artist
  verify_tag_for  :artist
  verify_format_is  :mp3
end

track = Track.new('missing_artist.flac')
track.errors => ["Missing artist tag: missing_artist.flac", "File not of format :mp3: missing_artist.flac"]

FAQs

Package last updated on 08 Jul 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.