Class: WWW::VideoScraper::NicoVideo

Inherits:
Base
  • Object
show all
Defined in:
lib/www/video_scraper/nico_video.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



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

def scrape
  begin
    
    id = url_regex_match[1]
    get_flv(id)
    get_thumb(id)
    get_embed_tag(id)
  rescue Timeout::Error => e
    raise TryAgainLater, e.to_s
  rescue WWW::Mechanize::ResponseCodeError => e
    case e.response_code
    when '404', '403'
      raise FileNotFound, e.to_s
    when '502'
      raise TryAgainLater, e.to_s
    else
      raise TryAgainLater, e.to_s
    end
  end
end