getvideo 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/getvideo.gemspec +1 -0
- data/lib/getvideo.rb +3 -2
- data/lib/getvideo/iqiyi.rb +32 -33
- data/lib/getvideo/ku6.rb +2 -2
- data/lib/getvideo/{iask.rb → sina.rb} +33 -26
- data/lib/getvideo/tudou.rb +247 -109
- data/lib/getvideo/version.rb +1 -1
- data/lib/getvideo/video.rb +16 -14
- data/lib/getvideo/youtube.rb +6 -3
- data/spec/iqiyi_spec.rb +12 -4
- data/spec/{iask_spec.rb → sina_spec.rb} +18 -14
- data/spec/tudou_spec.rb +204 -90
- data/spec/youtube_spec.rb +7 -3
- metadata +30 -17
data/lib/getvideo/version.rb
CHANGED
data/lib/getvideo/video.rb
CHANGED
@@ -7,18 +7,19 @@ end
|
|
7
7
|
|
8
8
|
module Getvideo
|
9
9
|
class Video
|
10
|
-
attr_reader :url
|
10
|
+
attr_reader :url
|
11
11
|
|
12
12
|
def initialize(url)
|
13
13
|
@url = url
|
14
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
def response
|
17
|
+
@response ||= connection
|
15
18
|
end
|
16
19
|
|
17
20
|
def connection
|
18
21
|
api_url = self.class.get_api_uri(self)
|
19
|
-
|
20
|
-
response= conn.get api_url
|
21
|
-
@response = Response.new(response).parsed
|
22
|
+
Response.new(Faraday.get(api_url)).parsed
|
22
23
|
end
|
23
24
|
|
24
25
|
def id; end
|
@@ -58,24 +59,25 @@ module Getvideo
|
|
58
59
|
class Response
|
59
60
|
attr_reader :response
|
60
61
|
|
62
|
+
def initialize(response)
|
63
|
+
@response = response
|
64
|
+
end
|
65
|
+
|
61
66
|
CONTENT_TYPE = {
|
62
67
|
'application/json' => :json,
|
63
68
|
'application/x-www-form-urlencoded' => :html,
|
64
69
|
'text/html' => :html,
|
65
70
|
'text/javascript' => :json,
|
66
|
-
'text/xml' => :xml
|
71
|
+
'text/xml' => :xml,
|
72
|
+
"text/plain" => :json
|
67
73
|
}
|
68
74
|
|
69
75
|
PARSERS = {
|
70
76
|
:json => lambda{ |body| MultiJson.respond_to?(:adapter) ? MultiJson.load(body) : MultiJson.decode(body) rescue body },
|
71
77
|
:html => lambda{ |body| Nokogiri::HTML(body) },
|
72
|
-
:xml => lambda{ |body|
|
78
|
+
:xml => lambda{ |body| MultiXml.parse(body) }
|
73
79
|
}
|
74
80
|
|
75
|
-
def initialize(response)
|
76
|
-
@response = response
|
77
|
-
end
|
78
|
-
|
79
81
|
def headers
|
80
82
|
response.headers
|
81
83
|
end
|
@@ -85,12 +87,12 @@ module Getvideo
|
|
85
87
|
end
|
86
88
|
|
87
89
|
def decode(body)
|
88
|
-
return '' if !body
|
90
|
+
return '' if !body
|
89
91
|
return body if json?
|
90
92
|
charset = body.match(/charset\s*=[\s|\W]*([\w-]+)/)
|
91
93
|
if charset[1].downcase != "utf-8"
|
92
94
|
begin
|
93
|
-
body.encode! "utf-8", charset[1], {:invalid => :replace}
|
95
|
+
body.encode! "utf-8", charset[1], {:invalid => :replace}
|
94
96
|
rescue
|
95
97
|
body
|
96
98
|
end
|
@@ -113,7 +115,7 @@ module Getvideo
|
|
113
115
|
|
114
116
|
def parser
|
115
117
|
type = CONTENT_TYPE[content_type]
|
116
|
-
type = :json if type == :html && !response.body.match(/\<html/)
|
118
|
+
type = :json if type == :html && !response.body.match(/\<html/)
|
117
119
|
return type
|
118
120
|
end
|
119
121
|
|
data/lib/getvideo/youtube.rb
CHANGED
@@ -38,8 +38,11 @@ module Getvideo
|
|
38
38
|
type = stream.scan(/type=([^&]+)/)
|
39
39
|
vedio_list = {}
|
40
40
|
media.zip(sig, type).each do |m|
|
41
|
-
m_type = m[2][0].match(/(flv|mp4|webm|3gp)/)[0]
|
42
|
-
u = CGI::unescape(m[0][0])
|
41
|
+
m_type = m[2][0].match(/(flv|mp4|webm|3gp)/)[0]
|
42
|
+
u = CGI::unescape(m[0][0])
|
43
|
+
if m[1]
|
44
|
+
u += "&signature=" + m[1][0]
|
45
|
+
end
|
43
46
|
if vedio_list[m_type].nil?
|
44
47
|
vedio_list[m_type] = []
|
45
48
|
vedio_list[m_type] << u
|
@@ -59,7 +62,7 @@ module Getvideo
|
|
59
62
|
def connection
|
60
63
|
conn = Faraday.new
|
61
64
|
res = conn.post "http://www.youtube.com/get_video_info", { "video_id" => id }
|
62
|
-
|
65
|
+
Response.new(res).body
|
63
66
|
end
|
64
67
|
end
|
65
68
|
end
|
data/spec/iqiyi_spec.rb
CHANGED
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Getvideo::Iqiyi do
|
5
5
|
let(:iqiyi){ Getvideo::Iqiyi.new("http://www.iqiyi.com/weidianying/20120925/f15221a897037d07.html")}
|
6
|
+
let(:iqiyi2){ Getvideo::Iqiyi.new "http://www.iqiyi.com/v_19rrh4jv9s.html" }
|
6
7
|
|
7
8
|
let(:iqiyi_swf){ Getvideo::Iqiyi.new("http://player.video.qiyi.com/38c130b7b4124b1e902161e8e377324b/0/649/weidianying/20120925/f15221a897037d07.swf-pid=47084-ptype=2-albumId=233012-tvId=280286")}
|
8
9
|
|
@@ -11,21 +12,28 @@ describe Getvideo::Iqiyi do
|
|
11
12
|
describe "#id" do
|
12
13
|
it "should return id" do
|
13
14
|
iqiyi.id.should == "38c130b7b4124b1e902161e8e377324b"
|
15
|
+
iqiyi2.id.should == "8e0f5866b1d89f9328551ab98a95f102"
|
14
16
|
iqiyi_swf.id.should == "38c130b7b4124b1e902161e8e377324b"
|
15
17
|
iqiyi_id.id.should == "38c130b7b4124b1e902161e8e377324b"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
describe "#url" do
|
20
|
-
it{
|
22
|
+
it{
|
23
|
+
iqiyi.html_url.should eq("http://www.iqiyi.com/weidianying/20120925/f15221a897037d07.html")
|
24
|
+
}
|
21
25
|
end
|
22
26
|
|
23
27
|
describe "#title" do
|
24
|
-
it{
|
28
|
+
it {
|
29
|
+
iqiyi.title.should match(/网络/)
|
30
|
+
}
|
25
31
|
end
|
26
32
|
|
27
33
|
describe "#m3u8" do
|
28
|
-
it{
|
34
|
+
it {
|
35
|
+
iqiyi.m3u8.should == "http://metan.video.qiyi.com/161/2d67f7aa72fe95ee65d36ca7ceabb69e.m3u8"
|
36
|
+
}
|
29
37
|
end
|
30
38
|
|
31
39
|
describe "#flash" do
|
@@ -33,7 +41,7 @@ describe Getvideo::Iqiyi do
|
|
33
41
|
end
|
34
42
|
|
35
43
|
describe "#media" do
|
36
|
-
it{ iqiyi.media["
|
44
|
+
it{ iqiyi.media["f4v"].count.should eq(2) }
|
37
45
|
end
|
38
46
|
|
39
47
|
describe "#cover" do
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#coding:utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe Getvideo::
|
5
|
-
let(:iask){ Getvideo::
|
6
|
-
let(:iask_swf){ Getvideo::
|
7
|
-
let(:iask_id){ Getvideo::
|
8
|
-
let(:iask_noflash){ Getvideo::
|
4
|
+
describe Getvideo::Sina do
|
5
|
+
let(:iask){ Getvideo::Sina.new "http://video.sina.com.cn/v/b/87948161-2162799562.html" }
|
6
|
+
let(:iask_swf){ Getvideo::Sina.new "http://you.video.sina.com.cn/api/sinawebApi/outplayrefer.php/vid=87948161_2162799562_PE+1GCBtBjbK+l1lHz2stqkP7KQNt6nniGy2vFutIAhbQ0/XM5GRZdQD6CjQAdkEqDhATJ82cfYn0Rw/s.swf" }
|
7
|
+
let(:iask_id){ Getvideo::Sina.new "87948161|2162799562" }
|
8
|
+
let(:iask_noflash){ Getvideo::Sina.new "http://video.sina.com.cn/m/xbfmnz_61889719.html" }
|
9
9
|
|
10
10
|
|
11
11
|
describe "#id" do
|
@@ -25,7 +25,7 @@ describe Getvideo::Iask do
|
|
25
25
|
|
26
26
|
describe "#flash" do
|
27
27
|
it "should return flash url" do
|
28
|
-
iask.flash.should
|
28
|
+
iask.flash.should match(/s.swf/)
|
29
29
|
iask_noflash.flash.should be_empty()
|
30
30
|
end
|
31
31
|
end
|
@@ -51,9 +51,9 @@ describe Getvideo::Iask do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
context "when url is play_list" do
|
54
|
-
let(:iask_p){ Getvideo::
|
55
|
-
let(:iask_p2){ Getvideo::
|
56
|
-
let(:iask_p_swf){ Getvideo::
|
54
|
+
let(:iask_p){ Getvideo::Sina.new "http://video.sina.com.cn/playlist/5204279-2214257545-1.html#68348849" }
|
55
|
+
let(:iask_p2){ Getvideo::Sina.new "http://video.sina.com.cn/playlist/4077594-1549077107-2.html" }
|
56
|
+
let(:iask_p_swf){ Getvideo::Sina.new "http://you.video.sina.com.cn/api/sinawebApi/outplayrefer.php/vid=68348849_2214257545_aR69SnA+C2DK+l1lHz2stqkP7KQNt6nni2uwuVejIApcQ0/XM5Gfat4D6CHSCdkEqDhAQpA8cfYu0xQ/s.swf" }
|
57
57
|
|
58
58
|
describe "#id" do
|
59
59
|
it "should return true id" do
|
@@ -81,29 +81,33 @@ describe Getvideo::Iask do
|
|
81
81
|
|
82
82
|
|
83
83
|
context "when url is news" do
|
84
|
-
let(:iask_n){ Getvideo::
|
84
|
+
let(:iask_n){ Getvideo::Sina.new "http://video.sina.com.cn/p/news/c/v/2012-10-21/101961889769.html" }
|
85
85
|
#let(:iask_n){ Getvideo::Iask.new "http://news.sina.com.cn/z/video/rbgd2012/#88208237_6" }
|
86
|
-
let(:iask_n_id){ Getvideo::
|
87
|
-
let(:
|
86
|
+
let(:iask_n_id){ Getvideo::Sina.new "http://video.sina.com.cn/p/news/c/v/2012-10-21/101961889769.html#61889105" }
|
87
|
+
let(:sina){Getvideo::Sina.new "http://video.sina.com.cn/p/ent/m/m/2014-03-25/183663661343.html"}
|
88
|
+
let(:iask_n_swf){ Getvideo::Sina.new "http://you.video.sina.com.cn/api/sinawebApi/outplayrefer.php/vid=88279853_1_bEO9GyM9DWfK+l1lHz2stqkM7KQNt6nknynt71+iJAZRXAuIborfO4kK6CHUB8ZK9G8/s.swf" }
|
88
89
|
|
89
90
|
describe "#id" do
|
90
91
|
it "should return true id" do
|
91
92
|
iask_n.id.should == "88279853"
|
92
93
|
iask_n_id.id.should == "61889105"
|
93
94
|
iask_n_swf.id.should == "88279853"
|
95
|
+
sina.id.should == "129348331"
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
97
99
|
describe "#html_url" do
|
98
100
|
it "should return html url" do
|
99
101
|
iask_n_swf.html_url.should be_empty
|
102
|
+
sina.html_url.should == "http://video.sina.com.cn/p/ent/m/m/2014-03-25/183663661343.html"
|
100
103
|
end
|
101
104
|
end
|
102
105
|
|
103
106
|
describe "#media" do
|
104
107
|
it "should return media data" do
|
105
|
-
iask_n.media["hlv"]
|
106
|
-
iask_n_swf.media["hlv"]
|
108
|
+
#iask_n.media["hlv"].count.should eq(1)
|
109
|
+
#iask_n_swf.media["hlv"].count.should eq(1)
|
110
|
+
pp sina.m3u8
|
107
111
|
end
|
108
112
|
end
|
109
113
|
|
data/spec/tudou_spec.rb
CHANGED
@@ -1,154 +1,268 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Getvideo::Tudou do
|
4
|
-
context "when url type
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
context "when url type with program" do
|
5
|
+
####
|
6
|
+
# tudou program vedio
|
7
|
+
# iid = 188982955
|
8
|
+
# lcode = rCg0cXZ2_6g
|
9
|
+
####
|
10
|
+
let(:tudou_v){ Getvideo::Tudou.new "http://www.tudou.com/programs/view/rCg0cXZ2_6g/" }
|
11
|
+
let(:tudou_v_swf){ Getvideo::Tudou.new "http://www.tudou.com/v/rCg0cXZ2_6g/&rpid=119749846&resourceId=119749846_04_05_99/v.swf" }
|
10
12
|
|
11
13
|
describe "#id" do
|
12
|
-
it "should
|
13
|
-
tudou_v.id.should == "
|
14
|
-
tudou_v_swf.id.should == "
|
15
|
-
tudou_dp_v.id.should == "151831829"
|
16
|
-
tudou_dp_v_swf.id.should == "151831829"
|
17
|
-
tudou_dp_v_html.id.should == "151831829"
|
14
|
+
it "should equal 188982955" do
|
15
|
+
tudou_v.id.should == "188982955"
|
16
|
+
tudou_v_swf.id.should == "188982955"
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
describe "#html_url" do
|
22
|
-
it "should
|
23
|
-
|
24
|
-
|
21
|
+
it "should equal http://www.tudou.com/programs/view/rCg0cXZ2_6g/" do
|
22
|
+
tudou_v.html_url.should eq("http://www.tudou.com/programs/view/rCg0cXZ2_6g/")
|
23
|
+
tudou_v_swf.html_url.should eq("http://www.tudou.com/programs/view/rCg0cXZ2_6g/")
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
27
|
describe "#flash" do
|
29
|
-
it "should
|
30
|
-
tudou_v.flash.should
|
31
|
-
|
28
|
+
it "should equal http://www.tudou.com/v/rCg0cXZ2_6g/v.swf" do
|
29
|
+
tudou_v.flash.should eq("http://www.tudou.com/v/rCg0cXZ2_6g/v.swf")
|
30
|
+
tudou_v_swf.flash.should eq("http://www.tudou.com/v/rCg0cXZ2_6g/v.swf")
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
34
|
describe "#title" do
|
36
|
-
it
|
35
|
+
it "should get video name equal 【伦敦之心】坛久保 - 女性向摔跤揭秘" do
|
36
|
+
tudou_v.title.should eq("【伦敦之心】坛久保 - 女性向摔跤揭秘")
|
37
|
+
tudou_v_swf.title.should eq("【伦敦之心】坛久保 - 女性向摔跤揭秘")
|
38
|
+
end
|
37
39
|
end
|
38
40
|
|
39
41
|
describe "#cover" do
|
40
|
-
it
|
42
|
+
it "should equal " do
|
43
|
+
tudou_v.cover.should eq("http://i2.tdimg.com/188/982/955/p.jpg")
|
44
|
+
tudou_v_swf.cover.should eq("http://i2.tdimg.com/188/982/955/p.jpg")
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
48
|
describe "#m3u8" do
|
44
|
-
it
|
49
|
+
it "should equal http://vr.tudou.com/v2proxy/v2.m3u8?it=188982955&st=2&pw=" do
|
50
|
+
tudou_v.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=188982955&st=2&pw=")
|
51
|
+
tudou_v_swf.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=188982955&st=2&pw=")
|
52
|
+
end
|
45
53
|
end
|
46
54
|
|
47
|
-
describe "#media" do
|
48
|
-
it{ tudou_v.media["f4v"].count.should be(2)}
|
49
|
-
end
|
50
55
|
end
|
51
56
|
|
52
|
-
context "when url type
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
let(:
|
61
|
-
|
57
|
+
context "when url type with lisplay" do
|
58
|
+
####
|
59
|
+
# tudou list video
|
60
|
+
# lcode = 'BCbkQV3rOFc'
|
61
|
+
# lid = 17491087
|
62
|
+
# iid = 189900273
|
63
|
+
# icode = WK3rjXAAbd4
|
64
|
+
####
|
65
|
+
let(:tudou_list1){ Getvideo::Tudou.new "http://www.tudou.com/listplay/BCbkQV3rOFc/WK3rjXAAbd4.html" }
|
66
|
+
let(:tudou_list2){ Getvideo::Tudou.new "http://www.tudou.com/listplay/BCbkQV3rOFc.html" }
|
67
|
+
let(:tudou_list_swf){ Getvideo::Tudou.new "http://www.tudou.com/l/BCbkQV3rOFc/&iid=189900273&rpid=119749846&resourceId=119749846_04_05_99/v.swf" }
|
68
|
+
|
62
69
|
describe "#id" do
|
63
|
-
it "should
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
tudou_dp_a.id.should == "131561214"
|
68
|
-
tudou_dp_a2.id.should == "131561214"
|
70
|
+
it "should equal 189900273" do
|
71
|
+
tudou_list1.id.should == "189900273"
|
72
|
+
tudou_list2.id.should == "189900273"
|
73
|
+
tudou_list_swf.id.should == "189900273"
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
72
77
|
describe "#html_url" do
|
73
|
-
it "should
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
tudou_dp_a2.html_url.should == "http://www.tudou.com/albumplay/MgWfoV9cT4E/A49rc-hkUrY.html"
|
78
|
+
it "should equal http://www.tudou.com/listplay/BCbkQV3rOFc/WK3rjXAAbd4.html" do
|
79
|
+
tudou_list1.html_url.should eq("http://www.tudou.com/listplay/BCbkQV3rOFc/WK3rjXAAbd4.html")
|
80
|
+
tudou_list2.html_url.should eq("http://www.tudou.com/listplay/BCbkQV3rOFc/WK3rjXAAbd4.html")
|
81
|
+
tudou_list_swf.html_url.should eq("http://www.tudou.com/listplay/BCbkQV3rOFc/WK3rjXAAbd4.html")
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
81
85
|
describe "#flash" do
|
82
|
-
it "should
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
tudou_dp_a2.flash.should == "http://www.tudou.com/a/MgWfoV9cT4E/&rpid=116105338&resourceId=116105338_04_05_99&iid=131561214/v.swf"
|
86
|
+
it "should" do
|
87
|
+
tudou_list1.flash.should eq("http://www.tudou.com/l/BCbkQV3rOFc/&iid=189900273/v.swf")
|
88
|
+
tudou_list2.flash.should eq("http://www.tudou.com/l/BCbkQV3rOFc/&iid=189900273/v.swf")
|
89
|
+
tudou_list_swf.flash.should eq("http://www.tudou.com/l/BCbkQV3rOFc/&iid=189900273/v.swf")
|
87
90
|
end
|
88
91
|
end
|
89
|
-
|
92
|
+
|
93
|
+
describe "#media" do
|
94
|
+
it "should" do
|
95
|
+
tudou_list1.media.count.should eq(5)
|
96
|
+
tudou_list2.media.count.should eq(5)
|
97
|
+
tudou_list_swf.media.count.should eq(5)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
90
101
|
describe "#cover" do
|
91
|
-
it "should
|
92
|
-
|
93
|
-
|
102
|
+
it "should" do
|
103
|
+
tudou_list1.cover.should eq("http://g2.tdimg.com/e3c1e6a10fe815112a7076609dae5c26/w_2.jpg")
|
104
|
+
tudou_list2.cover.should eq("http://g2.tdimg.com/e3c1e6a10fe815112a7076609dae5c26/w_2.jpg")
|
105
|
+
tudou_list_swf.cover.should eq("http://g2.tdimg.com/e3c1e6a10fe815112a7076609dae5c26/w_2.jpg")
|
94
106
|
end
|
95
107
|
end
|
96
108
|
|
97
|
-
describe "#
|
98
|
-
it "
|
99
|
-
|
100
|
-
|
109
|
+
describe "#m3u8" do
|
110
|
+
it "should" do
|
111
|
+
tudou_list1.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=189900273&st=2&pw=")
|
112
|
+
tudou_list2.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=189900273&st=2&pw=")
|
113
|
+
tudou_list_swf.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=189900273&st=2&pw=")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#title" do
|
118
|
+
it "should" do
|
119
|
+
tudou_list1.title.should eq("给你个机会做男人 你愿意吗?妹子神回复【神街访】")
|
120
|
+
tudou_list2.title.should eq("给你个机会做男人 你愿意吗?妹子神回复【神街访】")
|
121
|
+
tudou_list_swf.title.should eq("给你个机会做男人 你愿意吗?妹子神回复【神街访】")
|
101
122
|
end
|
102
123
|
end
|
103
124
|
end
|
104
125
|
|
105
|
-
context "when url type
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
126
|
+
context "when url type with albumplay" do
|
127
|
+
####
|
128
|
+
# tudou albumplay video 1
|
129
|
+
# lid = 235139
|
130
|
+
# lcode = lwRXz9WFd48
|
131
|
+
# ylid = 286629
|
132
|
+
# iid = 131675891
|
133
|
+
# icode = Tb6_eGHHjAI
|
134
|
+
# vcode = XNjY2NTMyNDgw
|
135
|
+
#
|
136
|
+
# tudou albumplay video 2
|
137
|
+
# lid = 235139
|
138
|
+
# lcode = lwRXz9WFd48
|
139
|
+
# ylid = 286629
|
140
|
+
# iid = 131675896
|
141
|
+
# icode = Tb6_eGHHjAI
|
142
|
+
# vcode = XNjY2NTMyNDgw
|
143
|
+
###
|
144
|
+
let(:tudou_albumplay1){ Getvideo::Tudou.new "http://www.tudou.com/albumplay/lwRXz9WFd48/uW1V7DwwNNY.html"}
|
145
|
+
let(:tudou_albumplay2){ Getvideo::Tudou.new "http://www.tudou.com/albumplay/lwRXz9WFd48.html"}
|
146
|
+
let(:tudou_albumplay3){ Getvideo::Tudou.new "http://www.tudou.com/albumplay/lwRXz9WFd48/Tb6_eGHHjAI.html"}
|
147
|
+
let(:tudou_albumplay_swf1){ Getvideo::Tudou.new "http://www.tudou.com/a/lwRXz9WFd48/&iid=131675891&rpid=119749846&resourceId=119749846_04_05_99/v.swf" }
|
148
|
+
let(:tudou_albumplay_swf2){ Getvideo::Tudou.new "http://www.tudou.com/a/lwRXz9WFd48/&iid=131675896&rpid=119749846&resourceId=119749846_04_05_99/v.swf" }
|
112
149
|
|
113
150
|
describe "#id" do
|
114
|
-
it "should
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
tudou_dp_l2.id.should == "126330996"
|
151
|
+
it "should equal 131675896" do
|
152
|
+
tudou_albumplay1.id.should eq("131675891")
|
153
|
+
tudou_albumplay2.id.should eq("131675891")
|
154
|
+
tudou_albumplay3.id.should eq("131675896")
|
155
|
+
tudou_albumplay_swf1.id.should eq("131675891")
|
156
|
+
tudou_albumplay_swf2.id.should eq("131675896")
|
121
157
|
end
|
122
158
|
end
|
123
159
|
|
124
160
|
describe "#html_url" do
|
125
|
-
it "should
|
126
|
-
|
127
|
-
|
161
|
+
it "should equal http://www.tudou.com/albumplay/lwRXz9WFd48/uW1V7DwwNNY.html" do
|
162
|
+
tudou_albumplay1.html_url.should eq("http://www.tudou.com/albumplay/lwRXz9WFd48/uW1V7DwwNNY.html")
|
163
|
+
tudou_albumplay2.html_url.should eq("http://www.tudou.com/albumplay/lwRXz9WFd48/uW1V7DwwNNY.html")
|
164
|
+
tudou_albumplay3.html_url.should eq("http://www.tudou.com/albumplay/lwRXz9WFd48/Tb6_eGHHjAI.html")
|
165
|
+
tudou_albumplay_swf1.html_url.should eq("http://www.tudou.com/albumplay/lwRXz9WFd48/uW1V7DwwNNY.html")
|
166
|
+
tudou_albumplay_swf2.html_url.should eq("http://www.tudou.com/albumplay/lwRXz9WFd48/Tb6_eGHHjAI.html")
|
128
167
|
end
|
129
168
|
end
|
130
169
|
|
131
|
-
describe "
|
132
|
-
it "should return flash" do
|
133
|
-
|
134
|
-
|
170
|
+
describe "flash" do
|
171
|
+
it "should return real flash" do
|
172
|
+
tudou_albumplay1.flash.should eq("http://www.tudou.com/a/lwRXz9WFd48/&iid=131675891/v.swf")
|
173
|
+
tudou_albumplay2.flash.should eq("http://www.tudou.com/a/lwRXz9WFd48/&iid=131675891/v.swf")
|
174
|
+
tudou_albumplay3.flash.should eq("http://www.tudou.com/a/lwRXz9WFd48/&iid=131675896/v.swf")
|
175
|
+
tudou_albumplay_swf1.flash.should eq("http://www.tudou.com/a/lwRXz9WFd48/&iid=131675891/v.swf")
|
176
|
+
tudou_albumplay_swf2.flash.should eq("http://www.tudou.com/a/lwRXz9WFd48/&iid=131675896/v.swf")
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe "#media" do
|
181
|
+
it "should get 3 media" do
|
182
|
+
tudou_albumplay1.media.count.should eq(3)
|
183
|
+
tudou_albumplay2.media.count.should eq(3)
|
184
|
+
tudou_albumplay3.media.count.should eq(3)
|
185
|
+
tudou_albumplay_swf1.media.count.should eq(3)
|
186
|
+
tudou_albumplay_swf2.media.count.should eq(3)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "#cover" do
|
191
|
+
it "should get real cover" do
|
192
|
+
tudou_albumplay1.cover.should eq("http://g3.ykimg.com/11270F1F4652E4F6DE2030000000002C541A48-C9BA-60F1-557B-4F5D58E7820B")
|
193
|
+
tudou_albumplay2.cover.should eq("http://g3.ykimg.com/11270F1F4652E4F6DE2030000000002C541A48-C9BA-60F1-557B-4F5D58E7820B")
|
194
|
+
tudou_albumplay3.cover.should eq("http://g2.ykimg.com/11270F1F4652E4FF55A147000000004D785935-2C2C-DB1C-7C9E-ECBE99D259D5")
|
195
|
+
tudou_albumplay_swf1.cover.should eq("http://g3.ykimg.com/11270F1F4652E4F6DE2030000000002C541A48-C9BA-60F1-557B-4F5D58E7820B")
|
196
|
+
tudou_albumplay_swf2.cover.should eq("http://g2.ykimg.com/11270F1F4652E4FF55A147000000004D785935-2C2C-DB1C-7C9E-ECBE99D259D5")
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "#title" do
|
201
|
+
it "should get video name equal 发胶喷太猛一秒就爆炸" do
|
202
|
+
tudou_albumplay1.title.should eq("发胶喷太猛一秒就爆炸")
|
203
|
+
tudou_albumplay2.title.should eq("发胶喷太猛一秒就爆炸")
|
204
|
+
tudou_albumplay3.title.should eq("缺德男电梯调戏仨美女")
|
205
|
+
tudou_albumplay_swf1.title.should eq("lol:-) 第二季 01")
|
206
|
+
tudou_albumplay_swf2.title.should eq("lol:-) 第二季 11")
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe "#cover" do
|
211
|
+
it "should get real cover" do
|
212
|
+
tudou_albumplay1.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=131675891&st=2&pw=")
|
213
|
+
tudou_albumplay2.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=131675891&st=2&pw=")
|
214
|
+
tudou_albumplay3.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=131675896&st=2&pw=")
|
215
|
+
tudou_albumplay_swf1.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=131675891&st=2&pw=")
|
216
|
+
tudou_albumplay_swf2.m3u8.should eq("http://vr.tudou.com/v2proxy/v2.m3u8?it=131675896&st=2&pw=")
|
135
217
|
end
|
136
218
|
end
|
137
|
-
|
138
219
|
end
|
139
220
|
|
140
|
-
context "when url type
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
221
|
+
context "when url type with oplay" do
|
222
|
+
####
|
223
|
+
# tudou oplay video
|
224
|
+
# lid = 98167
|
225
|
+
# lcode = 6jo2_Ep6Jbg
|
226
|
+
# ylid = 22642
|
227
|
+
# iid = 130441856
|
228
|
+
# icode = pJKf69qZMyQ
|
229
|
+
# vcode = XMzU1NDE5MTYw
|
230
|
+
###
|
231
|
+
let(:tudou_oplay){ Getvideo::Tudou.new "www.tudou.com/oplay/6jo2_Ep6Jbg/pJKf69qZMyQ.html"}
|
232
|
+
let(:tudou_oplay_swf){ Getvideo::Tudou.new "http://www.tudou.com/o/6jo2_Ep6Jbg/&iid=130441856&rpid=119749846&resourceId=119749846_04_05_99/v.swf"}
|
145
233
|
|
146
234
|
describe "#id" do
|
147
|
-
it "should
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
235
|
+
it "should equal 130441856" do
|
236
|
+
tudou_oplay.id.should eq("130441856")
|
237
|
+
tudou_oplay_swf.id.should eq("130441856")
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "title" do
|
242
|
+
it "should equal 十一罗汉-Ocean's Eleven(2001)中文预告片" do
|
243
|
+
tudou_oplay.title.should eq("十一罗汉-Ocean's Eleven(2001)中文预告片")
|
244
|
+
tudou_oplay_swf.title.should eq("十一罗汉-Ocean's Eleven(2001)中文预告片")
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "#html_url" do
|
249
|
+
it "should equal http://www.tudou.com/albumplay/6jo2_Ep6Jbg/pJKf69qZMyQ.html" do
|
250
|
+
tudou_oplay.html_url.should eq("http://www.tudou.com/albumplay/6jo2_Ep6Jbg/pJKf69qZMyQ.html")
|
251
|
+
tudou_oplay_swf.html_url.should eq("http://www.tudou.com/albumplay/6jo2_Ep6Jbg/pJKf69qZMyQ.html")
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "flash" do
|
256
|
+
it "should equal http://www.tudou.com/o/6jo2_Ep6Jbg/&iid=130441856/v.swf" do
|
257
|
+
tudou_oplay.flash.should eq("http://www.tudou.com/a/6jo2_Ep6Jbg/&iid=130441856/v.swf")
|
258
|
+
tudou_oplay_swf.flash.should eq("http://www.tudou.com/a/6jo2_Ep6Jbg/&iid=130441856/v.swf")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "cover" do
|
263
|
+
it "should get real cover" do
|
264
|
+
tudou_oplay.cover.should eq("http://g3.ykimg.com/1100641F46510C41BA2F3300B49D4A19E2DAE9-14BD-BAC8-1EF3-05BCB948C329")
|
265
|
+
tudou_oplay_swf.cover.should eq("http://g3.ykimg.com/1100641F46510C41BA2F3300B49D4A19E2DAE9-14BD-BAC8-1EF3-05BCB948C329")
|
152
266
|
end
|
153
267
|
end
|
154
268
|
end
|