Sélectionner une révision Git
soundcloud_plugin.rb
Bifurcation depuis
Alexandre MORIGNOT / PlayBot
Le projet source a une visibilité limitée.
-
Alexandre Morignot a rédigé
Links are now registered in a database ! Its configurtion muste be defined in the database section in the config file. The migration for the database can be done simply using "rake". The config file has moved ! He must be located at "~/.playbot/config". Site Plugins return value has changed ! The hash must contain a new key "url". It allow the plugin to normalize it if many different url can link to a same content.
Alexandre Morignot a rédigéLinks are now registered in a database ! Its configurtion muste be defined in the database section in the config file. The migration for the database can be done simply using "rake". The config file has moved ! He must be located at "~/.playbot/config". Site Plugins return value has changed ! The hash must contain a new key "url". It allow the plugin to normalize it if many different url can link to a same content.
soundcloud_plugin.rb 660 o
require_relative '../lib/site_plugin.rb'
require 'rubygems'
require 'bundler/setup'
require 'soundcloud'
# SitePlugin for Soundcloud
#
# Need an client ID (soundcloud_client_id).
class SoundcloudPlugin < SitePlugin
def self.can_handle?(site)
site =~ /^https?:\/\/(www\.)?soundcloud\.com\/[a-zA-Z0-9\/_-]+$/
end
public
def initialize(options)
@client = Soundcloud.new(:client_id => options[:soundcloud_client_id])
end
def get(url)
track = @client.get('/resolve', :url => url)
url.gsub(/http:\/\//, 'https://')
{:title => track.title, :author => track.user.username, :url => url}
end
end