acts_as_unvlogable_fork 1.0.1 → 1.0.4

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.
@@ -1,4 +1,3 @@
1
-
2
1
  class String
3
2
  def query_param(param_name)
4
3
  raise ArgumentError.new("param name can't be nil") if param_name.blank?
@@ -1,3 +1,3 @@
1
1
  module ActsAsUnvlogable
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -7,17 +7,16 @@
7
7
  class Vg11870
8
8
 
9
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])
10
+ @url = url.sub "http:", "https:"
11
+ @page = Nokogiri::HTML(open(@url))
13
12
  end
14
13
 
15
14
  def title
16
- CGI::unescapeHTML @page.search("//h1[@class='fn name']/a").first.inner_html
15
+ CGI::unescapeHTML @page.xpath("//span[@itemprop='name']").first.text.strip
17
16
  end
18
17
 
19
18
  def thumbnail
20
- @flashvars['image']
19
+ @page.xpath("//img[@itemprop='image']").first["src"]
21
20
  end
22
21
 
23
22
  def duration
@@ -25,8 +24,7 @@ class Vg11870
25
24
  end
26
25
 
27
26
  def embed_url
28
- query = @flashvars.map {|k,v| "&#{k}=#{v}"}
29
- "http://11870.com/multimedia/flvplayer.swf?#{query}"
27
+ "https://s3-eu-west-1.amazonaws.com/static.11870.com/11870/player.swf?netstreambasepath=#{@url}&id=video&file=#{flv}&image=#{thumbnail}"
30
28
  end
31
29
 
32
30
  def embed_html(width=425, height=344, options={}, params={})
@@ -34,7 +32,7 @@ class Vg11870
34
32
  end
35
33
 
36
34
  def flv
37
- @flashvars['file']
35
+ @page.xpath("//div[@id='video']/span").first.text.strip
38
36
  end
39
37
 
40
38
  def download_url
@@ -17,7 +17,7 @@ class VgBlip
17
17
  end
18
18
 
19
19
  def thumbnail
20
- REXML::XPath.first(@feed, "//blip:smallThumbnail")[0].to_s
20
+ REXML::XPath.first(@feed, "//media:thumbnail").attributes['url']
21
21
  end
22
22
 
23
23
  def duration
@@ -25,18 +25,13 @@ class VgBlip
25
25
  end
26
26
 
27
27
  def embed_url
28
- emb = REXML::XPath.first(@feed, "//media:player")[0].to_s
29
- emb.split("src=\"")[1].split("\"")[0]
28
+ emb = REXML::XPath.first(@feed, "//blip:embedUrl")[0].to_s
30
29
  end
31
30
 
32
31
  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>"
32
+ "<iframe src='#{embed_url}.x?p=1' width='#{width}' height='#{height}' frameborder='0' allowfullscreen></iframe>"
34
33
  end
35
34
 
36
- def flv
37
- REXML::XPath.first(@feed, "//enclosure").attributes['url']
38
- end
39
-
40
35
  def download_url
41
36
  nil
42
37
  end
@@ -22,17 +22,13 @@ class VgCollegehumor
22
22
  end
23
23
 
24
24
  def embed_url
25
- "http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=#{@video_id}&fullscreen=1"
25
+ "http://www.collegehumor.com/e/#{@video_id}"
26
26
  end
27
27
 
28
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>"
29
+ "<iframe src='#{embed_url}' width='#{width}' height='#{height}' frameborder='0' webkitAllowFullScreen allowFullScreen></iframe>"
30
30
  end
31
31
 
32
- def flv
33
- REXML::XPath.first(@feed, "//video/file")[0]
34
- end
35
-
36
32
  def download_url
37
33
  nil
38
34
  end
@@ -22,18 +22,13 @@ class VgDailymotion
22
22
  end
23
23
 
24
24
  def embed_url
25
- REXML::XPath.first(@feed, "//media:content[@type='application/x-shockwave-flash']").attributes['url']
25
+ REXML::XPath.first(@feed, "//media:content[@type='text/html']").attributes['url']
26
26
  end
27
27
 
28
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>"
29
+ "<iframe frameborder='0' width='#{width}' height='#{height}' src='#{embed_url}' allowfullscreen></iframe>"
30
30
  end
31
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
32
  def download_url
38
33
  nil
39
34
  end
@@ -12,19 +12,19 @@ class VgDalealplay
12
12
  def initialize(url=nil, options={})
13
13
  @url = url
14
14
  @video_id = @url.query_param('con')
15
- @page = open(url) {|f| Hpricot(f.read.encode("UTF-8")) }
15
+ @page = Nokogiri::HTML(open(@url))
16
16
  end
17
17
 
18
18
  def title
19
- @page.search("//title").inner_html.split(" - Vídeo Online")[0].to_s
19
+ @page.xpath("//h1").first.text
20
20
  end
21
21
 
22
22
  def thumbnail
23
- "http://images-00.dalealplay.com/contenidos2/#{@video_id}/captura.jpg"
23
+ @page.xpath("//meta[@itemprop='image']").first["content"]
24
24
  end
25
25
 
26
26
  def embed_url
27
- @page.search("//link[@rel='video_src']").first.attributes["href"].sub("autoStart=true", "autoStart=false")
27
+ @page.xpath("//meta[@itemprop='embedUrl']").first["content"]
28
28
  end
29
29
 
30
30
  def duration
@@ -32,13 +32,9 @@ class VgDalealplay
32
32
  end
33
33
 
34
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>"
35
+ "<iframe frameborder='0' marginwidth='0' marginheight ='0' id='videodap' scrolling='no' width='#{width}' height='#{height}' src='#{embed_url}'></iframe>"
36
36
  end
37
37
 
38
- def flv
39
- "http://videos.dalealplay.com/contenidos3/#{CGI::parse(URI::parse(embed_url).query)['file']}"
40
- end
41
-
42
38
  def download_url
43
39
  nil
44
40
  end
@@ -31,20 +31,6 @@ class VgFlickr
31
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
32
  end
33
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
34
  def download_url
49
35
  nil
50
36
  end
@@ -9,10 +9,8 @@ class VgMetacafe
9
9
  def initialize(url=nil, options={})
10
10
  @url = url
11
11
  @args = parse_url(url)
12
-
13
- #is the video 'youtubed'?
14
12
  @youtubed = @args[1].index("yt-").nil? ? false : true
15
- @yt = @youtubed ? VgYoutube.new("http://www.youtube.com/watch?v=#{@args[1].sub('yt-', '')}") : nil
13
+ @yt = @youtubed ? VgYoutube.new("http://www.youtube.com/watch?v=#{@args[1].sub('yt-', '')}", options) : nil
16
14
  end
17
15
 
18
16
  def title
@@ -28,29 +26,13 @@ class VgMetacafe
28
26
  end
29
27
 
30
28
  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>"
29
+ "<iframe src='#{embed_url}' width='#{width}' height='#{height}' allowFullScreen frameborder=0></iframe>"
32
30
  end
33
31
 
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
32
  def duration
47
33
  nil
48
34
  end
49
35
 
50
- def download_url
51
- nil
52
- end
53
-
54
36
  def service
55
37
  "Metacafe"
56
38
  end
@@ -64,7 +46,6 @@ class VgMetacafe
64
46
  if path and path.split("/").size >=1
65
47
  @args = path.split("/")
66
48
  @args.delete("watch")
67
-
68
49
  raise unless @args.size > 0
69
50
  else
70
51
  raise
@@ -8,17 +8,15 @@ class VgMyspace
8
8
 
9
9
  def initialize(url=nil, options={})
10
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)
11
+ @page = Nokogiri::HTML(open(@url))
14
12
  end
15
13
 
16
14
  def title
17
- REXML::XPath.first(@feed, "//item/title")[0].to_s
15
+ @page.xpath("//meta[@property='og:title']").first["content"].split("Video by")[0].strip
18
16
  end
19
17
 
20
18
  def thumbnail
21
- REXML::XPath.first(@feed, "//media:thumbnail").attributes['url']
19
+ @page.xpath("//meta[@property='og:image']").first["content"].strip
22
20
  end
23
21
 
24
22
  def duration
@@ -26,17 +24,13 @@ class VgMyspace
26
24
  end
27
25
 
28
26
  def embed_url
29
- "http://lads.myspace.com/videos/vplayer.swf?m=#{REXML::XPath.first( @feed, "//myspace:itemID" )[0]}&v=2&type=video"
27
+ @page.xpath("//meta[@name='twitter:player']").first["content"].strip
30
28
  end
31
29
 
32
30
  def embed_html(width=425, height=344, options={}, params={})
33
- "<embed src='#{embed_url}' type='application/x-shockwave-flash' width='#{width}' height='#{height}'></embed>"
31
+ "<iframe width='#{width}' height='#{height}' src='#{embed_url}' frameborder='0' allowtransparency='true' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>"
34
32
  end
35
33
 
36
- def flv
37
- REXML::XPath.first(@feed, "//media:content").attributes['url']
38
- end
39
-
40
34
  def download_url
41
35
  nil
42
36
  end
@@ -1,12 +1,4 @@
1
- # ----------------------------------------------
2
- # Class for prostopleer.com
3
- # http://prostopleer.com/tracks/401758bI6n
4
- # ----------------------------------------------
5
-
6
- require 'hpricot'
7
-
8
- class VgProstopleer
9
-
1
+ class VgPleer
10
2
  attr_accessor :track_id
11
3
 
12
4
  def initialize(url, options={})
@@ -21,18 +13,18 @@ class VgProstopleer
21
13
  end
22
14
 
23
15
  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>"
16
+ "<object width=\"#{width}\" height=\"#{height}\"><param name=\"movie\" value=\"http://embed.pleer.com/track?id=#{track_id}\"></param><embed src=\"http://embed.pleer.com/track?id=#{track_id}\" type=\"application/x-shockwave-flash\" width=\"#{width}\" height=\"#{height}\"></embed></object>"
25
17
  end
26
18
 
27
19
  def service
28
- "ProstoPleer"
20
+ "Pleer"
29
21
  end
30
22
 
31
23
  private
32
24
  def pp_data
33
25
  return @pp_data if defined? @pp_data
34
- hp = Hpricot.parse(Net::HTTP.get(@uri))
35
- info = (hp/'li[@singer]').first
26
+ page = Nokogiri::HTML(Net::HTTP.get(@uri))
27
+ info = page.xpath('//li[@singer]').first
36
28
  @pp_data = {
37
29
  :singer => info['singer'], # artist name
38
30
  :song => info['song'], # song title
@@ -43,4 +35,4 @@ class VgProstopleer
43
35
  :rate => info['rate'] # bit rate
44
36
  }
45
37
  end
46
- end
38
+ end
@@ -2,45 +2,23 @@ class VgRutube
2
2
 
3
3
  def initialize(url=nil, options={})
4
4
  @url = url
5
- parse_url(url)
5
+ @page = Nokogiri::HTML(open(@url)) rescue nil
6
+ raise ArgumentError.new("Unsuported url or service") if @page.xpath("//meta[@property='og:video:iframe']").blank?
6
7
  end
7
8
 
8
9
  def title
9
- rt_info["movie"][0]["title"][0].strip
10
+ @page.xpath("//meta[@property='og:title']").first["content"].strip
10
11
  end
11
-
12
- # this method of extraction is somewhat fragile to changes in RuTube urls
13
- # more correct way would be using rt_info structure, like it was done in title()
14
12
  def thumbnail
15
- # size=1 gives bigger thumbnail.
16
- # I'm not sure how to add size parameter in compatible way
17
- size = 2
18
- "http://img.rutube.ru/thumbs/#{movie_hash[0,2]}/#{movie_hash[2,2]}/#{movie_hash}-#{size}.jpg"
13
+ @page.xpath("//meta[@property='og:image']").first["content"].strip
19
14
  end
20
15
 
21
16
  def embed_url
22
- # path to swf
23
- "http://video.rutube.ru/#{movie_hash}"
17
+ @page.xpath("//meta[@property='og:video:iframe']").first["content"].strip
24
18
  end
25
19
 
26
20
  def embed_html(width=425, height=344, options={}, params={})
27
- # overridden cause we have to change default size if needed
28
- return <<-"END"
29
- <object width="#{width}" height="#{height}"><param
30
- name="movie" value="#{embed_url}"></param><param
31
- name="wmode" value="window"></param><param
32
- name="allowFullScreen" value="true"></param><embed
33
- src="#{embed_url}" type="application/x-shockwave-flash"
34
- wmode="window" width="#{width}" height="#{height}"
35
- allowFullScreen="true"></embed>
36
- </object>
37
- END
38
- end
39
-
40
- def flv
41
- # Fragile, untested, issues one redirect to actual location
42
- # can't be extracted from rt_info
43
- "http://bl.rutube.ru/#{movie_hash}.iflv"
21
+ "<iframe width='#{width}' height='#{height}' src='#{embed_url}' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>"
44
22
  end
45
23
 
46
24
  def download_url
@@ -55,26 +33,4 @@ class VgRutube
55
33
  "Rutube"
56
34
  end
57
35
 
58
- private
59
-
60
- attr_accessor :movie_id
61
- RT_XML_API = "http://rutube.ru/cgi-bin/xmlapi.cgi"
62
-
63
- def movie_hash
64
- @movie_hash ||= rt_info["movie"][0]["playerLink"][0].match( %r{[a-f0-9]+$} )[0]
65
- end
66
-
67
- def rt_info
68
- url = RT_XML_API + "?rt_movie_id=#{movie_id}&rt_mode=movie"
69
- @rt_info ||= XmlSimple.xml_in( Net::HTTP.get_response( URI.parse(url) ).body )
70
- end
71
-
72
- def parse_url(url)
73
- uri = URI.parse(url)
74
- @movie_id = uri.path.match(/\d+/)[0]
75
- # this doesn't work reliably:
76
- # @movie_hash = uri.query.match(/(^|&)v=([^&]+)/)[2]
77
- # we'll cut it from rt_info instead
78
- end
79
-
80
36
  end
@@ -8,20 +8,16 @@ class VgTed
8
8
 
9
9
  def initialize(url=nil, options={})
10
10
  @url = url
11
- raise unless URI::parse(url).path.split("/").include? "talks"
12
- @page = Hpricot(open(url))
13
- id = @page.to_s.split("ted id=")[1].split("\]")[0]
14
- @emb = Hpricot(open("http://www.ted.com/talks/embed/id/#{id}"))
15
- @flashvars = CGI::unescapeHTML(@emb.to_s).split("param name=\"flashvars\" value=\"")[1].split("\"")[0]
16
- @args = CGI::parse(@flashvars)
11
+ raise ArgumentError.new("Unsuported url or service") unless URI::parse(url).path.split("/").include? "talks"
12
+ @page = Nokogiri::HTML(open(@url))
17
13
  end
18
14
 
19
15
  def title
20
- @page.search("//h1/span").first.inner_html.strip
16
+ @page.xpath("//meta[@property='og:title']").first["content"].strip
21
17
  end
22
18
 
23
19
  def thumbnail
24
- "#{@args['su']}"
20
+ @page.xpath("//meta[@property='og:image']").first["content"].strip
25
21
  end
26
22
 
27
23
  def duration
@@ -29,15 +25,11 @@ class VgTed
29
25
  end
30
26
 
31
27
  def embed_url
32
- "http://video.ted.com/assets/player/swf/EmbedPlayer.swf?#{@flashvars}"
28
+ @page.xpath("//link[@itemprop='embedURL']").first["href"].strip
33
29
  end
34
30
 
35
31
  def embed_html(width=425, height=344, options={}, params={})
36
- "<object width='#{width}' height='#{height}'><param name='movie' value='#{embed_url}'></param><param name='allowFullScreen' value='true' /><param name='wmode' value='transparent'></param><param name='bgColor' value='#ffffff'></param><embed src='#{embed_url}' pluginspace='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='transparent' bgColor='#ffffff' width='#{width}' height='#{height}' allowFullScreen='true'></embed></object>"
37
- end
38
-
39
- def flv
40
- "#{@args['vu'].to_s}"
32
+ "<iframe src='#{embed_url}' width='#{width}' height='#{height}' frameborder='0' scrolling='no' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>"
41
33
  end
42
34
 
43
35
  def download_url
@@ -10,16 +10,6 @@ class VgVimeo
10
10
  # general settings
11
11
  @url = url
12
12
  @video_id = parse_url(url)
13
-
14
- if !(@vimeo_id =~ /^[0-9]+$/)
15
- r = Net::HTTP.get_response(URI.parse(url))
16
-
17
- if r.code == "301"
18
- @url = "http://vimeo.com#{r.header['location']}"
19
- @video_id = parse_url(@url)
20
- end
21
- end
22
-
23
13
  res = Net::HTTP.get(URI.parse("http://vimeo.com/api/v2/video/#{@video_id}.xml"))
24
14
  @feed = REXML::Document.new(res)
25
15
  end
@@ -41,24 +31,15 @@ class VgVimeo
41
31
  end
42
32
 
43
33
  def embed_url
44
- "http://vimeo.com/moogaloop.swf?clip_id=#{@video_id}&amp;force_embed=1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=1&amp;color=ffffff&amp;fullscreen=1&amp;autoplay=0&amp;loop=0"
34
+ "http://http://player.vimeo.com/video/#{@video_id}"
45
35
  end
46
36
 
47
37
  def embed_html(width=425, height=344, options={}, params={})
48
- "<object width='#{width}' height='#{height}'><param name='movie' value='#{embed_url}'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='#{embed_url}' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>"
49
- end
50
-
51
- def flv
52
- res = Net::HTTP.get(URI.parse("http://vimeo.com/42966264?action=download"))
53
- request_signature = res.split("\"signature\":\"")[1].split("\"")[0]
54
- request_cached_timestamp = res.split("\"cached_timestamp\":")[1].split(",")[0]
55
- "http://player.vimeo.com/play_redirect?clip_id=#{@video_id}&sig=#{request_signature}&time=#{request_cached_timestamp}&quality=sd&codecs=H264,VP8,VP6&type=moogaloop&embed_location="
38
+ "<iframe src='#{embed_url}' width='#{width}' height='#{height}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>"
56
39
  end
57
40
 
58
41
  def download_url
59
- request_signature = REXML::XPath.first( @feed, "//request_signature" )[0]
60
- request_signature_expires = REXML::XPath.first( @feed, "//request_signature_expires" )[0]
61
- "http://www.vimeo.com/moogaloop/play/clip:#{@video_id}/#{request_signature}/#{request_signature_expires}/?q=hd"
42
+ nil
62
43
  end
63
44
 
64
45
  def service