valda-video_scraper 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/lib/www/video_scraper.rb +12 -12
- data/lib/www/video_scraper/adult_satellites.rb +27 -0
- data/lib/www/video_scraper/age_sage.rb +1 -7
- data/lib/www/video_scraper/ameba_vision.rb +1 -7
- data/lib/www/video_scraper/base.rb +23 -3
- data/lib/www/video_scraper/dailymotion.rb +1 -7
- data/lib/www/video_scraper/moro_tube.rb +1 -7
- data/lib/www/video_scraper/nico_video.rb +19 -24
- data/lib/www/video_scraper/pornhub.rb +1 -7
- data/lib/www/video_scraper/pornotube.rb +11 -16
- data/lib/www/video_scraper/red_tube.rb +42 -22
- data/lib/www/video_scraper/tube8.rb +10 -7
- data/lib/www/video_scraper/veoh.rb +4 -10
- data/lib/www/video_scraper/you_porn.rb +1 -7
- data/lib/www/video_scraper/you_tube.rb +16 -21
- data/lib/www/video_scraper/your_file_host.rb +1 -7
- data/test/test_helper.rb +15 -0
- data/test/www/test_video_scraper.rb +21 -0
- data/test/www/video_scraper/test_adult_satellites.rb +13 -0
- data/test/www/video_scraper/test_age_sage.rb +1 -12
- data/test/www/video_scraper/test_ameba_vision.rb +1 -12
- data/test/www/video_scraper/test_base.rb +14 -0
- data/test/www/video_scraper/test_dailymotion.rb +1 -12
- data/test/www/video_scraper/test_moro_tube.rb +1 -12
- data/test/www/video_scraper/test_nico_video.rb +3 -10
- data/test/www/video_scraper/test_pornhub.rb +1 -12
- data/test/www/video_scraper/test_pornotube.rb +2 -13
- data/test/www/video_scraper/test_red_tube.rb +4 -15
- data/test/www/video_scraper/test_tube8.rb +3 -13
- data/test/www/video_scraper/test_veoh.rb +1 -12
- data/test/www/video_scraper/test_you_porn.rb +1 -12
- data/test/www/video_scraper/test_you_tube.rb +8 -16
- data/test/www/video_scraper/test_your_file_host.rb +2 -12
- metadata +6 -2
data/README
CHANGED
data/lib/www/video_scraper.rb
CHANGED
@@ -15,9 +15,9 @@ end
|
|
15
15
|
|
16
16
|
module WWW
|
17
17
|
module VideoScraper
|
18
|
-
VERSION = '1.0.
|
18
|
+
VERSION = '1.0.3'
|
19
19
|
|
20
|
-
MODULES_NAME = %w(age_sage ameba_vision dailymotion moro_tube
|
20
|
+
MODULES_NAME = %w(adult_satellites age_sage ameba_vision dailymotion moro_tube
|
21
21
|
nico_video pornhub pornotube red_tube tube8 veoh
|
22
22
|
you_porn you_tube your_file_host)
|
23
23
|
|
@@ -29,7 +29,6 @@ module WWW
|
|
29
29
|
@@options = {
|
30
30
|
:logger => nil,
|
31
31
|
:cache => nil,
|
32
|
-
:debug => false,
|
33
32
|
}
|
34
33
|
|
35
34
|
class << self
|
@@ -50,20 +49,22 @@ module WWW
|
|
50
49
|
yield @@options
|
51
50
|
end
|
52
51
|
|
52
|
+
def find_module(url)
|
53
|
+
@@modules.find { |mod| mod.valid_url?(url) }
|
54
|
+
end
|
55
|
+
|
53
56
|
# 与えられた URL を処理できるモジュールを @@modules から検索して実行する
|
54
57
|
def scrape(url, opt = nil)
|
55
58
|
opt = @@options.merge(opt || {})
|
56
59
|
opt[:logger] ||= logger
|
57
60
|
raise StandardError, "url param is requred" unless url
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
return scraper.new(url, opt)
|
64
|
-
end
|
62
|
+
logger.info "url: #{url}"
|
63
|
+
if mod = find_module(url)
|
64
|
+
logger.info "found module: #{mod.to_s}"
|
65
|
+
return mod.scrape(url, opt)
|
65
66
|
end
|
66
|
-
logger.info "unsupport
|
67
|
+
logger.info "unsupport url."
|
67
68
|
return nil
|
68
69
|
rescue TimeoutError, Timeout::Error, Errno::ETIMEDOUT => e
|
69
70
|
logger.warn " Timeout : #{e.to_s}"
|
@@ -80,8 +81,7 @@ module WWW
|
|
80
81
|
private
|
81
82
|
def logger
|
82
83
|
return @@options[:logger] if @@options[:logger]
|
83
|
-
|
84
|
-
@@options[:logger] = Logger.new(STDOUT)
|
84
|
+
@@options[:logger] = NullLogger.new
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/base')
|
4
|
+
|
5
|
+
module WWW
|
6
|
+
module VideoScraper
|
7
|
+
class AdultSatellites < Base
|
8
|
+
url_regex %r!http://(?:www\.)?asa\.tv/movie_detail\.php.*!
|
9
|
+
|
10
|
+
def scrape
|
11
|
+
html = http_get(@page_url)
|
12
|
+
doc = Hpricot(html.toutf8)
|
13
|
+
raise FileNotFound unless flashvars = doc.at('//object //param[@name="FlashVars"]')
|
14
|
+
flashvars = CGI.parse(flashvars.attributes['value'])
|
15
|
+
@video_url = flashvars['videoName'][0]
|
16
|
+
uri = URI.parse(@page_url)
|
17
|
+
if m = @video_url.match(%r!/([[:alnum:]]+/[[:alnum:]]+)\.flv!)
|
18
|
+
@thumb_url = "#{uri.scheme}://#{uri.host}/captured/#{m[1]}_1.jpg"
|
19
|
+
end
|
20
|
+
@title = doc.at('//strong[@class="ptitle"]').inner_html rescue nil
|
21
|
+
if embed = doc.at('//input[@name="embed"]')
|
22
|
+
@embed_tag = CGI.unescapeHTML(embed.attributes['value'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -7,13 +7,7 @@ module WWW
|
|
7
7
|
class AgeSage < Base
|
8
8
|
url_regex %r!\Ahttp://adult\.agesage\.jp/contentsPage\.html\?mcd=[[:alnum:]]{16}!
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def do_query
|
10
|
+
def scrape
|
17
11
|
@request_url = @page_url.sub('.html', '.xml')
|
18
12
|
@response_body = http_get(@request_url)
|
19
13
|
raise FileNotFound if @response_body.nil? or @response_body.empty?
|
@@ -7,13 +7,7 @@ module WWW
|
|
7
7
|
class AmebaVision < Base
|
8
8
|
url_regex %r!\Ahttp://vision\.ameba\.jp/watch\.do.*?\?movie=(\d+)!
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def do_query
|
10
|
+
def scrape
|
17
11
|
id = url_regex_match[1]
|
18
12
|
request_url = "http://vision.ameba.jp/api/get/detailMovie.do?movie=#{id}"
|
19
13
|
xml = http_get(request_url)
|
@@ -5,6 +5,10 @@ module WWW
|
|
5
5
|
class TryAgainLater < RuntimeError; end
|
6
6
|
class FileNotFound < RuntimeError; end
|
7
7
|
|
8
|
+
class NullLogger
|
9
|
+
def method_missing(name, *args); return nil; end
|
10
|
+
end
|
11
|
+
|
8
12
|
class Base
|
9
13
|
attr_reader :page_url, :video_url, :thumb_url, :embed_tag, :title
|
10
14
|
|
@@ -17,6 +21,12 @@ module WWW
|
|
17
21
|
def valid_url?(url)
|
18
22
|
not (url =~ @url_regex).nil?
|
19
23
|
end
|
24
|
+
|
25
|
+
def scrape(url, opt = nil)
|
26
|
+
instance = self.new(url, opt)
|
27
|
+
instance.scrape
|
28
|
+
instance
|
29
|
+
end
|
20
30
|
end
|
21
31
|
|
22
32
|
def initialize(url, opt = nil)
|
@@ -26,8 +36,14 @@ module WWW
|
|
26
36
|
raise StandardError, "url is not #{self.class.name} link: #{url}" if @url_regex_match.nil?
|
27
37
|
end
|
28
38
|
|
29
|
-
|
30
|
-
|
39
|
+
def scrape
|
40
|
+
raise StandardError, 'not implemented yet'
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
def url_regex_match
|
45
|
+
@url_regex_match
|
46
|
+
end
|
31
47
|
|
32
48
|
def agent
|
33
49
|
@agent ||= WWW::Mechanize.new do |a|
|
@@ -35,6 +51,11 @@ module WWW
|
|
35
51
|
end
|
36
52
|
end
|
37
53
|
|
54
|
+
def logger
|
55
|
+
return @opt[:logger] if @opt[:logger]
|
56
|
+
@opt[:logger] = NullLogger.new
|
57
|
+
end
|
58
|
+
|
38
59
|
def http_get(url, opt = nil)
|
39
60
|
open_opt = {
|
40
61
|
"User-Agent" => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)",
|
@@ -57,7 +78,6 @@ module WWW
|
|
57
78
|
raise TryAgainLater, e.to_s if e.to_s.include?('503')
|
58
79
|
raise e
|
59
80
|
end
|
60
|
-
|
61
81
|
end
|
62
82
|
end
|
63
83
|
end
|
@@ -7,13 +7,7 @@ module WWW
|
|
7
7
|
class Dailymotion < Base
|
8
8
|
url_regex %r!\Ahttp://www\.dailymotion\.com/.*?/video/([\w/-]+)!
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def do_query
|
10
|
+
def scrape
|
17
11
|
uri = URI.parse(@page_url)
|
18
12
|
html = http_get(@page_url)
|
19
13
|
doc = Hpricot(html.toutf8)
|
@@ -8,13 +8,7 @@ module WWW
|
|
8
8
|
url_regex %r!\Ahttp://www\.morotube\.com/watch\.php\?clip=([[:alnum:]]{8})!
|
9
9
|
attr_reader :author, :duration
|
10
10
|
|
11
|
-
def
|
12
|
-
super
|
13
|
-
do_query
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
def do_query
|
11
|
+
def scrape
|
18
12
|
uri = URI.parse(@page_url)
|
19
13
|
uri.path = '/gen_xml.php'
|
20
14
|
uri.query = "type=o&id=#{url_regex_match[1]}"
|
@@ -7,9 +7,25 @@ module WWW
|
|
7
7
|
class NicoVideo < Base
|
8
8
|
url_regex %r!\Ahttp://www\.nicovideo\.jp/watch/([[:alnum:]]+)!
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
10
|
+
def scrape
|
11
|
+
begin
|
12
|
+
login
|
13
|
+
id = url_regex_match[1]
|
14
|
+
get_flv(id)
|
15
|
+
get_thumb(id)
|
16
|
+
get_embed_tag(id)
|
17
|
+
rescue Timeout::Error => e
|
18
|
+
raise TryAgainLater, e.to_s
|
19
|
+
rescue WWW::Mechanize::ResponseCodeError => e
|
20
|
+
case e.response_code
|
21
|
+
when '404', '403'
|
22
|
+
raise FileNotFound, e.to_s
|
23
|
+
when '502'
|
24
|
+
raise TryAgainLater, e.to_s
|
25
|
+
else
|
26
|
+
raise TryAgainLater, e.to_s
|
27
|
+
end
|
28
|
+
end
|
13
29
|
end
|
14
30
|
|
15
31
|
private
|
@@ -47,27 +63,6 @@ module WWW
|
|
47
63
|
@embed_tag = elem.attributes['value']
|
48
64
|
end
|
49
65
|
end
|
50
|
-
|
51
|
-
def do_query
|
52
|
-
begin
|
53
|
-
login
|
54
|
-
id = url_regex_match[1]
|
55
|
-
get_flv(id)
|
56
|
-
get_thumb(id)
|
57
|
-
get_embed_tag(id)
|
58
|
-
rescue Timeout::Error => e
|
59
|
-
raise TryAgainLater, e.to_s
|
60
|
-
rescue WWW::Mechanize::ResponseCodeError => e
|
61
|
-
case e.response_code
|
62
|
-
when '404', '403'
|
63
|
-
raise FileNotFound, e.to_s
|
64
|
-
when '502'
|
65
|
-
raise TryAgainLater, e.to_s
|
66
|
-
else
|
67
|
-
raise TryAgainLater, e.to_s
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
66
|
end
|
72
67
|
end
|
73
68
|
end
|
@@ -7,13 +7,7 @@ module WWW
|
|
7
7
|
class Pornhub < Base
|
8
8
|
url_regex %r|\Ahttp://www\.pornhub\.com/view_video\.php.*viewkey=[[:alnum:]]{20}|
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def do_query
|
10
|
+
def scrape
|
17
11
|
html = http_get(@page_url)
|
18
12
|
raise FileNotFound unless m = html.match(/\.addVariable\("options",\s*"([^"]+)"\);/i)
|
19
13
|
@request_url = URI.decode m[1]
|
@@ -7,22 +7,7 @@ module WWW
|
|
7
7
|
class Pornotube < Base
|
8
8
|
url_regex %r!\Ahttp://(?:www\.)?pornotube\.com/(?:media|channels)\.php\?.*m=(\d+)!
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def login
|
17
|
-
agent.post("http://pornotube.com/index.php",
|
18
|
-
'verifyAge' => 'true',
|
19
|
-
'bMonth' => '01',
|
20
|
-
'bDay' => '01',
|
21
|
-
'bYear' => '1970',
|
22
|
-
'submit' => 'View All Content')
|
23
|
-
end
|
24
|
-
|
25
|
-
def do_query
|
10
|
+
def scrape
|
26
11
|
id = url_regex_match[1]
|
27
12
|
|
28
13
|
login
|
@@ -37,6 +22,16 @@ module WWW
|
|
37
22
|
@image_url = "http://photo.pornotube.com/thumbnails/video/#{q['userId'][0]}/#{q['mediaId'][0]}_full.jpg";
|
38
23
|
@embed_tag = q['embedCode'][0]
|
39
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def login
|
28
|
+
agent.post("http://pornotube.com/index.php",
|
29
|
+
'verifyAge' => 'true',
|
30
|
+
'bMonth' => '01',
|
31
|
+
'bDay' => '01',
|
32
|
+
'bYear' => '1970',
|
33
|
+
'submit' => 'View All Content')
|
34
|
+
end
|
40
35
|
end
|
41
36
|
end
|
42
37
|
end
|
@@ -5,33 +5,16 @@ require File.expand_path(File.dirname(__FILE__) + '/base')
|
|
5
5
|
module WWW
|
6
6
|
module VideoScraper
|
7
7
|
class RedTube < Base
|
8
|
-
url_regex %r|\Ahttp://www\.redtube\.com/(\d
|
8
|
+
url_regex %r|\Ahttp://www\.redtube\.com/(\d+)|
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
def embed_tag
|
16
|
-
return @embed_tag if @embed_tag
|
17
|
-
url = "http://www.redtube.com/embed/#{content_id}"
|
18
|
-
response_body = http_get(url)
|
19
|
-
doc = Hpricot(response_body)
|
20
|
-
doc.search('//textarea#cpf') do |elem|
|
21
|
-
@embed_tag = elem.inner_html
|
22
|
-
end
|
23
|
-
@embed_tag
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
def content_id; url_regex_match[1]; end
|
28
|
-
|
29
|
-
def do_query
|
10
|
+
def scrape
|
30
11
|
s = content_id || '0'
|
31
12
|
s = '1' if s.empty?
|
32
13
|
pathnr = s.to_i / 1000
|
33
14
|
s = "%07d" % s.to_i
|
15
|
+
logger.debug s
|
34
16
|
pathnr = "%07d" % pathnr
|
17
|
+
logger.debug pathnr
|
35
18
|
xc = %w!R 1 5 3 4 2 O 7 K 9 H B C D X F G A I J 8 L M Z 6 P Q 0 S T U V W E Y N!
|
36
19
|
qsum = 0
|
37
20
|
s.length.times do |i|
|
@@ -54,9 +37,46 @@ module WWW
|
|
54
37
|
code += xc[s[4] - 48 + qsum + 7]
|
55
38
|
code += xc[s[6] - 48 + qsum + 4]
|
56
39
|
content_video = pathnr + '/' + code + '.flv'
|
40
|
+
@pathnr = pathnr
|
41
|
+
@s = s
|
57
42
|
@video_url = "http://dl.redtube.com/_videos_t4vn23s9jc5498tgj49icfj4678/#{content_video}"
|
58
|
-
# @thumb_url = "http://thumbs.redtube.com/_thumbs/#{pathnr}/#{s}/#{s}_#{'%03d' % i}.jpg"
|
59
43
|
end
|
44
|
+
|
45
|
+
def thumb_url
|
46
|
+
return @thumb_url if @thumb_url
|
47
|
+
1.upto(10) do |i|
|
48
|
+
url = "http://thumbs.redtube.com/_thumbs/#{@pathnr}/#{@s}/#{@s}_#{'%03d' % i}.jpg"
|
49
|
+
logger.debug url
|
50
|
+
begin
|
51
|
+
uri = URI.parse(url)
|
52
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
53
|
+
response = http.head(uri.request_uri,
|
54
|
+
{"User-Agent" => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"})
|
55
|
+
logger.debug response.code
|
56
|
+
if 200 == response.code.to_i
|
57
|
+
@thumb_url = url
|
58
|
+
return @thumb_url
|
59
|
+
end
|
60
|
+
end
|
61
|
+
rescue TimeoutError, Timeout::Error, Errno::ETIMEDOUT
|
62
|
+
end
|
63
|
+
end
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def embed_tag
|
68
|
+
return @embed_tag if @embed_tag
|
69
|
+
url = "http://www.redtube.com/embed/#{content_id}"
|
70
|
+
response_body = http_get(url)
|
71
|
+
doc = Hpricot(response_body)
|
72
|
+
doc.search('//textarea#cpf') do |elem|
|
73
|
+
@embed_tag = elem.inner_html
|
74
|
+
end
|
75
|
+
@embed_tag
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
def content_id; url_regex_match[1]; end
|
60
80
|
end
|
61
81
|
end
|
62
82
|
end
|
@@ -5,15 +5,10 @@ require File.expand_path(File.dirname(__FILE__) + '/base')
|
|
5
5
|
module WWW
|
6
6
|
module VideoScraper
|
7
7
|
class Tube8 < Base
|
8
|
+
attr_reader :video_url_3gp
|
8
9
|
url_regex %r!\Ahttp://www\.tube8\.com/.*/(\d+)(?:/|$)!
|
9
10
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def do_query
|
11
|
+
def scrape
|
17
12
|
html = http_get(@page_url)
|
18
13
|
doc = Hpricot(html.toutf8)
|
19
14
|
raise FileNotFound unless flashvars = doc.at('//object //param[@name="FlashVars"]')
|
@@ -22,6 +17,14 @@ module WWW
|
|
22
17
|
uri = URI.parse(@page_url)
|
23
18
|
@thumb_url = URI.join("#{uri.scheme}://#{uri.host}", flashvars['imageUrl'][0]).to_s
|
24
19
|
@title = doc.at('//h1[@class="text"]').inner_html rescue nil
|
20
|
+
doc.search('//a').each do |elem|
|
21
|
+
if href = elem.attributes['href']
|
22
|
+
if href.match(/\.3gp$/)
|
23
|
+
@video_url_3gp = href
|
24
|
+
break
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -7,13 +7,7 @@ module WWW
|
|
7
7
|
class Veoh < Base
|
8
8
|
url_regex %r!\Ahttp://www\.veoh\.com/videos/([[:alnum:]]+)!
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def do_query
|
10
|
+
def scrape
|
17
11
|
@id = url_regex_match[1]
|
18
12
|
request_url = "http://www.veoh.com/rest/video/#{@id}/details"
|
19
13
|
xml = http_get(request_url)
|
@@ -21,10 +15,10 @@ module WWW
|
|
21
15
|
@title = xml.match(/title="([^"]+)"/).to_a[1]
|
22
16
|
@thumb_url = xml.match(/fullMedResImagePath="([^"]+)"/).to_a[1]
|
23
17
|
html = http_get(@page_url)
|
24
|
-
embed_tag = html.match(/\sid="embed"\s[^>]*value="([^"]+)"/).to_a[1]
|
25
|
-
|
18
|
+
if embed_tag = html.match(/\sid="embed"\s[^>]*value="([^"]+)"/).to_a[1]
|
19
|
+
@embed_tag = CGI.unescapeHTML(embed_tag)
|
20
|
+
end
|
26
21
|
end
|
27
22
|
end
|
28
23
|
end
|
29
24
|
end
|
30
|
-
|
@@ -7,13 +7,7 @@ module WWW
|
|
7
7
|
class YouPorn < Base
|
8
8
|
url_regex %r!\Ahttp://youporn\.com/watch/(\d+)!
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
do_query
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def do_query
|
10
|
+
def scrape
|
17
11
|
id = url_regex_match[1]
|
18
12
|
|
19
13
|
request_url = @page_url.sub(/(\?.*)?$/, '?user_choice=Enter')
|
@@ -7,16 +7,28 @@ module WWW
|
|
7
7
|
class YouTube < Base
|
8
8
|
url_regex %r!\Ahttp://(?:www|jp)\.youtube\.com/watch.*[?&]v=([[:alnum:]]+)!
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
10
|
+
def scrape
|
11
|
+
page = pass_verify_age
|
12
|
+
@title = page.root.at('//head/title').inner_html.sub(/^YouTube[\s-]*/, '') rescue ''
|
13
|
+
@embed_tag = page.root.at('//input[@id="embed_code"]').attributes['value'] rescue nil
|
14
|
+
page.root.search('//script').each do |script|
|
15
|
+
if m = script.inner_html.match(/var\s+swfArgs\s*=\s*([^;]+);/)
|
16
|
+
swf_args = JSON::parse(m[1])
|
17
|
+
uri = URI.parse(@page_url)
|
18
|
+
uri.path = '/get_video'
|
19
|
+
uri.query = "video_id=#{swf_args['video_id']}&t=#{swf_args['t']}"
|
20
|
+
@video_url = uri.to_s
|
21
|
+
@thumb_url = "http://i.ytimg.com/vi/#{swf_args['video_id']}/default.jpg"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
raise FileNotFound, 'file not found' if @video_url.nil?
|
13
25
|
end
|
14
26
|
|
15
27
|
private
|
16
28
|
def login
|
17
29
|
uri = URI.parse(@page_url)
|
18
30
|
page = agent.get("#{uri.scheme}://#{uri.host}/login")
|
19
|
-
login_form = page.
|
31
|
+
login_form = page.form('loginForm')
|
20
32
|
login_form.username = @opt[:you_tube_username]
|
21
33
|
login_form.password = @opt[:you_tube_password]
|
22
34
|
agent.submit(login_form)
|
@@ -33,23 +45,6 @@ module WWW
|
|
33
45
|
end
|
34
46
|
page
|
35
47
|
end
|
36
|
-
|
37
|
-
def do_query
|
38
|
-
page = pass_verify_age
|
39
|
-
@title = page.root.at('//head/title').inner_html.sub(/^YouTube[\s-]*/, '') rescue ''
|
40
|
-
@embed_tag = page.root.at('//input[@id="embed_code"]').attributes['value'] rescue nil
|
41
|
-
page.root.search('//script').each do |script|
|
42
|
-
if m = script.inner_html.match(/var\s+swfArgs\s*=\s*([^;]+);/)
|
43
|
-
swf_args = JSON::parse(m[1])
|
44
|
-
uri = URI.parse(@page_url)
|
45
|
-
uri.path = '/get_video'
|
46
|
-
uri.query = "video_id=#{swf_args['video_id']}&t=#{swf_args['t']}"
|
47
|
-
@video_url = uri.to_s
|
48
|
-
@thumb_url = "http://i.ytimg.com/vi/#{swf_args['video_id']}/default.jpg"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
raise FileNotFound, 'file not found' if @video_url.nil?
|
52
|
-
end
|
53
48
|
end
|
54
49
|
end
|
55
50
|
end
|
@@ -11,11 +11,6 @@ module WWW
|
|
11
11
|
class BandwidthAllowanceExceeded < TryAgainLater; end
|
12
12
|
class NoFileCategory < FileNotFound; end
|
13
13
|
|
14
|
-
def initialize(url, opt = nil)
|
15
|
-
super
|
16
|
-
do_query
|
17
|
-
end
|
18
|
-
|
19
14
|
def filename
|
20
15
|
uri = URI.parse(@page_url)
|
21
16
|
q = CGI.parse(uri.query)
|
@@ -23,8 +18,7 @@ module WWW
|
|
23
18
|
end
|
24
19
|
alias :title :filename
|
25
20
|
|
26
|
-
|
27
|
-
def do_query
|
21
|
+
def scrape
|
28
22
|
html = http_get(@page_url)
|
29
23
|
doc = Hpricot(html.toutf8)
|
30
24
|
if elem = doc.at('//object[@id="objectPlayer"] //param[@name="movie"]')
|
data/test/test_helper.rb
CHANGED
@@ -5,4 +5,19 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/www/video_scraper')
|
|
5
5
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'filecache'
|
8
|
+
require 'logger'
|
8
9
|
require 'pit'
|
10
|
+
|
11
|
+
class Test::Unit::TestCase
|
12
|
+
def logger
|
13
|
+
@logger ||= Logger.new(STDOUT)
|
14
|
+
end
|
15
|
+
|
16
|
+
def filecache
|
17
|
+
@filecache ||= FileCache.new('TestVideoScraper', '/tmp/test_video_scraper_cache', 60 * 60)
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_opt
|
21
|
+
@default_opt ||= { :logger => logger, :cache => filecache }
|
22
|
+
end
|
23
|
+
end
|
@@ -12,9 +12,30 @@ class TestVideoScraper < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_configure
|
15
|
+
WWW::VideoScraper.options = {}
|
16
|
+
|
17
|
+
assert_nil WWW::VideoScraper.options[:cache]
|
18
|
+
assert_nil WWW::VideoScraper.options[:logger]
|
19
|
+
|
15
20
|
WWW::VideoScraper.configure do |conf|
|
16
21
|
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
22
|
+
conf[:logger] = Logger.new(STDOUT)
|
17
23
|
end
|
24
|
+
|
18
25
|
assert_kind_of FileCache, WWW::VideoScraper.options[:cache]
|
26
|
+
assert_kind_of Logger, WWW::VideoScraper.options[:logger]
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_find_module
|
30
|
+
mod = WWW::VideoScraper.find_module('http://jp.youtube.com/watch?v=Ym20IwIUbuU')
|
31
|
+
assert_equal WWW::VideoScraper::YouTube, mod
|
32
|
+
mod = WWW::VideoScraper.find_module('http://www.nicovideo.jp/watch/sm1175788')
|
33
|
+
assert_equal WWW::VideoScraper::NicoVideo, mod
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_scrape
|
37
|
+
vs = WWW::VideoScraper.scrape('http://www.yourfilehost.com/media.php?cat=video&file=XV436__03.wmv')
|
38
|
+
assert_kind_of WWW::VideoScraper::Yourfilehost, vs
|
19
39
|
end
|
20
40
|
end
|
41
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
+
|
5
|
+
class TestAdultSatellites < Test::Unit::TestCase
|
6
|
+
def test_scrape
|
7
|
+
vs = WWW::VideoScraper::AdultSatellites.scrape('http://www.asa.tv/movie_detail.php?userid=&movie_id=15680', default_opt)
|
8
|
+
assert_equal 'http://www.asa.tv/movie_detail.php?userid=&movie_id=15680', vs.page_url
|
9
|
+
assert_match %r|http://asa\.tv/movie/D5/gcuppapa/[[:alnum:]]{32}\.flv|, vs.video_url
|
10
|
+
assert_match %r|http://www\.asa\.tv/captured/gcuppapa/[[:alnum:]]{32}_1\.jpg|, vs.thumb_url
|
11
|
+
assert_equal '妃乃ひかり,2', vs.title
|
12
|
+
end
|
13
|
+
end
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestAgeSage < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://adult.agesage.jp/contentsPage.html?mcd=oadyChZgcoN9rqbJ')
|
7
|
+
vs = WWW::VideoScraper::AgeSage.scrape('http://adult.agesage.jp/contentsPage.html?mcd=oadyChZgcoN9rqbJ', default_opt)
|
19
8
|
assert_equal 'http://adult.agesage.jp/contentsPage.html?mcd=oadyChZgcoN9rqbJ', vs.page_url
|
20
9
|
assert_match %r!http://file\d+\.agesage\.jp/flv/\d{8}/\d{10}_\d{6}\.flv!, vs.video_url
|
21
10
|
assert_match %r!http://file\d+\.agesage\.jp/data/\d{8}/\d{10}_\d{6}!, vs.thumb_url
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestAmebaVision < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://vision.ameba.jp/watch.do?movie=772341')
|
7
|
+
vs = WWW::VideoScraper::AmebaVision.scrape('http://vision.ameba.jp/watch.do?movie=772341', default_opt)
|
19
8
|
assert_equal 'http://vision.ameba.jp/watch.do?movie=772341', vs.page_url
|
20
9
|
assert_match %r|http://[-[:alnum:]]+\.vision\.ameba\.jp/flv/\d{4}/\d{2}/\d{2}/[[:alnum:]]+\.flv|, vs.video_url
|
21
10
|
assert_match %r|http://[-[:alnum:]]+\.vision\.ameba\.jp/jpg/\d{4}/\d{2}/\d{2}/[[:alnum:]]+_4\.jpg|, vs.thumb_url
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
4
|
+
|
5
|
+
class TestBase < Test::Unit::TestCase
|
6
|
+
def test_nulllogger
|
7
|
+
logger = WWW::VideoScraper::NullLogger.new
|
8
|
+
assert_nil logger.fatal 'nop'
|
9
|
+
assert_nil logger.error 'nop'
|
10
|
+
assert_nil logger.warn 'nop'
|
11
|
+
assert_nil logger.info 'nop'
|
12
|
+
assert_nil logger.debug 'nop'
|
13
|
+
end
|
14
|
+
end
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestDailymotion < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://www.dailymotion.com/mokelov/japan/video/x12gr3_music')
|
7
|
+
vs = WWW::VideoScraper::Dailymotion.scrape('http://www.dailymotion.com/mokelov/japan/video/x12gr3_music', default_opt)
|
19
8
|
assert_equal 'http://www.dailymotion.com/mokelov/japan/video/x12gr3_music', vs.page_url
|
20
9
|
assert_match %r|http://www\.dailymotion\.com/get/\d{2}/\d+x\d+/flv/\d+\.flv\?key=[[:alnum:]]+|, vs.video_url
|
21
10
|
assert_match %r|http://\w+\.static\.dailymotion\.com/dyn/preview/\d+x\d+/\d+\.jpg\?\d{14}|, vs.thumb_url
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestMoroTube < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://www.morotube.com/watch.php?clip=46430e1d')
|
7
|
+
vs = WWW::VideoScraper::MoroTube.scrape('http://www.morotube.com/watch.php?clip=46430e1d', default_opt)
|
19
8
|
assert_equal 'http://www.morotube.com/watch.php?clip=46430e1d', vs.page_url
|
20
9
|
assert_match %r!http://video\d+\.morotube\.com/[[:alnum:]]{32}/[[:alnum:]]{8}/[[:alnum:]]{8}\.flv!, vs.video_url
|
21
10
|
assert_match %r!http://static\d+\.morotube\.com/thumbs/\w{8}\.jpg!, vs.thumb_url
|
@@ -4,23 +4,16 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
|
4
4
|
|
5
5
|
class TestNicoVideo < Test::Unit::TestCase
|
6
6
|
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
7
|
config = Pit.get('nicovideo.jp', :require => {
|
12
8
|
'mail' => 'your email in nicovideo.jp',
|
13
9
|
'password' => 'your password in nicovideo.jp'
|
14
10
|
})
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def teardown
|
19
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
11
|
+
default_opt.merge!(:nico_video_mail => config['mail'],
|
12
|
+
:nico_video_password => config['password'])
|
20
13
|
end
|
21
14
|
|
22
15
|
def test_scrape
|
23
|
-
vs = WWW::VideoScraper.scrape('http://www.nicovideo.jp/watch/sm1175788',
|
16
|
+
vs = WWW::VideoScraper::NicoVideo.scrape('http://www.nicovideo.jp/watch/sm1175788', default_opt)
|
24
17
|
assert_equal 'http://www.nicovideo.jp/watch/sm1175788', vs.page_url
|
25
18
|
assert_match %r|http://smile-[[:alnum:]]+\.nicovideo\.jp/smile\?v=\d{7}\.\d{5}|, vs.video_url
|
26
19
|
assert_match %r|http://tn-skr\d+\.smilevideo\.jp/smile\?i=\d{7}|, vs.thumb_url
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestPornhub < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://www.pornhub.com/view_video.php?viewkey=27f115e7fee8c18f92b0')
|
7
|
+
vs = WWW::VideoScraper::Pornhub.scrape('http://www.pornhub.com/view_video.php?viewkey=27f115e7fee8c18f92b0', default_opt)
|
19
8
|
assert_equal 'http://www.pornhub.com/view_video.php?viewkey=27f115e7fee8c18f92b0', vs.page_url
|
20
9
|
assert_match %r|http://media1.pornhub.com/dl/[[:alnum:]]{32}/[[:alnum:]]{8}/videos/000/191/743/191743\.flv|, vs.video_url
|
21
10
|
assert_equal 'http://p1.pornhub.com/thumbs/000/191/743/small.jpg', vs.thumb_url
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestPornotube < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://pornotube.com/media.php?m=1677937')
|
7
|
+
vs = WWW::VideoScraper::Pornotube.scrape('http://pornotube.com/media.php?m=1677937', default_opt)
|
19
8
|
assert_equal 'http://pornotube.com/media.php?m=1677937', vs.page_url
|
20
9
|
assert_match %r|http://video\d+\.pornotube\.com/\d+/\d+\.flv|, vs.video_url
|
21
10
|
assert_match %r|http://photo\.pornotube\.com/thumbnails/video/\d+/\d+\.jpg|, vs.thumb_url
|
@@ -23,7 +12,7 @@ class TestPornotube < Test::Unit::TestCase
|
|
23
12
|
end
|
24
13
|
|
25
14
|
def test_scrape_alt_url
|
26
|
-
vs = WWW::VideoScraper.scrape('http://pornotube.com/channels.php?channelId=83&m=1677912')
|
15
|
+
vs = WWW::VideoScraper::Pornotube.scrape('http://pornotube.com/channels.php?channelId=83&m=1677912', default_opt)
|
27
16
|
assert_equal 'http://pornotube.com/channels.php?channelId=83&m=1677912', vs.page_url
|
28
17
|
assert_match %r|http://video\d+\.pornotube\.com/\d+/\d+\.flv|, vs.video_url
|
29
18
|
assert_match %r|http://photo\.pornotube\.com/thumbnails/video/\d+/\d+\.jpg|, vs.thumb_url
|
@@ -3,22 +3,11 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestRedTube < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://www.redtube.com/
|
19
|
-
assert_equal 'http://www.redtube.com/
|
20
|
-
|
21
|
-
|
7
|
+
vs = WWW::VideoScraper::RedTube.scrape('http://www.redtube.com/15021', default_opt)
|
8
|
+
assert_equal 'http://www.redtube.com/15021', vs.page_url
|
9
|
+
assert_equal 'http://dl.redtube.com/_videos_t4vn23s9jc5498tgj49icfj4678/0000015/X6KKXB0DB.flv', vs.video_url
|
10
|
+
assert_equal 'http://thumbs.redtube.com/_thumbs/0000015/0015021/0015021_001.jpg', vs.thumb_url
|
22
11
|
assert_match %r!<object\s+.*</object>!, vs.embed_tag
|
23
12
|
end
|
24
13
|
end
|
@@ -3,22 +3,12 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestTube8 < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://www.tube8.com/anal/alexis-amore-pov/56983/')
|
7
|
+
vs = WWW::VideoScraper::Tube8.scrape('http://www.tube8.com/anal/alexis-amore-pov/56983/', default_opt)
|
19
8
|
assert_equal 'http://www.tube8.com/anal/alexis-amore-pov/56983/', vs.page_url
|
20
|
-
assert_match %r|http://
|
9
|
+
assert_match %r|http://media\w+\.tube8\.com/flv/[[:alnum:]]{32}/[[:alnum:]]{8}/\d{4}/\d{2}/[[:alnum:]]+/[[:alnum:]]+\.flv|, vs.video_url
|
21
10
|
assert_equal 'http://www.tube8.com/vs/83/56983.jpg', vs.thumb_url
|
22
11
|
assert_equal 'Alexis Amore POV', vs.title
|
12
|
+
assert_match %r!http://mobile\d+\.tube8\.com/flv/[[:alnum:]]{32}/[[:alnum:]]{8}/\d{4}/\d{2}/[[:alnum:]]+/[[:alnum:]]+\.3gp!, vs.video_url_3gp
|
23
13
|
end
|
24
14
|
end
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestVeoh < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://www.veoh.com/videos/v6245232rh8aGEM9')
|
7
|
+
vs = WWW::VideoScraper::Veoh.scrape('http://www.veoh.com/videos/v6245232rh8aGEM9', default_opt)
|
19
8
|
assert_equal 'http://www.veoh.com/videos/v6245232rh8aGEM9', vs.page_url
|
20
9
|
assert_match %r|http://content\.veoh\.com/flash/p/\d/[[:alnum:]]{16}/[[:alnum:]]{40}\.fll\?ct=[[:alnum:]]{48}|, vs.video_url
|
21
10
|
assert_match %r|http://p-images\.veoh\.com/image\.out\?imageId=media-[[:alnum:]]+.jpg|, vs.thumb_url
|
@@ -3,19 +3,8 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestYouPorn < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://youporn.com/watch/93495?user_choice=Enter')
|
7
|
+
vs = WWW::VideoScraper::YouPorn.scrape('http://youporn.com/watch/93495?user_choice=Enter', default_opt)
|
19
8
|
assert_equal 'http://youporn.com/watch/93495?user_choice=Enter', vs.page_url
|
20
9
|
assert_match %r|http://download\.youporn\.com/download/\d+/flv/\d+_.*\.flv.*|, vs.video_url
|
21
10
|
assert_match %r|http://ss-\d+\.youporn\.com/screenshot/\d+/\d+/screenshot/\d+_large\.jpg|, vs.thumb_url
|
@@ -4,24 +4,16 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
|
4
4
|
|
5
5
|
class TestYouTube < Test::Unit::TestCase
|
6
6
|
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
|
12
7
|
config = Pit.get('youtube.com', :require => {
|
13
8
|
'username' => 'your email in youtube.com',
|
14
9
|
'password' => 'your password in youtube.com'
|
15
10
|
})
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
11
|
+
default_opt.merge!(:you_tube_username => config['username'],
|
12
|
+
:you_tube_password => config['password'])
|
21
13
|
end
|
22
14
|
|
23
15
|
def test_scrape
|
24
|
-
vs = WWW::VideoScraper.scrape('http://jp.youtube.com/watch?v=Ym20IwIUbuU',
|
16
|
+
vs = WWW::VideoScraper::YouTube.scrape('http://jp.youtube.com/watch?v=Ym20IwIUbuU', default_opt)
|
25
17
|
assert_equal 'http://jp.youtube.com/watch?v=Ym20IwIUbuU', vs.page_url
|
26
18
|
assert_match %r|http://jp\.youtube\.com/get_video\?video_id=Ym20IwIUbuU&t=[-_[:alnum:]]{32}|, vs.video_url
|
27
19
|
assert_match %r|http://\w\.ytimg\.com/vi/Ym20IwIUbuU/default\.jpg|, vs.thumb_url
|
@@ -30,11 +22,11 @@ class TestYouTube < Test::Unit::TestCase
|
|
30
22
|
end
|
31
23
|
|
32
24
|
def test_scrape_alt_url
|
33
|
-
vs = WWW::VideoScraper.scrape('http://jp.youtube.com/watch?v=
|
34
|
-
assert_equal 'http://jp.youtube.com/watch?v=
|
35
|
-
assert_match %r|http://jp\.youtube\.com/get_video\?video_id=
|
36
|
-
assert_match %r|http://\w\.ytimg\.com/vi/
|
25
|
+
vs = WWW::VideoScraper::YouTube.scrape('http://jp.youtube.com/watch?v=ATHC8qDkoO0', default_opt)
|
26
|
+
assert_equal 'http://jp.youtube.com/watch?v=ATHC8qDkoO0', vs.page_url
|
27
|
+
assert_match %r|http://jp\.youtube\.com/get_video\?video_id=ATHC8qDkoO0&t=[-_[:alnum:]]{32}|, vs.video_url
|
28
|
+
assert_match %r|http://\w\.ytimg\.com/vi/ATHC8qDkoO0/default\.jpg|, vs.thumb_url
|
37
29
|
assert_match %r|^<object\s+.*</object>$|, vs.embed_tag
|
38
|
-
assert_equal '
|
30
|
+
assert_equal "019' Sexii_Shower 藤澤まお_洗白白", vs.title
|
39
31
|
end
|
40
32
|
end
|
@@ -3,22 +3,12 @@
|
|
3
3
|
require File.dirname(__FILE__) + '/../../test_helper'
|
4
4
|
|
5
5
|
class TestYourFileHost < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@cache_root = '/tmp/test_video_scraper_cache'
|
8
|
-
WWW::VideoScraper.configure do |conf|
|
9
|
-
conf[:cache] = FileCache.new('TestVideoScraper', @cache_root, 60*60*24)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
# FileUtils.remove_entry_secure(@cache_root, true)
|
15
|
-
end
|
16
|
-
|
17
6
|
def test_scrape
|
18
|
-
vs = WWW::VideoScraper.scrape('http://www.yourfilehost.com/media.php?cat=video&file=XV436__03.wmv')
|
7
|
+
vs = WWW::VideoScraper::YourFileHost.scrape('http://www.yourfilehost.com/media.php?cat=video&file=XV436__03.wmv', default_opt)
|
19
8
|
assert_equal 'http://www.yourfilehost.com/media.php?cat=video&file=XV436__03.wmv', vs.page_url
|
20
9
|
assert_match %r|http://cdn\w*\.yourfilehost\.com/unit1/flash8/\d+/[[:alnum:]]{32}\.flv|, vs.video_url
|
21
10
|
assert_match %r|http://cdn\w*\.yourfilehost\.com/thumbs/\d+/[[:alnum:]]{32}\.jpg|, vs.thumb_url
|
22
11
|
assert_equal 'XV436__03.wmv', vs.title
|
23
12
|
end
|
24
13
|
end
|
14
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valda-video_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YAMAGUCHI Seiji
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-27 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- test/www/video_scraper/test_dailymotion.rb
|
51
51
|
- test/www/video_scraper/test_age_sage.rb
|
52
52
|
- test/www/video_scraper/test_pornotube.rb
|
53
|
+
- test/www/video_scraper/test_your_file_host_flymake.rb
|
53
54
|
- test/www/video_scraper/test_tube8.rb
|
54
55
|
- test/www/video_scraper/test_your_file_host.rb
|
55
56
|
- test/www/video_scraper/test_moro_tube.rb
|
@@ -58,7 +59,9 @@ files:
|
|
58
59
|
- test/www/video_scraper/test_nico_video.rb
|
59
60
|
- test/www/video_scraper/test_you_porn.rb
|
60
61
|
- test/www/video_scraper/test_you_tube.rb
|
62
|
+
- test/www/video_scraper/test_adult_satellites.rb
|
61
63
|
- test/www/video_scraper/test_red_tube.rb
|
64
|
+
- test/www/video_scraper/test_base.rb
|
62
65
|
- test/www/test_video_scraper.rb
|
63
66
|
- lib/www
|
64
67
|
- lib/www/video_scraper
|
@@ -67,6 +70,7 @@ files:
|
|
67
70
|
- lib/www/video_scraper/ameba_vision.rb
|
68
71
|
- lib/www/video_scraper/age_sage.rb
|
69
72
|
- lib/www/video_scraper/pornotube.rb
|
73
|
+
- lib/www/video_scraper/adult_satellites.rb
|
70
74
|
- lib/www/video_scraper/you_tube.rb
|
71
75
|
- lib/www/video_scraper/moro_tube.rb
|
72
76
|
- lib/www/video_scraper/pornhub.rb
|