Class: WWW::VideoScraper::Tube8
- Defined in:
- lib/www/video_scraper/tube8.rb
Instance Attribute Summary collapse
-
#video_url_3gp ⇒ Object
readonly
Returns the value of attribute video_url_3gp.
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 Attribute Details
#video_url_3gp ⇒ Object (readonly)
Returns the value of attribute video_url_3gp.
8 9 10 |
# File 'lib/www/video_scraper/tube8.rb', line 8 def video_url_3gp @video_url_3gp end |
Instance Method Details
#scrape ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/www/video_scraper/tube8.rb', line 11 def scrape html = http_get(@page_url) doc = Hpricot(html.toutf8) raise FileNotFound unless flashvars = doc.at('//object //param[@name="FlashVars"]') flashvars = CGI.parse(flashvars.attributes['value']) @video_url = flashvars['videoUrl'][0] uri = URI.parse(@page_url) @thumb_url = URI.join("#{uri.scheme}://#{uri.host}", flashvars['imageUrl'][0]).to_s @title = doc.at('//h1[@class="text"]').inner_html rescue nil doc.search('//a').each do |elem| if href = elem.attributes['href'] if href.match(/\.3gp$/) @video_url_3gp = href break end end end end |