forked from rb2k/viddl-rb
/
blip.rb
executable file
·25 lines (22 loc) · 931 Bytes
/
blip.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Blip < PluginBase
# this will be called by the main app to check whether this plugin is responsible for the url passed
def self.matches_provider?(url)
url.include?("blip.tv")
end
# return the url for original video file and title
def self.get_urls_and_filenames(url)
id = self.to_id(url)
xml_url = "http://blip.tv/rss/#{id}"
doc = Nokogiri::XML(open(xml_url))
user = doc.at("//channel/item/blip:user").inner_text
title = doc.at("//channel/item/title").inner_text.gsub(" ", "_")
download_url = doc.at("//channel/item/media:group/media:content").attributes["url"].value
extention = download_url.split(".").last
file_name = "#{id}-#{user}-#{title}.#{extention}"
[{:url => download_url, :name => file_name}]
end
# usually id is last 7 digits
def self.to_id(url)
URI::split(url)[5].split("/")[2].split("-").last
end
end