Skip to content
Extraits de code Groupes Projets
Valider 7bcbc841 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

Youtube Plugin is done !

parent 0bf63b77
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
require_relative '../lib/site_plugin.rb'
require 'rubygems'
require 'youtube_it'
class YoutubePlugin < SitePlugin
def self.can_handle?(site)
site =~ /^http:\/\/((www.)?youtube.(fr|com)\/watch\?v=|youtu\.be\/)[a-zA-Z0-9]+$/
end
public
# Store a new youtube api client
def initialize
@client = YouTubeIt::Client.new
end
def get(url)
puts "Oh oh oh ! #{url}"
video = @client.video_by(url)
{:title => video.title, :author => video.author.name}
end
end
......@@ -14,7 +14,7 @@ describe SitePlugin do
end
describe '.for_site' do
it 'return plugin that can handle a given site"' do
it 'return plugin that can handle a given site' do
class TestPlugin2 < SitePlugin
def self.can_handle?(site)
site =~ /test/
......
......@@ -14,4 +14,11 @@ describe YoutubePlugin do
YoutubePlugin.can_handle?('http://youtu.be/Pb8VPYMgHlg').should be_true
end
end
describe '#get' do
it "return video's informations" do
YoutubePlugin.new.get('http://youtube.com/watch?v=Pb8VPYMgHlg')[:title].should == 'DJ Showtek - FTS (Fuck the system)'
YoutubePlugin.new.get('http://youtube.com/watch?v=Pb8VPYMgHlg')[:author].should == 'bf2julian'
end
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter