getvideo 0.0.4

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.
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require 'getvideo'
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
@@ -0,0 +1,155 @@
1
+ require 'spec_helper'
2
+
3
+ describe Getvideo::Tudou do
4
+ context "when url type view" do
5
+ let(:tudou_v){Getvideo::Tudou.new "http://www.tudou.com/programs/view/-tuU-wryFaQ/"}
6
+ let(:tudou_v_swf){Getvideo::Tudou.new "http://www.tudou.com/v/-tuU-wryFaQ/&rpid=116105338&resourceId=116105338_04_05_99/v.swf"}
7
+ let(:tudou_dp_v){Getvideo::Tudou.new "dp.tudou.com/v/-tuU-wryFaQ.html"}
8
+ let(:tudou_dp_v_swf){Getvideo::Tudou.new "http://dp.tudou.com/nplayer.swf?151831829&&33.439"}
9
+ let(:tudou_dp_v_html){Getvideo::Tudou.new "http://dp.tudou.com/player.php?id=151831829&offset=1.733"}
10
+
11
+ describe "#id" do
12
+ it "should return id" do
13
+ tudou_v.id.should == "151831829"
14
+ tudou_v_swf.id.should == "151831829"
15
+ tudou_dp_v.id.should == "151831829"
16
+ tudou_dp_v_swf.id.should == "151831829"
17
+ tudou_dp_v_html.id.should == "151831829"
18
+ end
19
+ end
20
+
21
+ describe "#html_url" do
22
+ it "should return html url" do
23
+ tudou_v_swf.html_url.should == "http://www.tudou.com/programs/view/-tuU-wryFaQ/"
24
+ tudou_dp_v.html_url.should == "http://www.tudou.com/programs/view/-tuU-wryFaQ/"
25
+ end
26
+ end
27
+
28
+ describe "#flash" do
29
+ it "should return flash url" do
30
+ tudou_v.flash.should == "http://www.tudou.com/v/-tuU-wryFaQ/&rpid=116105338&resourceId=116105338_04_05_99/v.swf"
31
+ tudou_dp_v.flash.should == "http://www.tudou.com/v/-tuU-wryFaQ/&rpid=116105338&resourceId=116105338_04_05_99/v.swf"
32
+ end
33
+ end
34
+
35
+ describe "#title" do
36
+ it {tudou_v.title.should match(/20120907/) }
37
+ end
38
+
39
+ describe "#cover" do
40
+ it{ tudou_v.cover.should match(/tdimg|ykimg/) }
41
+ end
42
+
43
+ describe "#m3u8" do
44
+ it{ tudou_v.m3u8.should == "http://vr.tudou.com/v2proxy/v2.m3u8?it=151831829&st=2&pw=" }
45
+ end
46
+
47
+ describe "#media" do
48
+ it{ tudou_v.media["f4v"].count.should be(2)}
49
+ end
50
+ end
51
+
52
+ context "when url type is albumplay" do
53
+ let(:tudou_a){Getvideo::Tudou.new "http://www.tudou.com/albumplay/MgWfoV9cT4E.html"}
54
+ #会跳转url
55
+ let(:tudou_a1){Getvideo::Tudou.new "http://www.tudou.com/albumplay/1D9nGd3U0ks/WjNmtxWnbac.html"}
56
+ let(:tudou_a_swf){Getvideo::Tudou.new "http://www.tudou.com/a/MgWfoV9cT4E/&resourceId=0_04_05_99&iid=131561214/v.swf"}
57
+ let(:tudou_a2){Getvideo::Tudou.new "http://www.tudou.com/albumplay/oYvFcu7I5YY/RO-yBcJdGws.html"}
58
+ let(:tudou_a2_swf){Getvideo::Tudou.new "http://www.tudou.com/a/oYvFcu7I5YY/&resourceId=0_04_05_99&iid=131561156/v.swf"}
59
+ let(:tudou_dp_a){Getvideo::Tudou.new "http://dp.tudou.com/a/MgWfoV9cT4E.html"}
60
+ let(:tudou_dp_a2){Getvideo::Tudou.new "http://dp.tudou.com/a/MgWfoV9cT4E/A49rc-hkUrY.html"}
61
+
62
+ describe "#id" do
63
+ it "should return id" do
64
+ tudou_a_swf.id.should == "131561214"
65
+ tudou_a2.id.should == "131561156"
66
+ tudou_a2_swf.id.should == "131561156"
67
+ tudou_dp_a.id.should == "131561214"
68
+ tudou_dp_a2.id.should == "131561214"
69
+ end
70
+ end
71
+
72
+ describe "#html_url" do
73
+ it "should return id" do
74
+ tudou_a_swf.html_url.should == "http://www.tudou.com/albumplay/MgWfoV9cT4E.html"
75
+ tudou_a2_swf.html_url.should == "http://www.tudou.com/albumplay/oYvFcu7I5YY.html"
76
+ tudou_dp_a.html_url.should == "http://www.tudou.com/albumplay/MgWfoV9cT4E.html"
77
+ tudou_dp_a2.html_url.should == "http://www.tudou.com/albumplay/MgWfoV9cT4E/A49rc-hkUrY.html"
78
+ end
79
+ end
80
+
81
+ describe "#flash" do
82
+ it "should return flash" do
83
+ tudou_a.flash.should == "http://www.tudou.com/a/MgWfoV9cT4E/&rpid=116105338&resourceId=116105338_04_05_99&iid=131561214/v.swf"
84
+ tudou_a2.flash.should == "http://www.tudou.com/a/oYvFcu7I5YY/&rpid=116105338&resourceId=116105338_04_05_99&iid=131561156/v.swf"
85
+ tudou_dp_a.flash.should == "http://www.tudou.com/a/MgWfoV9cT4E/&rpid=116105338&resourceId=116105338_04_05_99&iid=131561214/v.swf"
86
+ tudou_dp_a2.flash.should == "http://www.tudou.com/a/MgWfoV9cT4E/&rpid=116105338&resourceId=116105338_04_05_99&iid=131561214/v.swf"
87
+ end
88
+ end
89
+
90
+ describe "#cover" do
91
+ it "should return cover" do
92
+ tudou_a.cover.should match(/tdimg|ykimg/)
93
+ tudou_a1.cover.should match(/tdimg|ykimg/)
94
+ end
95
+ end
96
+
97
+ describe "#media" do
98
+ it "return media url" do
99
+ tudou_a.media["f4v"].count.should be(0)
100
+ tudou_a.media["flv"].count.should be(0)
101
+ end
102
+ end
103
+ end
104
+
105
+ context "when url type is playlist" do
106
+ let(:tudou_l){Getvideo::Tudou.new "http://www.tudou.com/listplay/ofVJWe0u0sI.html"}
107
+ let(:tudou_l_swf){Getvideo::Tudou.new "http://www.tudou.com/l/ofVJWe0u0sI/&rpid=116105338&resourceId=116105338_04_05_99&iid=126315712/v.swf"}
108
+ let(:tudou_l2){Getvideo::Tudou.new "http://www.tudou.com/listplay/ofVJWe0u0sI/_4805-g0kM8.html"}
109
+ let(:tudou_l2_swf){Getvideo::Tudou.new "http://www.tudou.com/l/ofVJWe0u0sI/&rpid=116105338&resourceId=116105338_04_05_99&iid=126330996/v.swf"}
110
+ let(:tudou_dp_l){Getvideo::Tudou.new "http://dp.tudou.com/l/ofVJWe0u0sI.html"}
111
+ let(:tudou_dp_l2){Getvideo::Tudou.new "http://dp.tudou.com/l/ofVJWe0u0sI/_4805-g0kM8.html"}
112
+
113
+ describe "#id" do
114
+ it "should return id" do
115
+ tudou_l.id.should == "161629341"
116
+ tudou_l_swf.id.should == "126315712"
117
+ tudou_l2.id.should == "126330996"
118
+ tudou_l2_swf.id.should == "126330996"
119
+ tudou_dp_l.id.should == "161629341"
120
+ tudou_dp_l2.id.should == "126330996"
121
+ end
122
+ end
123
+
124
+ describe "#html_url" do
125
+ it "should return id" do
126
+ tudou_l_swf.html_url.should == "http://www.tudou.com/listplay/ofVJWe0u0sI/zsbv-3JbxJk.html"
127
+ tudou_l2_swf.html_url.should == "http://www.tudou.com/listplay/ofVJWe0u0sI/_4805-g0kM8.html"
128
+ end
129
+ end
130
+
131
+ describe "#flash" do
132
+ it "should return flash" do
133
+ tudou_l.flash.should == "http://www.tudou.com/l/ofVJWe0u0sI/&rpid=116105338&resourceId=116105338_04_05_99&iid=161629341/v.swf"
134
+ tudou_l2.flash.should == "http://www.tudou.com/l/ofVJWe0u0sI/&rpid=116105338&resourceId=116105338_04_05_99&iid=126330996/v.swf"
135
+ end
136
+ end
137
+
138
+ end
139
+
140
+ context "when url type is oplay" do
141
+ let(:tudou_o){Getvideo::Tudou.new "http://www.tudou.com/oplay/6jo2_Ep6Jbg.html"}
142
+ let(:tudou_o_swf){Getvideo::Tudou.new "http://www.tudou.com/o/6jo2_Ep6Jbg/&resourceId=0_04_05_99&iid=130441856/v.swf"}
143
+ let(:tudou_o2){Getvideo::Tudou.new "http://www.tudou.com/oplay/6jo2_Ep6Jbg/pJKf69qZMyQ.html"}
144
+ let(:tudou_o2_swf){Getvideo::Tudou.new "http://www.tudou.com/o/6jo2_Ep6Jbg/&resourceId=0_04_05_99&iid=130441856/v.swf"}
145
+
146
+ describe "#id" do
147
+ it "should return id" do
148
+ tudou_o.id.should == "130441856"
149
+ tudou_o_swf.id.should == "130441856"
150
+ tudou_o2.id.should == "130441856"
151
+ tudou_o2_swf.id.should == "130441856"
152
+ end
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,47 @@
1
+ #coding:utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Getvideo::Youku do
5
+ let(:youku){ Getvideo::Youku.new("http://v.youku.com/v_show/id_XNDQ2MzE4MzMy.html") }
6
+ let(:youku_vip){ Getvideo::Youku.new "http://v.youku.com/v_show/id_XNDYzOTQ1OTky.html" }
7
+ let(:youku_swf){ Getvideo::Youku.new "http://player.youku.com/player.php/sid/XNDQ2MzE4MzMy/v.swf"}
8
+ let(:youku_id){ Getvideo::Youku.new "XNDQ2MzE4MzMy"}
9
+
10
+ describe "#html_url" do
11
+ it{ youku.html_url.should == "http://v.youku.com/v_show/id_XNDQ2MzE4MzMy.html" }
12
+ it{ youku_vip.html_url.should == "http://v.youku.com/v_show/id_XNDYzOTQ1OTky.html" }
13
+ end
14
+
15
+ describe "#title" do
16
+ it{ youku.title.should match(/1/)}
17
+ it{ youku_vip.title.should match(/青楼/)}
18
+ end
19
+
20
+ describe "#id" do
21
+ context "when is html url" do
22
+ it{ youku.id.should == "XNDQ2MzE4MzMy" }
23
+ end
24
+
25
+ context "when is swf url" do
26
+ it{ youku_swf.id.should == "XNDQ2MzE4MzMy" }
27
+ end
28
+ end
29
+
30
+ describe "#cover" do
31
+ it{ youku.cover.should =~ /ykimg\.com/ }
32
+ end
33
+
34
+ describe "#flash" do
35
+ it { youku.flash.should == "http://player.youku.com/player.php/sid/XNDQ2MzE4MzMy/v.swf" }
36
+ end
37
+
38
+ describe "#media" do
39
+ let(:youku){ Getvideo::Youku.new "http://v.youku.com/v_show/id_XNDYwNjU1NDky.html" }
40
+ it{ youku.media.count.should equal(3) }
41
+ it{ youku_vip.media.count.should equal(3) }
42
+ end
43
+
44
+ describe "#m3u8" do
45
+ it{ youku.m3u8.should == "http://v.youku.com/player/getM3U8/vid/111579583/type/flv/ts/v.m3u8" }
46
+ end
47
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Getvideo::Youtube do
4
+ let(:youtube){ Getvideo::Youtube.new "http://www.youtube.com/watch?v=ylLzyHk54Z0" }
5
+ let(:youtube2){ Getvideo::Youtube.new "http://www.youtube.com/watch?v=S0o4-efO9x4&feature=g-vrec" }
6
+ let(:youtube3){ Getvideo::Youtube.new "http://www.youtube.com/watch?v=5AhMZ04H094" }
7
+ let(:youtube_s){ Getvideo::Youtube.new "http://youtu.be/ylLzyHk54Z0" }
8
+ let(:youtube_id){ Getvideo::Youtube.new "ylLzyHk54Z0" }
9
+ let(:youtube_swf){ Getvideo::Youtube.new "http://www.youtube.com/v/ylLzyHk54Z0" }
10
+
11
+ describe "#id" do
12
+ it "should return id" do
13
+ youtube.id.should == "ylLzyHk54Z0"
14
+ youtube2.id.should == "S0o4-efO9x4"
15
+ youtube3.id.should == "pI47zdMhX3I"
16
+ youtube_swf.id.should == "ylLzyHk54Z0"
17
+ youtube_s.id.should == "ylLzyHk54Z0"
18
+ youtube_id.id.should == "ylLzyHk54Z0"
19
+ end
20
+ end
21
+
22
+ describe "#html_url" do
23
+ it "should return html url" do
24
+ youtube_swf.html_url.should == "http://www.youtube.com/watch?v=ylLzyHk54Z0"
25
+ youtube_id.html_url.should == "http://www.youtube.com/watch?v=ylLzyHk54Z0"
26
+ end
27
+ end
28
+
29
+ describe "#cover" do
30
+ it{ youtube.cover.should =~ /ytimg/}
31
+ end
32
+
33
+ describe "#flash" do
34
+ it{ youtube.flash.should == "http://www.youtube.com/v/ylLzyHk54Z0"}
35
+ end
36
+
37
+ describe "#title" do
38
+ it{ youtube.title.should match(/API/)}
39
+ it{ youtube3.title.should match(/2012/)}
40
+ end
41
+
42
+ describe "#m3u8" do
43
+ it{ youtube.m3u8.should match(/youtube\.com/)}
44
+ end
45
+
46
+ describe "media" do
47
+ it{ youtube.media["flv"][0].should match(/youtube\.com/)}
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: getvideo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - ye.li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: get video
56
+ email:
57
+ - yeeli@outlook.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .rspec
64
+ - Gemfile
65
+ - Guardfile
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - getvideo.gemspec
70
+ - lib/getvideo.rb
71
+ - lib/getvideo/56.rb
72
+ - lib/getvideo/iask.rb
73
+ - lib/getvideo/iqiyi.rb
74
+ - lib/getvideo/ku6.rb
75
+ - lib/getvideo/sohu.rb
76
+ - lib/getvideo/tudou.rb
77
+ - lib/getvideo/version.rb
78
+ - lib/getvideo/video.rb
79
+ - lib/getvideo/youku.rb
80
+ - lib/getvideo/youtube.rb
81
+ - spec/56_spec.rb
82
+ - spec/getvideo_spec.rb
83
+ - spec/iask_spec.rb
84
+ - spec/iqiyi_spec.rb
85
+ - spec/ku6_spec.rb
86
+ - spec/sohu_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/tudou_spec.rb
89
+ - spec/youku_spec.rb
90
+ - spec/youtube_spec.rb
91
+ homepage: ''
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.0.3
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: get video
115
+ test_files:
116
+ - spec/56_spec.rb
117
+ - spec/getvideo_spec.rb
118
+ - spec/iask_spec.rb
119
+ - spec/iqiyi_spec.rb
120
+ - spec/ku6_spec.rb
121
+ - spec/sohu_spec.rb
122
+ - spec/spec_helper.rb
123
+ - spec/tudou_spec.rb
124
+ - spec/youku_spec.rb
125
+ - spec/youtube_spec.rb
126
+ has_rdoc: