- Timestamp:
- 04/13/09 13:11:05 (4 years ago)
- Location:
- lang/ruby/video_scraper
- Files:
-
- 2 modified
-
lib/www/video_scraper/veoh.rb (modified) (2 diffs)
-
test/www/video_scraper/test_veoh.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/video_scraper/lib/www/video_scraper/veoh.rb
r30120 r32340 6 6 module VideoScraper 7 7 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:]]+)!] 11 11 12 12 def scrape … … 19 19 @thumb_url = xml.match(/fullMedResImagePath="([^"]+)"/).to_a[1] 20 20 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] 22 23 @embed_tag = CGI.unescapeHTML(embed_tag) 23 24 end -
lang/ruby/video_scraper/test/www/video_scraper/test_veoh.rb
r30120 r32340 9 9 assert_match %r|http://content\.veoh\.com/flash/p/\d/[[:alnum:]]{16}/[[:alnum:]]{40}\.fll\?ct=[[:alnum:]]{48}|, vs.video_url 10 10 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_tag11 assert_match %r|^<object\s.*>$|, vs.embed_tag 12 12 end 13 13 … … 19 19 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) 20 20 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 21 23 end 22 24 end
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)