Module: RockboxFFI::Metadata
- Defined in:
- lib/rockbox_ffi/metadata.rb
Overview
Audio file metadata parsing.
Class Method Summary collapse
-
.probe(filename) ⇒ Object
Guess the codec label (e.g. "FLAC") from a filename's extension without opening the file.
-
.read(path) ⇒ Object
Parse the metadata of the audio file at
path.
Class Method Details
.probe(filename) ⇒ Object
Guess the codec label (e.g. "FLAC") from a filename's extension without opening the file. Returns nil for an unknown extension.
25 26 27 |
# File 'lib/rockbox_ffi/metadata.rb', line 25 def probe(filename) RockboxFFI.take_string(Lib.(filename.to_s)) end |
.read(path) ⇒ Object
Parse the metadata of the audio file at path.
Returns a Hash (symbol keys) with tag strings, :duration_ms,
:bitrate, :sample_rate, a nested :replaygain Hash (including the
raw Q7.24 raw_* fields), and optional :album_art / :cuesheet
locations. Raises on failure.
16 17 18 19 20 21 |
# File 'lib/rockbox_ffi/metadata.rb', line 16 def read(path) s = RockboxFFI.take_string(Lib.(path.to_s)) raise "could not read metadata from #{path.inspect}" if s.nil? JSON.parse(s, symbolize_names: true) end |