acts_as_unvlogable_fork 1.0.1 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +1 -1
- data/.travis.yml +3 -0
- data/Gemfile +4 -8
- data/README.markdown +7 -29
- data/Rakefile +1 -1
- data/acts_as_unvlogable.gemspec +10 -6
- data/lib/acts_as_unvlogable.rb +24 -24
- data/lib/acts_as_unvlogable/flickr.rb +3 -487
- data/lib/acts_as_unvlogable/string_extend.rb +0 -1
- data/lib/acts_as_unvlogable/version.rb +1 -1
- data/lib/acts_as_unvlogable/vg_11870.rb +6 -8
- data/lib/acts_as_unvlogable/vg_blip.rb +3 -8
- data/lib/acts_as_unvlogable/vg_collegehumor.rb +2 -6
- data/lib/acts_as_unvlogable/vg_dailymotion.rb +2 -7
- data/lib/acts_as_unvlogable/vg_dalealplay.rb +5 -9
- data/lib/acts_as_unvlogable/vg_flickr.rb +0 -14
- data/lib/acts_as_unvlogable/vg_metacafe.rb +2 -21
- data/lib/acts_as_unvlogable/vg_myspace.rb +5 -11
- data/lib/acts_as_unvlogable/{vg_prostopleer.rb → vg_pleer.rb} +6 -14
- data/lib/acts_as_unvlogable/vg_rutube.rb +6 -50
- data/lib/acts_as_unvlogable/vg_ted.rb +6 -14
- data/lib/acts_as_unvlogable/vg_vimeo.rb +3 -22
- data/lib/acts_as_unvlogable/vg_wistia.rb +49 -0
- data/lib/acts_as_unvlogable/vg_youtube.rb +11 -31
- data/spec/acts_as_unvlogable_spec.rb +363 -0
- data/spec/spec_helper.rb +4 -0
- data/unvlogable_sample.yml +3 -0
- metadata +44 -14
- data/lib/acts_as_unvlogable/vg_marca.rb +0 -48
- data/lib/acts_as_unvlogable/vg_qik.rb +0 -64
- data/test/acts_as_unvlogable_test.rb +0 -392
- data/test/video_factory_test.rb +0 -66
@@ -0,0 +1,49 @@
|
|
1
|
+
# ----------------------------------------------
|
2
|
+
# Class for Wistia (wistia.com)
|
3
|
+
# https://home.wistia.com/medias/e4a27b971d
|
4
|
+
# ----------------------------------------------
|
5
|
+
|
6
|
+
class VgWistia
|
7
|
+
attr_reader :title, :thumbnail, :duration, :service
|
8
|
+
|
9
|
+
def initialize(url=nil, options={})
|
10
|
+
@url = url
|
11
|
+
fetch_video_details!
|
12
|
+
assign_properties!
|
13
|
+
end
|
14
|
+
|
15
|
+
def embed_url
|
16
|
+
iframe = Nokogiri::HTML(@details["html"])
|
17
|
+
iframe.xpath("//iframe").first["src"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def embed_html(width=425, height=344, options={}, params={})
|
21
|
+
"<iframe src='#{embed_url}' allowtransparency='true' frameborder='0' scrolling='no' class='wistia_embed' name='wistia_embed' allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width='#{width}' height='#{height}'></iframe>"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def fetch_video_details!
|
27
|
+
begin
|
28
|
+
res = Net::HTTP.get(URI.parse(wistia_oembed_endpoint))
|
29
|
+
@details = JSON.parse(res)
|
30
|
+
rescue JSON::ParserError
|
31
|
+
raise ArgumentError.new("Unsuported url or service")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def assign_properties!
|
36
|
+
@title = @details["title"]
|
37
|
+
@thumbnail = @details["thumbnail_url"]
|
38
|
+
@duration = @details["duration"]
|
39
|
+
@service = @details["provider_name"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def encoded_url
|
43
|
+
CGI::escape(@url)
|
44
|
+
end
|
45
|
+
|
46
|
+
def wistia_oembed_endpoint
|
47
|
+
"http://fast.wistia.com/oembed.json?url=#{encoded_url}"
|
48
|
+
end
|
49
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# ----------------------------------------------
|
2
2
|
# Class for Youtube (youtube.com)
|
3
|
-
# http://www.youtube.com/watch?v=
|
3
|
+
# http://www.youtube.com/watch?v=MVa4q-YVjD8
|
4
4
|
# ----------------------------------------------
|
5
5
|
|
6
6
|
class VgYoutube
|
7
7
|
|
8
8
|
def initialize(url=nil, options={})
|
9
|
-
|
9
|
+
settings ||= YAML.load_file(Rails.root.join 'config/unvlogable.yml')[Rails.env] rescue {}
|
10
|
+
Yt.configuration.api_key = options.nil? || options[:key].nil? ? settings['youtube_key'] : options[:key]
|
11
|
+
|
10
12
|
@url = url
|
11
13
|
@video_id = @url.query_param('v')
|
12
14
|
begin
|
13
|
-
@details =
|
14
|
-
raise if @details.blank?
|
15
|
-
raise ArgumentError, "Embedding disabled by request" unless @details.embeddable?
|
16
|
-
@details.instance_variable_set(:@noembed, false)
|
15
|
+
@details = Yt::Video.new id: @video_id
|
16
|
+
raise if @details.blank? || !@details.embeddable?
|
17
17
|
rescue
|
18
18
|
raise ArgumentError, "Unsuported url or service"
|
19
19
|
end
|
@@ -24,7 +24,7 @@ class VgYoutube
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def thumbnail
|
27
|
-
@details.
|
27
|
+
@details.thumbnail_url
|
28
28
|
end
|
29
29
|
|
30
30
|
def duration
|
@@ -32,36 +32,16 @@ class VgYoutube
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def embed_url
|
35
|
-
|
35
|
+
"http://www.youtube.com/embed/#{@video_id}" if @details.embeddable?
|
36
36
|
end
|
37
37
|
|
38
|
-
#
|
39
|
-
# You can read more about the youtube player options in
|
40
|
-
# http://code.google.com/intl/en/apis/youtube/player_parameters.html
|
41
|
-
# Use them in options (ex {:rel => 0, :color1 => '0x333333'})
|
42
|
-
#
|
38
|
+
# iframe embed — https://developers.google.com/youtube/player_parameters#Manual_IFrame_Embeds
|
43
39
|
def embed_html(width=425, height=344, options={}, params={})
|
44
|
-
"<
|
40
|
+
"<iframe id='ytplayer' type='text/html' width='#{width}' height='#{height}' src='#{embed_url}#{options.map {|k,v| "&#{k}=#{v}"}}' frameborder='0'/>" if @details.embeddable?
|
45
41
|
end
|
46
42
|
|
47
|
-
|
48
|
-
def flv
|
49
|
-
doc = URI::parse("http://www.youtube.com/get_video_info?&video_id=#{@video_id}").read
|
50
|
-
CGI::unescape(doc.split("&url_encoded_fmt_stream_map=")[1]).split("url=").each do |u|
|
51
|
-
u = CGI::unescape(u)
|
52
|
-
unless u.index("x-flv").nil?
|
53
|
-
return u.split("&quality").first
|
54
|
-
break
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def download_url
|
60
|
-
flv
|
61
|
-
end
|
62
|
-
|
63
43
|
def service
|
64
44
|
"Youtube"
|
65
45
|
end
|
66
46
|
|
67
|
-
end
|
47
|
+
end
|
@@ -0,0 +1,363 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe UnvlogIt do
|
5
|
+
context "without any url" do
|
6
|
+
it {
|
7
|
+
expect { UnvlogIt.new }.to raise_error(ArgumentError, "We need a video url")
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
context "with an unsupported url" do
|
12
|
+
it {
|
13
|
+
expect { UnvlogIt.new("http://iwannagothere.net") }.to raise_error(ArgumentError, "Unsuported url or service")
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
# ----------------------------------------------------------
|
18
|
+
# Testing youtube
|
19
|
+
# ----------------------------------------------------------
|
20
|
+
|
21
|
+
context "with an existent youtube url" do
|
22
|
+
let(:videotron) { UnvlogIt.new("http://www.youtube.com/watch?v=MVa4q-YVjD8", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) } # => Keith Moon´s drum kit explodes
|
23
|
+
|
24
|
+
it "initialize a VgYoutube instance" do
|
25
|
+
expect(VgYoutube).to eq(videotron.instance_values['object'].class)
|
26
|
+
expect("http://www.youtube.com/watch?v=MVa4q-YVjD8").to eq(videotron.instance_values['object'].instance_values['url'])
|
27
|
+
expect("MVa4q-YVjD8").to eq(videotron.instance_values['object'].instance_values['video_id'])
|
28
|
+
expect(videotron.instance_values['object'].instance_values['details']).to_not be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns the video properties" do
|
32
|
+
check_video_attributes({:title => "Keith Moon´s drum kit explodes", :service => "Youtube"})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with an existent youtube url that can not be embedded" do
|
37
|
+
it {
|
38
|
+
expect { UnvlogIt.new("https://www.youtube.com/watch?v=-PZYZ6fJbr4", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) }.to raise_error(ArgumentError, "Unsuported url or service")
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with an inexistent youtube url" do
|
43
|
+
it {
|
44
|
+
expect { UnvlogIt.new("http://www.youtube.com/watch?v=inexistente", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) }.to raise_error(ArgumentError, "Unsuported url or service")
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with a shortened youtube URL" do
|
49
|
+
let(:videotron) { UnvlogIt.new("http://youtu.be/4pzMBtPMUq8", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) } # => Keith Moon´s drum kit explodes
|
50
|
+
|
51
|
+
it "initialize a VgYoutube instance" do
|
52
|
+
expect(VgYoutu).to eq(videotron.instance_values['object'].class)
|
53
|
+
expect("http://www.youtube.com/watch?&v=4pzMBtPMUq8").to eq(videotron.instance_values['object'].instance_values['url'])
|
54
|
+
expect("4pzMBtPMUq8").to eq(videotron.instance_values['object'].instance_values['video_id'])
|
55
|
+
expect(videotron.instance_values['object'].instance_values['details']).to_not be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns the video properties" do
|
59
|
+
check_video_attributes({:title => "APM? Capítol 349 -09/04/14- (HD)", :service => "Youtube"})
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# ----------------------------------------------------------
|
64
|
+
# Testing metacafe
|
65
|
+
# ----------------------------------------------------------
|
66
|
+
|
67
|
+
context "with an existent metacafe url" do
|
68
|
+
let(:videotron) { UnvlogIt.new("http://www.metacafe.com/watch/1135061/close_call_a320_caught_in_crosswinds/") } # => Close Call! A320 Caught in Crosswinds
|
69
|
+
|
70
|
+
it "initialize a VgMetacafe instance" do
|
71
|
+
expect(VgMetacafe).to eq(videotron.instance_values['object'].class)
|
72
|
+
expect("http://www.metacafe.com/watch/1135061/close_call_a320_caught_in_crosswinds/").to eq(videotron.instance_values['object'].instance_values['url'])
|
73
|
+
expect(3).to eq(videotron.instance_values['object'].instance_values['args'].size)
|
74
|
+
expect(videotron.instance_values['object'].instance_values['yt']).to be_nil
|
75
|
+
expect(videotron.instance_values['object'].instance_values['youtubed']).to be false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns the video properties" do
|
79
|
+
check_video_attributes({:title => "Close call a320 caught in crosswinds", :service => "Metacafe"})
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with an existent 'youtubed' metacafe url" do
|
84
|
+
let(:videotron) { UnvlogIt.new("http://www.metacafe.com/watch/yt-r07zdVLOWBA/pop_rocks_and_coke_myth/", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) } # => Pop Rocks and Coke Myth
|
85
|
+
|
86
|
+
it "initialize a VgMetacafe instance" do
|
87
|
+
expect(VgMetacafe).to eq(videotron.instance_values['object'].class)
|
88
|
+
expect("http://www.metacafe.com/watch/yt-r07zdVLOWBA/pop_rocks_and_coke_myth/").to eq(videotron.instance_values['object'].instance_values['url'])
|
89
|
+
expect(3).to eq(videotron.instance_values['object'].instance_values['args'].size)
|
90
|
+
expect("VgYoutube").to eq(videotron.instance_values['object'].instance_values['yt'].class.to_s)
|
91
|
+
expect(videotron.instance_values['object'].instance_values['youtubed']).to be true
|
92
|
+
end
|
93
|
+
|
94
|
+
it "returns the video properties" do
|
95
|
+
check_video_attributes({:title => "Pop Rocks and Coke Myth", :service => "Metacafe"})
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# ----------------------------------------------------------
|
100
|
+
# Testing dailymotion
|
101
|
+
# ----------------------------------------------------------
|
102
|
+
|
103
|
+
context "with an existent dailymotion url" do
|
104
|
+
let(:videotron) { UnvlogIt.new("http://www.dailymotion.com/video/x7u5kn_parkour-dayyy_sport/") } # => parkour dayyy
|
105
|
+
|
106
|
+
it "initialize a VgDailymotion instance" do
|
107
|
+
expect(VgDailymotion).to eq(videotron.instance_values['object'].class)
|
108
|
+
expect("http://www.dailymotion.com/video/x7u5kn_parkour-dayyy_sport/").to eq(videotron.instance_values['object'].instance_values['url'])
|
109
|
+
expect("x7u5kn_parkour-dayyy_sport").to eq(videotron.instance_values['object'].instance_values['video_id'])
|
110
|
+
expect(videotron.instance_values['object'].instance_values['feed']).to_not be_nil
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns the video properties" do
|
114
|
+
check_video_attributes({:title => "parkour dayyy", :service => "Dailymotion"})
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# ----------------------------------------------------------
|
119
|
+
# Testing collegehumor
|
120
|
+
# ----------------------------------------------------------
|
121
|
+
|
122
|
+
context "with an existent collegehumor url" do
|
123
|
+
let(:videotron) { UnvlogIt.new("http://www.collegehumor.com/video/3005349/brohemian-rhapsody/") } # => Brohemian Rhapsody
|
124
|
+
|
125
|
+
it "initialize a VgCollegehumor instance" do
|
126
|
+
expect(VgCollegehumor).to eq(videotron.instance_values['object'].class)
|
127
|
+
expect("http://www.collegehumor.com/video/3005349/brohemian-rhapsody/").to eq(videotron.instance_values['object'].instance_values['url'])
|
128
|
+
expect("3005349").to eq(videotron.instance_values['object'].instance_values['video_id'])
|
129
|
+
expect(videotron.instance_values['object'].instance_values['feed']).to_not be_nil
|
130
|
+
end
|
131
|
+
|
132
|
+
it "returns the video properties" do
|
133
|
+
check_video_attributes({:title => "Brohemian Rhapsody", :service => "CollegeHumor"})
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# ----------------------------------------------------------
|
138
|
+
# Testing blip.tv
|
139
|
+
# ----------------------------------------------------------
|
140
|
+
|
141
|
+
context "with an existent blip.tv url" do
|
142
|
+
let(:videotron) { UnvlogIt.new("http://blip.tv/sarahrdtv/sarah-s-super-bowl-spread-healthy-recipe-classic-buffalo-wing-dip-6717535") } # => Sarah's Super Bowl Spread – Healthy Recipe - Classic Buffalo Wing Dip
|
143
|
+
|
144
|
+
it "initialize a VgBlip instance" do
|
145
|
+
expect(VgBlip).to eq(videotron.instance_values['object'].class)
|
146
|
+
expect("http://blip.tv/sarahrdtv/sarah-s-super-bowl-spread-healthy-recipe-classic-buffalo-wing-dip-6717535").to eq(videotron.instance_values['object'].instance_values['url'])
|
147
|
+
expect(videotron.instance_values['object'].instance_values['feed']).to_not be_nil
|
148
|
+
end
|
149
|
+
|
150
|
+
it "returns the video properties" do
|
151
|
+
check_video_attributes({:title => "Sarah's Super Bowl Spread – Healthy Recipe - Classic Buffalo Wing Dip", :service => "Blip.tv"})
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# ----------------------------------------------------------
|
156
|
+
# Testing myspace.com
|
157
|
+
# ----------------------------------------------------------
|
158
|
+
context "with an existent myspace.com url" do
|
159
|
+
let(:videotron) { UnvlogIt.new("https://myspace.com/jimmykimmellive/video/mastodon-the-motherload-/109586961") } # => Mastodon - The Motherload
|
160
|
+
|
161
|
+
it "initialize a VgMyspace instance" do
|
162
|
+
expect(VgMyspace).to eq(videotron.instance_values['object'].class)
|
163
|
+
expect("https://myspace.com/jimmykimmellive/video/mastodon-the-motherload-/109586961").to eq(videotron.instance_values['object'].instance_values['url'])
|
164
|
+
expect(videotron.instance_values['object'].instance_values['page']).to_not be_nil
|
165
|
+
end
|
166
|
+
|
167
|
+
it "returns the video properties" do
|
168
|
+
check_video_attributes({:title => "Mastodon - The Motherload", :service => "Myspace"})
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
# ----------------------------------------------------------
|
174
|
+
# Testing 11870.com
|
175
|
+
# ----------------------------------------------------------
|
176
|
+
context "with an existent 11870.com url" do
|
177
|
+
let(:videotron) { UnvlogIt.new("http://11870.com/pro/chic-basic-born/media/b606abfe") } # => Chic & Basic Born
|
178
|
+
|
179
|
+
it "initialize a Vg11870 instance" do
|
180
|
+
expect(Vg11870).to eq(videotron.instance_values['object'].class)
|
181
|
+
expect("https://11870.com/pro/chic-basic-born/media/b606abfe").to eq(videotron.instance_values['object'].instance_values['url'])
|
182
|
+
expect(videotron.instance_values['object'].instance_values['page']).to_not be_nil
|
183
|
+
end
|
184
|
+
|
185
|
+
it "returns the video properties" do
|
186
|
+
check_video_attributes({:title => "Chic & Basic Born", :service => "11870.com"})
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
# ----------------------------------------------------------
|
192
|
+
# Testing dalealplay.com
|
193
|
+
# ----------------------------------------------------------
|
194
|
+
context "with an existent dalealplay.com url" do
|
195
|
+
let(:videotron) { UnvlogIt.new("http://www.dalealplay.com/informaciondecontenido.php?con=80280") } # => Camelos Semos Jonathan Tú si que vales
|
196
|
+
|
197
|
+
it "initialize a VgDalealplay instance" do
|
198
|
+
expect(VgDalealplay).to eq(videotron.instance_values['object'].class)
|
199
|
+
expect("http://www.dalealplay.com/informaciondecontenido.php?con=80280").to eq(videotron.instance_values['object'].instance_values['url'])
|
200
|
+
expect("80280").to eq(videotron.instance_values['object'].instance_values['video_id'])
|
201
|
+
expect(videotron.instance_values['object'].instance_values['page']).to_not be_nil
|
202
|
+
end
|
203
|
+
|
204
|
+
it "returns the video properties" do
|
205
|
+
check_video_attributes({:title => "Camelos.Semos. Jonathan. Tú si que vales.", :service => "dalealplay"})
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
# ----------------------------------------------------------
|
211
|
+
# Testing flickr.com
|
212
|
+
# ----------------------------------------------------------
|
213
|
+
context "with a flickr.com video url" do
|
214
|
+
let(:videotron) { UnvlogIt.new("http://www.flickr.com/photos/jerovital/4152225414/", {:key => "065b2eff5e604e2a408c01af1f27a982" }) }# => flipando en los columpios
|
215
|
+
|
216
|
+
it "initialize a VgFlickr instance" do
|
217
|
+
expect(VgFlickr).to eq(videotron.instance_values['object'].class)
|
218
|
+
expect("http://www.flickr.com/photos/jerovital/4152225414/").to eq(videotron.instance_values['object'].instance_values['url'])
|
219
|
+
expect("4152225414").to eq(videotron.instance_values['object'].instance_values['video_id'])
|
220
|
+
expect(videotron.instance_values['object'].instance_values['details']).to_not be_nil
|
221
|
+
end
|
222
|
+
|
223
|
+
it "returns the video properties" do
|
224
|
+
check_video_attributes({:title => "flipando en los columpios", :service => "Flickr"})
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
# ----------------------------------------------------------
|
230
|
+
# Testing ted talks
|
231
|
+
# ----------------------------------------------------------
|
232
|
+
context "with an existent ted talks url" do
|
233
|
+
let(:videotron) { UnvlogIt.new("http://www.ted.com/talks/benjamin_wallace_on_the_price_of_happiness") } # => Benjamin Wallace: Does happiness have a price tag?
|
234
|
+
|
235
|
+
it "initialize a VgTed instance" do
|
236
|
+
expect(VgTed).to eq(videotron.instance_values['object'].class)
|
237
|
+
expect("http://www.ted.com/talks/benjamin_wallace_on_the_price_of_happiness").to eq(videotron.instance_values['object'].instance_values['url'])
|
238
|
+
expect(videotron.instance_values['object'].instance_values['page']).to_not be_nil
|
239
|
+
end
|
240
|
+
|
241
|
+
it "returns the video properties" do
|
242
|
+
check_video_attributes({:title => "The price of happiness", :service => "Ted Talks"})
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context "with a non existent ted talks url" do
|
247
|
+
it "should raise an error" do
|
248
|
+
expect{ UnvlogIt.new("http://www.ted.com/index.php/wadus.html") }.to raise_error(ArgumentError, "Unsuported url or service")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
# ----------------------------------------------------------
|
254
|
+
# Testing vimeo
|
255
|
+
# ----------------------------------------------------------
|
256
|
+
context "with an existent vimeo url" do
|
257
|
+
let(:videotron) { UnvlogIt.new("http://vimeo.com/119318850") } # => Gotham City SF // A Timelapse Film
|
258
|
+
|
259
|
+
it "initialize a VgVimeo instance" do
|
260
|
+
expect(VgVimeo).to eq(videotron.instance_values['object'].class)
|
261
|
+
expect("http://vimeo.com/119318850").to eq(videotron.instance_values['object'].instance_values['url'])
|
262
|
+
expect("119318850").to eq(videotron.instance_values['object'].instance_values['video_id'])
|
263
|
+
expect(videotron.instance_values['object'].instance_values['feed']).to_not be_nil
|
264
|
+
end
|
265
|
+
|
266
|
+
it "returns the video properties" do
|
267
|
+
check_video_attributes({:title => "Gotham City SF // A Timelapse Film", :service => "Vimeo"})
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
|
272
|
+
# ----------------------------------------------------------
|
273
|
+
# Testing RuTube
|
274
|
+
# ----------------------------------------------------------
|
275
|
+
context "with an existent rutube url" do
|
276
|
+
let(:videotron) { UnvlogIt.new("http://rutube.ru/video/520685fa20c456e200e683f3df17b131/") } # => chipmunks!!
|
277
|
+
|
278
|
+
it "initialize a VgRutube instance" do
|
279
|
+
expect(VgRutube).to eq(videotron.instance_values['object'].class)
|
280
|
+
expect("http://rutube.ru/video/520685fa20c456e200e683f3df17b131/").to eq(videotron.instance_values['object'].instance_values['url'])
|
281
|
+
expect(videotron.instance_values['object'].instance_values['page']).to_not be_nil
|
282
|
+
end
|
283
|
+
|
284
|
+
it "returns the video properties" do
|
285
|
+
check_video_attributes({:title => "Запасливые бурундуки", :service => "Rutube"})
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
context "with an invalid rutube url" do
|
290
|
+
it "should raise an error" do
|
291
|
+
expect{ UnvlogIt.new("http://rutube.ru/tracks/abdcd.html?v=523423") }.to raise_error(ArgumentError, "Unsuported url or service")
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
# ----------------------------------------------------------
|
296
|
+
# Testing Prostopleer
|
297
|
+
# ----------------------------------------------------------
|
298
|
+
context "with an existent pleer url" do
|
299
|
+
let(:videotron) { UnvlogIt.new("http://pleer.com/tracks/3370305QRJl") } # => La mala rodriguez, Nach Scratch SFDK - Dominicana
|
300
|
+
|
301
|
+
it "initialize a VgPleer instance" do
|
302
|
+
expect(VgPleer).to eq(videotron.instance_values['object'].class)
|
303
|
+
expect("http://pleer.com/tracks/3370305QRJl").to eq(videotron.instance_values['object'].instance_values['url'])
|
304
|
+
expect("3370305QRJl").to eq(videotron.instance_values['object'].instance_values['track_id'])
|
305
|
+
expect("Pleer").to eq(videotron.service)
|
306
|
+
expect(videotron.embed_html).not_to be_nil
|
307
|
+
expect("La mala rodriguez, Nach Scratch SFDK - Dominicana").to eq(videotron.title)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
context "with an invalid pleer url" do
|
312
|
+
it "should raise an error" do
|
313
|
+
expect{ UnvlogIt.new("http://prostopleer.com/trackszz/401758bI6n") }.to raise_error(ArgumentError, "Unsuported url or service")
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
|
318
|
+
# ----------------------------------------------------------
|
319
|
+
# Testing Wistia
|
320
|
+
# ----------------------------------------------------------
|
321
|
+
context "with an existent wistia url" do
|
322
|
+
let(:videotron) { UnvlogIt.new("https://home.wistia.com/medias/e4a27b971d") } # => Brendan - Make It Clap
|
323
|
+
|
324
|
+
it "initialize a VgWistia instance" do
|
325
|
+
expect(VgWistia).to eq(videotron.instance_values['object'].class)
|
326
|
+
expect("https://home.wistia.com/medias/e4a27b971d").to eq(videotron.instance_values['object'].instance_values['url'])
|
327
|
+
end
|
328
|
+
|
329
|
+
it "returns the video properties" do
|
330
|
+
check_video_attributes({
|
331
|
+
:title => "Brendan - Make It Clap",
|
332
|
+
:service => "Wistia, Inc.",
|
333
|
+
:duration => 16.43,
|
334
|
+
:thumbnail => "https://embed-ssl.wistia.com/deliveries/2d2c14e15face1e0cc7aac98ebd5b6f040b950b5.jpg?image_crop_resized=640x360"
|
335
|
+
})
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
context "with a non existent wistia url" do
|
340
|
+
it "should raise an error" do
|
341
|
+
expect{ UnvlogIt.new("https://gadabouting.wistia.com/medias/inexistent") }.to raise_error(ArgumentError, "Unsuported url or service")
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
protected
|
346
|
+
|
347
|
+
def check_video_attributes(options={})
|
348
|
+
expect(options[:title]).to eq(videotron.title) unless (options.blank? || options[:title].blank?)
|
349
|
+
expect(options[:service]).to eq(videotron.service) unless (options.blank? || options[:service].blank?)
|
350
|
+
expect(videotron.thumbnail).not_to be_nil
|
351
|
+
if options.blank? || options[:noembed].blank?
|
352
|
+
expect(videotron.embed_url).not_to be_nil
|
353
|
+
expect(videotron.embed_html).not_to be_nil
|
354
|
+
elsif options[:noembed]
|
355
|
+
expect(videotron.embed_url).to be_nil
|
356
|
+
expect(videotron.embed_html).to be_nil
|
357
|
+
expect(videotron.video_details[:embed_url]).to be_nil
|
358
|
+
expect(videotron.video_details[:embed_html]).to be_nil
|
359
|
+
end
|
360
|
+
expect(videotron.flv).to be_nil
|
361
|
+
expect(Hash).to eq(videotron.video_details.class)
|
362
|
+
end
|
363
|
+
end
|