Module: AudioRating::FLAC
- Defined in:
- lib/audio_rating/flac.rb
Overview
Base class for FLAC files.
Class Method Summary collapse
-
.get(path) ⇒ Integer, ...
Get a FLAC file’s embedded star-rating metadata if present.
Class Method Details
.get(path) ⇒ Integer, ...
Get a FLAC file’s embedded star-rating metadata if present.
Uses taglib-ruby class: rubydoc.info/gems/taglib-ruby/TagLib/FLAC/File
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/audio_rating/flac.rb', line 16 def self.get(path) TagLib::FLAC::File.open(path) do |file| next unless file&.valid? && file&.xiph_comment? fields = file.xiph_comment.field_list_map next unless fields.key? 'RATING' = fields['RATING'].first.to_i return if <= 5 # foobar2000 sets <= 5 # MusicBee & MediaMonkey sets > 5 RATE_VALUE_TO_STAR_RATING[] if > 5 end end |