acts_as_unvlogable 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +15 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +130 -0
- data/Rakefile +2 -0
- data/acts_as_unvlogable.gemspec +26 -0
- data/lib/acts_as_unvlogable/flickr.rb +713 -0
- data/lib/acts_as_unvlogable/object_base.rb +15 -0
- data/lib/acts_as_unvlogable/string_base.rb +24 -0
- data/lib/acts_as_unvlogable/string_extend.rb +8 -0
- data/lib/acts_as_unvlogable/version.rb +3 -0
- data/lib/acts_as_unvlogable/vg_11870.rb +57 -0
- data/lib/acts_as_unvlogable/vg_blip.rb +48 -0
- data/lib/acts_as_unvlogable/vg_collegehumor.rb +66 -0
- data/lib/acts_as_unvlogable/vg_dailymotion.rb +66 -0
- data/lib/acts_as_unvlogable/vg_dalealplay.rb +49 -0
- data/lib/acts_as_unvlogable/vg_flickr.rb +70 -0
- data/lib/acts_as_unvlogable/vg_marca.rb +48 -0
- data/lib/acts_as_unvlogable/vg_metacafe.rb +77 -0
- data/lib/acts_as_unvlogable/vg_mtvmusic.rb +65 -0
- data/lib/acts_as_unvlogable/vg_myspace.rb +48 -0
- data/lib/acts_as_unvlogable/vg_qik.rb +66 -0
- data/lib/acts_as_unvlogable/vg_rutube.rb +80 -0
- data/lib/acts_as_unvlogable/vg_ted.rb +51 -0
- data/lib/acts_as_unvlogable/vg_vimeo.rb +78 -0
- data/lib/acts_as_unvlogable/vg_youtube.rb +57 -0
- data/lib/acts_as_unvlogable.rb +91 -0
- data/test/acts_as_unvlogable_test.rb +392 -0
- data/unvlogable_sample.yml +5 -0
- metadata +169 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
# This removes the activesupport dependency
|
2
|
+
|
3
|
+
class Object
|
4
|
+
def blank?
|
5
|
+
respond_to?(:empty?) ? empty? : !self
|
6
|
+
end
|
7
|
+
|
8
|
+
def instance_values #:nodoc:
|
9
|
+
instance_variables.inject({}) do |values, name|
|
10
|
+
values[name.to_s[1..-1]] = instance_variable_get(name)
|
11
|
+
values
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This removes the activesupport dependency
|
2
|
+
|
3
|
+
class String
|
4
|
+
def camelize(first_letter_in_uppercase = true)
|
5
|
+
if first_letter_in_uppercase
|
6
|
+
self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
7
|
+
else
|
8
|
+
self.first + camelize(self)[1..-1]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def constantize
|
13
|
+
camel_cased_word = self
|
14
|
+
unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
|
15
|
+
raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
|
16
|
+
end
|
17
|
+
|
18
|
+
Object.module_eval("::#{$1}", __FILE__, __LINE__)
|
19
|
+
end
|
20
|
+
|
21
|
+
def humanize
|
22
|
+
self.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for 11870 (11870.com)
|
3
|
+
# http://11870.com/pro/chic-basic-born/media/b606abfe
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class Vg11870
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
@page = Hpricot(open(url))
|
12
|
+
@flashvars = get_hash(/var flashvars = \{(.+)\}/.match(@page.to_s)[1])
|
13
|
+
@flashvars['logo'] = "http://11870.com#{@flashvars['logo']}" unless @flashvars['logo'].blank?
|
14
|
+
end
|
15
|
+
|
16
|
+
def title
|
17
|
+
CGI::unescapeHTML @page.search("//h1[@class='fn name']/a").first.inner_html
|
18
|
+
end
|
19
|
+
|
20
|
+
def thumbnail
|
21
|
+
@flashvars['image']
|
22
|
+
end
|
23
|
+
|
24
|
+
def duration
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def embed_url
|
29
|
+
query = @flashvars.map {|k,v| "&#{k}=#{v}"}
|
30
|
+
"http://11870.com/multimedia/flvplayer.swf?#{query}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def embed_html(width=425, height=344, options={})
|
34
|
+
"<object width='#{width}' height='#{height}' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'> <param name='movie' value='#{embed_url}' /> <param name='quality' value='high' /><embed src='#{embed_url}' width='#{width}' height='#{height}' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/></object>"
|
35
|
+
end
|
36
|
+
|
37
|
+
def flv
|
38
|
+
@flashvars['file']
|
39
|
+
end
|
40
|
+
|
41
|
+
def download_url
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def service
|
46
|
+
"11870.com"
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def get_hash(string)
|
52
|
+
pieces = string.gsub('"', '').split(/,|:\s/)
|
53
|
+
hash = Hash[*pieces]
|
54
|
+
hash.delete_if { |key, value| value.nil? || key == "displaywidth" }
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for BlipTv (blip.tv)
|
3
|
+
# http://blip.tv/file/678407/
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgBlip
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url.split("?").first if url
|
11
|
+
res = Net::HTTP.get(URI.parse("#{url}?skin=rss"))
|
12
|
+
@feed = REXML::Document.new(res)
|
13
|
+
end
|
14
|
+
|
15
|
+
def title
|
16
|
+
CGI::unescape REXML::XPath.first(@feed, "//media:title")[0].to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def thumbnail
|
20
|
+
REXML::XPath.first(@feed, "//blip:smallThumbnail")[0].to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def duration
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def embed_url
|
28
|
+
emb = REXML::XPath.first(@feed, "//media:player")[0].to_s
|
29
|
+
emb.split("src=\"")[1].split("\"")[0]
|
30
|
+
end
|
31
|
+
|
32
|
+
def embed_html(width=425, height=344, options={})
|
33
|
+
"<embed src='#{embed_url}' type='application/x-shockwave-flash' width='#{width}' height='#{height}' allowscriptaccess='always' allowfullscreen='true'></embed>"
|
34
|
+
end
|
35
|
+
|
36
|
+
def flv
|
37
|
+
REXML::XPath.first(@feed, "//enclosure").attributes['url']
|
38
|
+
end
|
39
|
+
|
40
|
+
def download_url
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def service
|
45
|
+
"Blip.tv"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Collegehumor (www.collegehumor.com)
|
3
|
+
# http://www.collegehumor.com/video:1781938
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgCollegehumor
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
@video_id = parse_url(url)
|
12
|
+
res = Net::HTTP.get(URI.parse("http://www.collegehumor.com/moogaloop/video:#{@video_id}"))
|
13
|
+
@feed = REXML::Document.new(res)
|
14
|
+
end
|
15
|
+
|
16
|
+
def title
|
17
|
+
REXML::XPath.first(@feed, "//video/caption")[0].to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def thumbnail
|
21
|
+
REXML::XPath.first(@feed, "//video/thumbnail")[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
def embed_url
|
25
|
+
"http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=#{@video_id}&fullscreen=1"
|
26
|
+
end
|
27
|
+
|
28
|
+
def embed_html(width=425, height=344, options={})
|
29
|
+
"<object type='application/x-shockwave-flash' data='#{embed_url}' width='#{width}' height='#{height}'><param name='allowfullscreen' value='true'/><param name='wmode' value='transparent'/><param name='AllowScriptAccess' value='true'/><param name='movie' quality='best' value='#{embed_url}'/><embed src='#{embed_url}' type='application/x-shockwave-flash' wmode='transparent' width='#{width}' height='#{height}' allowScriptAccess='always'></embed></object>"
|
30
|
+
end
|
31
|
+
|
32
|
+
def flv
|
33
|
+
REXML::XPath.first(@feed, "//video/file")[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
def download_url
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def duration
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def service
|
45
|
+
"CollegeHumor"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parse_url(url)
|
51
|
+
uri = URI.parse(url)
|
52
|
+
path = uri.path
|
53
|
+
videoargs = ''
|
54
|
+
if path and path.split(":").size > 0
|
55
|
+
videoargs = path.split(":")
|
56
|
+
raise unless videoargs.size > 0 && videoargs.first == '/video'
|
57
|
+
else
|
58
|
+
raise
|
59
|
+
end
|
60
|
+
videoargs[1]
|
61
|
+
rescue
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Dailymotion (www.dailymotion.com)
|
3
|
+
# http://www.dailymotion.com/visited-week/lang/es/video/x7u5kn_parkour-dayyy_sport
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgDailymotion
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
@video_id = parse_url(url)
|
12
|
+
res = Net::HTTP.get(URI.parse("http://www.dailymotion.com/rss/video/#{@video_id}"))
|
13
|
+
@feed = REXML::Document.new(res)
|
14
|
+
end
|
15
|
+
|
16
|
+
def title
|
17
|
+
REXML::XPath.first(@feed, "//item/title")[0].to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def thumbnail
|
21
|
+
REXML::XPath.first(@feed, "//media:thumbnail").attributes['url'].gsub("preview_large", "preview_medium")
|
22
|
+
end
|
23
|
+
|
24
|
+
def embed_url
|
25
|
+
REXML::XPath.first(@feed, "//media:content[@type='application/x-shockwave-flash']").attributes['url']
|
26
|
+
end
|
27
|
+
|
28
|
+
def embed_html(width=425, height=344, options={})
|
29
|
+
"<object width='#{width}' height='#{height}'><param name='movie' value='#{embed_url}&related=1'></param><param name='allowFullScreen' value='true'></param><param name='allowScriptAccess' value='always'></param><embed src='#{embed_url}&related=1' type='application/x-shockwave-flash' width='#{width}' height='#{height}' allowFullScreen='true' allowScriptAccess='always'></embed></object>"
|
30
|
+
end
|
31
|
+
|
32
|
+
def flv
|
33
|
+
REXML::XPath.first(@feed, "//media:content[@type='video/x-flv']").attributes['url']
|
34
|
+
end
|
35
|
+
|
36
|
+
def download_url
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def duration
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def service
|
45
|
+
"Dailymotion"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parse_url(url)
|
51
|
+
uri = URI.parse(url)
|
52
|
+
path = uri.path
|
53
|
+
videoargs = ''
|
54
|
+
if path
|
55
|
+
videoargs = path.split('/video/')[1].split("/")[0]
|
56
|
+
raise unless videoargs.size > 0
|
57
|
+
else
|
58
|
+
raise
|
59
|
+
end
|
60
|
+
videoargs
|
61
|
+
rescue
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for dalealplay (dalealplay.com)
|
3
|
+
# http://www.dalealplay.com/informaciondecontenido.php?con=80280
|
4
|
+
#
|
5
|
+
# Crappy without api
|
6
|
+
# ----------------------------------------------
|
7
|
+
|
8
|
+
|
9
|
+
class VgDalealplay
|
10
|
+
|
11
|
+
def initialize(url=nil, options={})
|
12
|
+
@url = url
|
13
|
+
@video_id = @url.query_param('con')
|
14
|
+
@page = Hpricot(open(url))
|
15
|
+
end
|
16
|
+
|
17
|
+
def title
|
18
|
+
(Iconv.iconv 'utf-8', 'iso-8859-1', @page.search("//title").inner_html.split(" - www.dalealplay.com")[0]).to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def thumbnail
|
22
|
+
"http://images-00.dalealplay.com/contenidos2/#{@video_id}/captura.jpg"
|
23
|
+
end
|
24
|
+
|
25
|
+
def embed_url
|
26
|
+
@page.search("//link[@rel='video_src']").first.attributes["href"].sub("autoStart=true", "autoStart=false")
|
27
|
+
end
|
28
|
+
|
29
|
+
def duration
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def embed_html(width=425, height=344, options={})
|
34
|
+
"<object type='application/x-shockwave-flash' width='#{width}' height='#{height}' data='#{embed_url}'><param name='quality' value='best' /> <param name='allowfullscreen' value='true' /><param name='scale' value='showAll' /><param name='movie' value='http#{embed_url}' /></object>"
|
35
|
+
end
|
36
|
+
|
37
|
+
def flv
|
38
|
+
"http://videos.dalealplay.com/contenidos3/#{CGI::parse(URI::parse(embed_url).query)['file']}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def download_url
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def service
|
46
|
+
"dalealplay"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Flickr (flickr.com)
|
3
|
+
# http://www.flickr.com/photos/andina/3158762127/in/photostream/
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgFlickr
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
# general settings
|
11
|
+
@url = url
|
12
|
+
@video_id = parse_url(url)
|
13
|
+
settings ||= YAML.load_file(RAILS_ROOT + '/config/unvlogable.yml') rescue {}
|
14
|
+
@details = Flickr::Photo.new(@video_id, options.nil? || options[:key].nil? ? settings['flickr_key'] : options[:key])
|
15
|
+
raise if @details.media != "video"
|
16
|
+
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
@details.title
|
20
|
+
end
|
21
|
+
|
22
|
+
def thumbnail
|
23
|
+
@details.source('Small')
|
24
|
+
end
|
25
|
+
|
26
|
+
def embed_url
|
27
|
+
"http://www.flickr.com/apps/video/stewart.swf?v=63881&intl_lang=en-us&photo_secret=#{@details.secret}&photo_id=#{@video_id}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def embed_html(width=425, height=344, options={})
|
31
|
+
"<object type='application/x-shockwave-flash' width='#{width}' height='#{height}' data='http://www.flickr.com/apps/video/stewart.swf?v=63881' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'><param name='movie' value='#{embed_url}'></param> <param name='bgcolor' value='#000000'></param> <param name='allowFullScreen' value='true'></param><embed type='application/x-shockwave-flash' src='#{embed_url}' bgcolor='#000000' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>"
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def flv
|
36
|
+
player_feed = "http://www.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=#{@video_id}&secret=#{@details.secret}&olang=en-us&noBuffer=null&bitrate=700&target=_blank"
|
37
|
+
res = Net::HTTP.get(URI::parse(player_feed))
|
38
|
+
player_feed_xml = REXML::Document.new(res)
|
39
|
+
data_id = REXML::XPath.first(player_feed_xml, "//Data/Item[@id='id']")[0].to_s
|
40
|
+
|
41
|
+
video_feed = "http://www.flickr.com/video_playlist.gne?node_id=#{data_id}&tech=flash&mode=playlist&lq=j2CW2jbpqCLKRy_s4bTylH&bitrate=700&secret=#{@details.secret}&rd=video.yahoo.com-offsite&noad=1"
|
42
|
+
res = Net::HTTP.get(URI::parse(video_feed))
|
43
|
+
video_feed_xml = REXML::Document.new(res)
|
44
|
+
stream = REXML::XPath.first(video_feed_xml, "//DATA/SEQUENCE-ITEM/STREAM")
|
45
|
+
"#{stream.attributes['APP']}#{stream.attributes['FULLPATH']}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def download_url
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def duration
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def service
|
57
|
+
"Flickr"
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def parse_url(url)
|
63
|
+
video_id = URI::parse(url).path.split("/")[3]
|
64
|
+
raise unless video_id
|
65
|
+
video_id
|
66
|
+
rescue
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Marca.tv (www.marca.tv)
|
3
|
+
# http://www.marca.com/tv/?v=DN23wG8c1Rj
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgMarca
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
@video_id = @url.query_param('v')
|
12
|
+
res = Net::HTTP.get(URI.parse("http://estaticos.marca.com/consolamultimedia/marcaTV/elementos/#{@video_id[0,1]}/#{@video_id[1,1]}/#{@video_id[2,100]}.xml"))
|
13
|
+
@feed = REXML::Document.new(res)
|
14
|
+
end
|
15
|
+
|
16
|
+
def title
|
17
|
+
REXML::XPath.first( @feed, "//titulo" )[0].to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def thumbnail
|
21
|
+
REXML::XPath.first( @feed, "//foto" )[0].to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def duration
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def embed_url
|
29
|
+
"http://www.marca.com/componentes/flash/embed.swf?ba=0&cvol=1&bt=1&lg=1&vID=#{@video_id}&ba=1"
|
30
|
+
end
|
31
|
+
|
32
|
+
def embed_html(width=425, height=344, options={})
|
33
|
+
"<embed width='#{width}' height='#{height}' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' allowfullscreen='true' quality='high' src='#{embed_url}'/>"
|
34
|
+
end
|
35
|
+
|
36
|
+
def flv
|
37
|
+
REXML::XPath.first(@feed, "//media")[0].to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
def download_url
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def service
|
45
|
+
"Marca.tv"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Metacafe (www.metacafe.com)
|
3
|
+
# http://www.metacafe.com/watch/476621/experiments_with_the_myth_busters_with_diet_coke_and_mentos_dry/
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgMetacafe
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
@args = parse_url(url)
|
12
|
+
|
13
|
+
#is the video 'youtubed'?
|
14
|
+
@youtubed = @args[1].index("yt-").nil? ? false : true
|
15
|
+
@yt = @youtubed ? VgYoutube.new("http://www.youtube.com/watch?v=#{@args[1].sub('yt-', '')}") : nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
@youtubed ? @yt.title : (@args[2].humanize unless @args[2].blank?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def thumbnail
|
23
|
+
"http://www.metacafe.com/thumb/#{@args[1]}.jpg"
|
24
|
+
end
|
25
|
+
|
26
|
+
def embed_url
|
27
|
+
"http://www.metacafe.com/fplayer/#{@args[1]}/#{@args[2]}.swf"
|
28
|
+
end
|
29
|
+
|
30
|
+
def embed_html(width=425, height=344, options={})
|
31
|
+
"<embed src='#{embed_url}' width='#{width}' height='#{height}' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>"
|
32
|
+
end
|
33
|
+
|
34
|
+
def flv
|
35
|
+
if @youtubed
|
36
|
+
@yt.flv
|
37
|
+
else
|
38
|
+
params = Hash.new
|
39
|
+
open(self.embed_url) {|f|
|
40
|
+
params = CGI::parse(f.base_uri.request_uri.split("?")[1])
|
41
|
+
}
|
42
|
+
CGI::unescape "#{ params['mediaURL']}?__gda__=#{params['gdaKey']}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def duration
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def download_url
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def service
|
55
|
+
"Metacafe"
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def parse_url(url)
|
61
|
+
uri = URI.parse(url)
|
62
|
+
path = uri.path
|
63
|
+
@args = ''
|
64
|
+
if path and path.split("/").size >=1
|
65
|
+
@args = path.split("/")
|
66
|
+
@args.delete("watch")
|
67
|
+
|
68
|
+
raise unless @args.size > 0
|
69
|
+
else
|
70
|
+
raise
|
71
|
+
end
|
72
|
+
@args
|
73
|
+
rescue
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for MTV Music (www.mtvmusic.com)
|
3
|
+
# http://www.mtvmusic.com/astley_rick/videos/55086/never_gonna_give_you_up.jhtml
|
4
|
+
#
|
5
|
+
#
|
6
|
+
# quite ugly, we know :(
|
7
|
+
# ----------------------------------------------
|
8
|
+
|
9
|
+
|
10
|
+
class VgMtvmusic
|
11
|
+
|
12
|
+
def initialize(url=nil, options={})
|
13
|
+
@url = url
|
14
|
+
@video_id = @url.query_param('id') || URI.parse(@url).path.split("/")[3]
|
15
|
+
@feed = nil
|
16
|
+
|
17
|
+
# veeeeeery ugly
|
18
|
+
page = Hpricot(open(url))
|
19
|
+
searchterms = page.search("//title").first.inner_html.split("Music Video")
|
20
|
+
res = Net::HTTP.get(URI.parse("http://api.mtvnservices.com/1/video/search/?term=#{searchterms[0].gsub(' ', '%20')}"))
|
21
|
+
search = REXML::Document.new(res)
|
22
|
+
entries = search.elements.to_a("//entry")
|
23
|
+
entries.each do |entry|
|
24
|
+
if REXML::XPath.first(entry, "media:content" ).attributes['url'] == "http://media.mtvnservices.com/mgid:uma:video:api.mtvnservices.com:#{@video_id}"
|
25
|
+
@feed = entry
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def title
|
31
|
+
REXML::XPath.first(@feed, "//entry/title")[0].to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
def thumbnail
|
35
|
+
REXML::XPath.first(@feed, "//media:thumbnail").attributes['url']
|
36
|
+
end
|
37
|
+
|
38
|
+
def duration
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def embed_url
|
43
|
+
REXML::XPath.first(@feed, "//media:content[@type='application/x-shockwave-flash']").attributes['url']
|
44
|
+
end
|
45
|
+
|
46
|
+
def embed_html(width=425, height=344, options={})
|
47
|
+
"<embed src='#{embed_url}' width='#{width}' height='#{height}' type='application/x-shockwave-flash' flashVars='dist=http://www.mtvmusic.com' allowFullScreen='true' AllowScriptAccess='never'></embed>"
|
48
|
+
end
|
49
|
+
|
50
|
+
# this method fails depending on country restrictions
|
51
|
+
def flv
|
52
|
+
res = Net::HTTP.get(URI.parse("http://api-media.mtvnservices.com/player/embed/includes/mediaGen.jhtml?uri=mgid:uma:video:api.mtvnservices.com:#{@video_id}&vid=#{@video_id}&ref=#{CGI::escape "{ref}"}"))
|
53
|
+
search = REXML::Document.new(res)
|
54
|
+
REXML::XPath.first(search, "//rendition/src")[0]
|
55
|
+
end
|
56
|
+
|
57
|
+
def download_url
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def service
|
62
|
+
"MTV Music"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Myspace (vids.myspace.com)
|
3
|
+
# http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=27111431
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgMyspace
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
@video_id = @url.query_param('videoid').blank? ? @url.query_param('VideoID') : @url.query_param('videoid')
|
12
|
+
res = Net::HTTP.get(URI.parse("http://mediaservices.myspace.com/services/rss.ashx?type=video&videoID=#{@video_id}"))
|
13
|
+
@feed = REXML::Document.new(res)
|
14
|
+
end
|
15
|
+
|
16
|
+
def title
|
17
|
+
REXML::XPath.first(@feed, "//item/title")[0].to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def thumbnail
|
21
|
+
REXML::XPath.first(@feed, "//media:thumbnail").attributes['url']
|
22
|
+
end
|
23
|
+
|
24
|
+
def duration
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def embed_url
|
29
|
+
"http://lads.myspace.com/videos/vplayer.swf?m=#{REXML::XPath.first( @feed, "//myspace:itemID" )[0]}&v=2&type=video"
|
30
|
+
end
|
31
|
+
|
32
|
+
def embed_html(width=425, height=344, options={})
|
33
|
+
"<embed src='#{embed_url}' type='application/x-shockwave-flash' width='#{width}' height='#{height}'></embed>"
|
34
|
+
end
|
35
|
+
|
36
|
+
def flv
|
37
|
+
REXML::XPath.first(@feed, "//media:content").attributes['url']
|
38
|
+
end
|
39
|
+
|
40
|
+
def download_url
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def service
|
45
|
+
"Myspace"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|