Changeset 32340 for lang/ruby

Show
Ignore:
Timestamp:
04/13/09 13:11:05 (5 years ago)
Author:
valda
Message:

veoh の URL のバリエーションを追加

Location:
lang/ruby/video_scraper
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/video_scraper/lib/www/video_scraper/veoh.rb

    r30120 r32340  
    66  module VideoScraper 
    77    class Veoh < Base 
    8       url_regex [%r!\Ahttp://www\.veoh\.com/videos/([[:alnum:]]+)!, 
    9                  %r!\Ahttp://www\.veoh\.com/collection/\w+/watch/.*#watch%3[Dd]([[:alnum:]]+)!, 
    10                  %r!\Ahttp://www\.veoh\.com/collection/\w+/watch/([[:alnum:]]+)!] 
     8      url_regex [%r!\Ahttp://www\.veoh\.com/videos/(v\d+[[:alnum:]]+)!, 
     9                 %r!\Ahttp://www\.veoh\.com/collection/\w+/watch/.*#watch%3[Dd](v\d+[[:alnum:]]+)!, 
     10                 %r!\Ahttp://www\.veoh\.com/(?:browse|collection)/(?:[\w]+/)+watch/(v\d+[[:alnum:]]+)!] 
    1111 
    1212      def scrape 
     
    1919        @thumb_url = xml.match(/fullMedResImagePath="([^"]+)"/).to_a[1] 
    2020        html = http_get(@page_url) 
    21         if embed_tag = html.match(/\sid="embed"\s[^>]*value="([^"]+)"/).to_a[1] 
     21        #logger.debug html 
     22        if embed_tag = html.match(/class="embedinput"\s[^>]*value="([^"]+)"/).to_a[1] 
    2223          @embed_tag = CGI.unescapeHTML(embed_tag) 
    2324        end 
  • lang/ruby/video_scraper/test/www/video_scraper/test_veoh.rb

    r30120 r32340  
    99    assert_match %r|http://content\.veoh\.com/flash/p/\d/[[:alnum:]]{16}/[[:alnum:]]{40}\.fll\?ct=[[:alnum:]]{48}|, vs.video_url 
    1010    assert_match %r|http://p-images\.veoh\.com/image\.out\?imageId=media-[[:alnum:]]+.jpg|, vs.thumb_url 
    11     assert_match %r|^<embed\s.*>$|, vs.embed_tag 
     11    assert_match %r|^<object\s.*>$|, vs.embed_tag 
    1212  end 
    1313 
     
    1919    vs = WWW::VideoScraper::Veoh.scrape('http://www.veoh.com/videos/v19937773gwSJPMk?rank=0&jsonParams=%7B%22numResults%22%3A20%2C%22rlmin%22%3A0%2C%22query%22%3A%22Shaman+King+01%22%2C%22rlmax%22%3Anull%2C%22veohOnly%22%3Atrue%2C%22order%22%3A%22default%22%2C%22range%22%3A%22a%22%2C%22sId%22%3A%22192998624295114150%22%7D&searchId=192998624295114150&rank=1', default_opt) 
    2020    assert_equal 'http://www.veoh.com/videos/v19937773gwSJPMk', vs.page_url 
     21    vs = WWW::VideoScraper::Veoh.scrape('http://www.veoh.com/browse/videos/category/comedy/watch/v17078605sszQzbBF') 
     22    assert_equal 'http://www.veoh.com/videos/v17078605sszQzbBF', vs.page_url 
    2123  end 
    2224end