Class: WWW::VideoScraper::Pornotube

Inherits:
Base
  • Object
show all
Defined in:
lib/www/video_scraper/pornotube.rb

Instance Attribute Summary

Attributes inherited from Base

#embed_tag, #page_url, #thumb_url, #title, #video_url

Instance Method Summary collapse

Methods inherited from Base

#initialize, scrape, url_regex, valid_url?

Constructor Details

This class inherits a constructor from WWW::VideoScraper::Base

Instance Method Details

#scrapeObject

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/www/video_scraper/pornotube.rb', line 10

def scrape
  id = url_regex_match[1]

  
  page = agent.get(@page_url)
  raise FileNotFound unless embed = page.root.at('//object/embed')
  src = embed.attributes['src']
  hash = src.to_s.match(/\?v=(.*)$/)[1]
  t = page.at('//div[@class="contentheader"]//span[@class="blue"]')
  @title = t.inner_html.gsub(/<[^>]*>/, '').strip
  page = agent.get("http://pornotube.com/player/player.php?#{hash}")
  q = CGI::parse(page.body)
  @video_url = "http://#{q['mediaDomain'][0]}.pornotube.com/#{q['userId'][0]}/#{q['mediaId'][0]}.flv"
  @thumb_url = "http://photo.pornotube.com/thumbnails/video/#{q['userId'][0]}/#{q['mediaId'][0]}.jpg";
  @image_url = "http://photo.pornotube.com/thumbnails/video/#{q['userId'][0]}/#{q['mediaId'][0]}_full.jpg";
  @embed_tag = q['embedCode'][0]
end