acts_as_unvlogable_fork 1.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +16 -0
- data/Gemfile +14 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +130 -0
- data/Rakefile +2 -0
- data/acts_as_unvlogable.gemspec +25 -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 +48 -0
- data/lib/acts_as_unvlogable/vg_blip.rb +48 -0
- data/lib/acts_as_unvlogable/vg_collegehumor.rb +58 -0
- data/lib/acts_as_unvlogable/vg_dailymotion.rb +67 -0
- data/lib/acts_as_unvlogable/vg_dalealplay.rb +50 -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_myspace.rb +48 -0
- data/lib/acts_as_unvlogable/vg_prostopleer.rb +46 -0
- data/lib/acts_as_unvlogable/vg_qik.rb +64 -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 +89 -0
- data/lib/acts_as_unvlogable/vg_youtu.rb +11 -0
- data/lib/acts_as_unvlogable/vg_youtube.rb +67 -0
- data/lib/acts_as_unvlogable.rb +117 -0
- data/test/acts_as_unvlogable_test.rb +392 -0
- data/test/video_factory_test.rb +66 -0
- data/unvlogable_sample.yml +5 -0
- metadata +137 -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,48 @@
|
|
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 = CGI::parse(@page.to_s.split("flashvars="")[1].split(""")[0])
|
13
|
+
end
|
14
|
+
|
15
|
+
def title
|
16
|
+
CGI::unescapeHTML @page.search("//h1[@class='fn name']/a").first.inner_html
|
17
|
+
end
|
18
|
+
|
19
|
+
def thumbnail
|
20
|
+
@flashvars['image']
|
21
|
+
end
|
22
|
+
|
23
|
+
def duration
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def embed_url
|
28
|
+
query = @flashvars.map {|k,v| "&#{k}=#{v}"}
|
29
|
+
"http://11870.com/multimedia/flvplayer.swf?#{query}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def embed_html(width=425, height=344, options={}, params={})
|
33
|
+
"<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>"
|
34
|
+
end
|
35
|
+
|
36
|
+
def flv
|
37
|
+
@flashvars['file']
|
38
|
+
end
|
39
|
+
|
40
|
+
def download_url
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def service
|
45
|
+
"11870.com"
|
46
|
+
end
|
47
|
+
|
48
|
+
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={}, params={})
|
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,58 @@
|
|
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={}, params={})
|
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 = path.split("/")
|
54
|
+
raise unless videoargs.size > 0 && videoargs[1] == 'video'
|
55
|
+
videoargs[2]
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,67 @@
|
|
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={}, params={})
|
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
|
+
doc = URI::parse("http://dailymotion.com/embed/video/#{@video_id}").read
|
34
|
+
doc = URI::parse("#{doc.split("stream_h264_url\":\"")[1].split("\"")[0].gsub("\\", "")}&redirect=0").read
|
35
|
+
end
|
36
|
+
|
37
|
+
def download_url
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def duration
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def service
|
46
|
+
"Dailymotion"
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def parse_url(url)
|
52
|
+
uri = URI.parse(url)
|
53
|
+
path = uri.path
|
54
|
+
videoargs = ''
|
55
|
+
if path
|
56
|
+
videoargs = path.split('/video/')[1].split("/")[0]
|
57
|
+
raise unless videoargs.size > 0
|
58
|
+
else
|
59
|
+
raise
|
60
|
+
end
|
61
|
+
videoargs
|
62
|
+
rescue
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# ----------------------------------------------
|
3
|
+
# Class for dalealplay (dalealplay.com)
|
4
|
+
# http://www.dalealplay.com/informaciondecontenido.php?con=80280
|
5
|
+
#
|
6
|
+
# Crappy without api
|
7
|
+
# ----------------------------------------------
|
8
|
+
|
9
|
+
|
10
|
+
class VgDalealplay
|
11
|
+
|
12
|
+
def initialize(url=nil, options={})
|
13
|
+
@url = url
|
14
|
+
@video_id = @url.query_param('con')
|
15
|
+
@page = open(url) {|f| Hpricot(f.read.encode("UTF-8")) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
@page.search("//title").inner_html.split(" - Vídeo Online")[0].to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def thumbnail
|
23
|
+
"http://images-00.dalealplay.com/contenidos2/#{@video_id}/captura.jpg"
|
24
|
+
end
|
25
|
+
|
26
|
+
def embed_url
|
27
|
+
@page.search("//link[@rel='video_src']").first.attributes["href"].sub("autoStart=true", "autoStart=false")
|
28
|
+
end
|
29
|
+
|
30
|
+
def duration
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def embed_html(width=425, height=344, options={}, params={})
|
35
|
+
"<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>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def flv
|
39
|
+
"http://videos.dalealplay.com/contenidos3/#{CGI::parse(URI::parse(embed_url).query)['file']}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def download_url
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def service
|
47
|
+
"dalealplay"
|
48
|
+
end
|
49
|
+
|
50
|
+
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={}, params={})
|
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={}, params={})
|
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={}, params={})
|
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,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={}, params={})
|
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
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for prostopleer.com
|
3
|
+
# http://prostopleer.com/tracks/401758bI6n
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
require 'hpricot'
|
7
|
+
|
8
|
+
class VgProstopleer
|
9
|
+
|
10
|
+
attr_accessor :track_id
|
11
|
+
|
12
|
+
def initialize(url, options={})
|
13
|
+
@uri = URI.parse(url)
|
14
|
+
@track_id = @uri.path.match(/tracks\/([\w\d]+)/)[1]
|
15
|
+
@url = url
|
16
|
+
raise ArgumentError unless @track_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def title
|
20
|
+
@title ||= [pp_data[:singer], pp_data[:song]].join(' - ')
|
21
|
+
end
|
22
|
+
|
23
|
+
def embed_html(width=425, height=344, options={}, params={})
|
24
|
+
return "<object width=\"#{width}\" height=\"#{height}\"><param name=\"movie\" value=\"http://embed.prostopleer.com/track?id=#{track_id}\"></param><embed src=\"http://embed.prostopleer.com/track?id=#{track_id}\" type=\"application/x-shockwave-flash\" width=\"#{width}\" height=\"#{height}\"></embed></object>"
|
25
|
+
end
|
26
|
+
|
27
|
+
def service
|
28
|
+
"ProstoPleer"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def pp_data
|
33
|
+
return @pp_data if defined? @pp_data
|
34
|
+
hp = Hpricot.parse(Net::HTTP.get(@uri))
|
35
|
+
info = (hp/'li[@singer]').first
|
36
|
+
@pp_data = {
|
37
|
+
:singer => info['singer'], # artist name
|
38
|
+
:song => info['song'], # song title
|
39
|
+
:file_id => info['file_id'], # wtf
|
40
|
+
:link => info['link'], # same as @track_id
|
41
|
+
:duration => info['duration'], # duration of the song in seconds
|
42
|
+
:size => info['size'], # file size
|
43
|
+
:rate => info['rate'] # bit rate
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Qik (qik.com)
|
3
|
+
# http://qik.com/video/340982
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
|
7
|
+
class VgQik
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
@video_id = parse_url(url)
|
12
|
+
h = {"Content-Type" => "application/json"}
|
13
|
+
@page = Net::HTTP.start("engine.qik.com", "80") do |connection|
|
14
|
+
JSON.parse(connection.post("/api/jsonrpc?apikey=e53d41680124e6d0", {:method => "qik.stream.public_info", :params => [340982]}.to_json, h).body)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
@page[0]['title']
|
20
|
+
end
|
21
|
+
|
22
|
+
def thumbnail
|
23
|
+
@page[0]['large_thumbnail_url']
|
24
|
+
end
|
25
|
+
|
26
|
+
def embed_url
|
27
|
+
"http://qik.com/swfs/qikPlayer5.swf?streamID=#{@page[0]['embed_html'].split("streamID=")[1].split("&")[0]}&autoplay=false"
|
28
|
+
end
|
29
|
+
|
30
|
+
def embed_html(width=425, height=344, options={}, params={})
|
31
|
+
@page[0]['embed_html']
|
32
|
+
end
|
33
|
+
|
34
|
+
def flv
|
35
|
+
"http://media.qik.com/vod/flvs-play?assetId=#{@page[0]['embed_html'].split("streamID=")[1].split("&")[0]}&profile=flvs-normal"
|
36
|
+
end
|
37
|
+
|
38
|
+
def download_url
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def duration
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def service
|
47
|
+
"Qik"
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def parse_url(url)
|
53
|
+
video_id = nil
|
54
|
+
if url.split('#').size > 1
|
55
|
+
pieces = url.split(/#|=/)
|
56
|
+
hash = Hash[*pieces]
|
57
|
+
video_id = hash['v']
|
58
|
+
else
|
59
|
+
video_id = url.split("/")[4]
|
60
|
+
end
|
61
|
+
video_id
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|