Created
September 30, 2011 23:16
-
-
Save sahib/1255285 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './glyros.so' | |
include Glyros | |
# Simple example on how to use glyr_info_get | |
# and the require macros appear here too. | |
def req_to_string reqs, required, optional | |
return "required" if (reqs & required) != 0 | |
return "optional" if (reqs & optional) != 0 | |
return "not needed" | |
end | |
# Get a GlyrFetcherInfo struct | |
info = glyr_info_get | |
# Keep a reference to the start of the list | |
iter = info | |
# Iterare over all fetchers, works the same way like with memcaches from glyr_get | |
# The requirements (what fields need to be filled (optionally)) of each fetcher is | |
# stored in Class.reqs - it's a bitmask. | |
until iter.nil? | |
reqs = iter.reqs | |
# Name of the fetcher (type id is not important, just showing all fields) | |
puts "[#{iter.name}] {TypeID: #{iter.type}}" | |
# check if required, optional or not required | |
puts "- Artist is #{req_to_string(reqs,GLYR_REQUIRES_ARTIST,GLYR_OPTIONAL_ARTIST )}" | |
puts "- Album is #{req_to_string(reqs,GLYR_REQUIRES_ALBUM, GLYR_OPTIONAL_ALBUM )}" | |
puts "- Title is #{req_to_string(reqs,GLYR_REQUIRES_TITLE, GLYR_OPTIONAL_TITLE )}" | |
puts "- Providers:" | |
# Now iterate over all providers | |
# and print them | |
source = iter.head | |
until source.nil? | |
# Print the provider's key and name | |
# The key is a one-letter shortcut for the name | |
# You can use it for glyr_opt_from() | |
# Speed and quality is a rating from 0-100 - it is used internally to | |
# select the providers to search in | |
puts " #[#{source.key}][Lang Aware: #{source.lang_aware ? "Y" : "N"}] (q:#{source.quality} s:#{source.speed}) #{source.name} " | |
source = source.next | |
end | |
puts "\n----------\n\n" | |
# Next fetcher please. | |
iter = iter.next | |
end | |
# This is C. Free it. | |
glyr_info_free info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment