Class: Audd::RecognitionResult
- Defined in:
- lib/audd/models/recognition_result.rb
Overview
A single recognition result. Which fields are populated depends on which catalog matched:
- public-DB match —
artist,title,album,release_date,labelandsong_linkare populated andaudio_idis absent; - custom-DB match (your own fingerprint catalog) — only
timecodeandaudio_idare populated.
Use #public_match? / #custom_match? rather than testing artist for nil.
Constant Summary collapse
- THUMBNAIL_HOST =
Only lis.tn-hosted song links serve cover art from
?thumb. "lis.tn"
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#custom_match? ⇒ Boolean
Matched against your own fingerprint catalog rather than the public DB.
- #public_match? ⇒ Boolean
-
#thumbnail_url ⇒ Object
Cover art for the match, or nil when there's no song_link to build it from — appending ?thumb only means anything on lis.tn.
Methods inherited from Model
#==, #[], field, fields, from_json, #hash, #initialize, #inspect, #to_h
Constructor Details
This class inherits a constructor from Audd::Model
Instance Method Details
#custom_match? ⇒ Boolean
Matched against your own fingerprint catalog rather than the public DB.
40 41 42 |
# File 'lib/audd/models/recognition_result.rb', line 40 def custom_match? !audio_id.nil? end |
#public_match? ⇒ Boolean
44 45 46 |
# File 'lib/audd/models/recognition_result.rb', line 44 def public_match? audio_id.nil? end |
#thumbnail_url ⇒ Object
Cover art for the match, or nil when there's no song_link to build it from — appending ?thumb only means anything on lis.tn.
50 51 52 53 54 55 56 57 |
# File 'lib/audd/models/recognition_result.rb', line 50 def thumbnail_url return nil if song_link.nil? return nil unless URI.parse(song_link).host == THUMBNAIL_HOST "#{song_link}?thumb" rescue URI::InvalidURIError nil end |