ruby-oembed 0.14.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/CHANGELOG.rdoc +25 -2
- data/README.md +5 -7
- data/lib/oembed/provider.rb +54 -5
- data/lib/oembed/providers/builtin_providers.rb +292 -0
- data/lib/oembed/providers/facebook_post.rb +27 -17
- data/lib/oembed/providers/facebook_video.rb +22 -10
- data/lib/oembed/providers/instagram.rb +37 -20
- data/lib/oembed/providers/tiktok.rb +13 -0
- data/lib/oembed/providers.rb +39 -300
- data/lib/oembed/version.rb +2 -2
- data/lib/oembed.rb +1 -0
- data/ruby-oembed.gemspec +1 -2
- metadata +9 -53
- data/integration_test/test.rb +0 -31
- data/integration_test/test_urls.csv +0 -502
- data/spec/cassettes/OEmbed_Provider.yml +0 -987
- data/spec/cassettes/OEmbed_ProviderDiscovery.yml +0 -27184
- data/spec/cassettes/OEmbed_Providers_Slideshare.yml +0 -1433
- data/spec/cassettes/OEmbed_Providers_Twitter.yml +0 -612
- data/spec/formatter/ducktype_backend_spec.rb +0 -94
- data/spec/formatter/json/.DS_Store +0 -0
- data/spec/formatter/json/jsongem_backend_spec.rb +0 -71
- data/spec/formatter/json/yaml_backend_spec.rb +0 -55
- data/spec/formatter/xml/nokogiri_backend_spec.rb +0 -59
- data/spec/formatter/xml/rexml_backend_spec.rb +0 -55
- data/spec/formatter/xml/xmlsimple_backend_spec.rb +0 -59
- data/spec/formatter_spec.rb +0 -37
- data/spec/provider_discovery_spec.rb +0 -141
- data/spec/provider_spec.rb +0 -366
- data/spec/providers/facebook_spec.rb +0 -50
- data/spec/providers/slideshare_spec.rb +0 -42
- data/spec/providers/twitter_spec.rb +0 -44
- data/spec/providers_spec.rb +0 -306
- data/spec/response_spec.rb +0 -230
- data/spec/spec_helper.rb +0 -111
- data/spec/spec_helper_examples.yml +0 -27
- data/spec/support/shared_examples_for_providers.rb +0 -39
@@ -1,28 +1,45 @@
|
|
1
1
|
module OEmbed
|
2
2
|
class Providers
|
3
3
|
# Provider for instagram.com
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
# See https://developers.facebook.com/docs/instagram/oembed/
|
5
|
+
Instagram = OEmbed::Provider.new(
|
6
|
+
"https://graph.facebook.com/v8.0/instagram_oembed",
|
7
|
+
required_query_params: { access_token: 'OEMBED_FACEBOOK_TOKEN' },
|
8
|
+
format: :json
|
9
|
+
)
|
10
|
+
Instagram << "http://instagr.am/p/*"
|
11
|
+
Instagram << "http://instagram.com/p/*"
|
12
|
+
Instagram << "http://www.instagram.com/p/*"
|
13
|
+
Instagram << "https://instagr.am/p/*"
|
14
|
+
Instagram << "https://instagram.com/p/*"
|
15
|
+
Instagram << "https://www.instagram.com/p/*"
|
9
16
|
|
10
|
-
|
17
|
+
Instagram << "http://instagr.am/tv/*"
|
18
|
+
Instagram << "http://instagram.com/tv/*"
|
19
|
+
Instagram << "http://www.instagram.com/tv/*"
|
20
|
+
Instagram << "https://instagr.am/tv/*"
|
21
|
+
Instagram << "https://instagram.com/tv/*"
|
22
|
+
Instagram << "https://www.instagram.com/tv/*"
|
11
23
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
Instagram << "http://instagram.com/reel/*"
|
25
|
+
Instagram << "http://www.instagram.com/reel/*"
|
26
|
+
Instagram << "https://instagram.com/reel/*"
|
27
|
+
Instagram << "https://www.instagram.com/reel/*"
|
28
|
+
|
29
|
+
# Note: even though Instagram is automatically registered as an official provider
|
30
|
+
# it will NOT resolve any URLs unless its access_token is set
|
31
|
+
# either via the OEMBED_FACEBOOK_TOKEN environment variable
|
32
|
+
# or by calling `OEmbed::Providers::Instagram.access_token = @your_token`
|
33
|
+
add_official_provider(Instagram, nil, access_token: {name: :facebook, method: :access_token})
|
34
|
+
|
35
|
+
# Respond to the `new` method to maintain backwards compatibility with v0.14.0
|
36
|
+
# See also:
|
37
|
+
# * https://github.com/ruby-oembed/ruby-oembed/pull/75
|
38
|
+
# * https://github.com/ruby-oembed/ruby-oembed/issues/77#issuecomment-727024682
|
39
|
+
# @deprecated *Note*: This method will be be removed in the future.
|
40
|
+
def Instagram.new(access_token:)
|
41
|
+
self.access_token = access_token
|
42
|
+
self
|
26
43
|
end
|
27
44
|
end
|
28
45
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module OEmbed
|
2
|
+
class Providers
|
3
|
+
# Provider for tiktok.com
|
4
|
+
# See https://developers.tiktok.com/doc/embed-videos
|
5
|
+
TikTok = OEmbed::Provider.new(
|
6
|
+
"https://www.tiktok.com/oembed",
|
7
|
+
format: :json
|
8
|
+
)
|
9
|
+
TikTok << "https://www.tiktok.com/*/video/*"
|
10
|
+
|
11
|
+
add_official_provider(TikTok)
|
12
|
+
end
|
13
|
+
end
|
data/lib/oembed/providers.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'yaml'
|
3
3
|
|
4
|
-
require 'oembed/providers/facebook_post'
|
5
|
-
require 'oembed/providers/facebook_video'
|
6
|
-
require 'oembed/providers/instagram'
|
7
|
-
|
8
4
|
module OEmbed
|
9
5
|
# Allows OEmbed to perform tasks across several, registered, Providers
|
10
6
|
# at once.
|
@@ -13,6 +9,7 @@ module OEmbed
|
|
13
9
|
@@urls = {}
|
14
10
|
@@fallback = []
|
15
11
|
@@to_register = {}
|
12
|
+
@@access_token_setters = {}
|
16
13
|
|
17
14
|
# A Hash of all url schemes, where the keys represent schemes supported by
|
18
15
|
# all registered Provider instances and values are an Array of Providers
|
@@ -48,14 +45,14 @@ module OEmbed
|
|
48
45
|
# Register all Providers built into this gem.
|
49
46
|
# The including_sub_type parameter should be one of the following values:
|
50
47
|
# * :aggregators: also register provider aggregator endpoints, like Embedly
|
51
|
-
# The
|
48
|
+
# The access_tokens keys can be one of the following:
|
52
49
|
# * :facebook: See https://developers.facebook.com/docs/instagram/oembed#access-tokens
|
53
50
|
def register_all(*including_sub_type, access_tokens: {})
|
54
51
|
register(*@@to_register[""])
|
55
|
-
register_access_token_providers(access_tokens)
|
56
52
|
including_sub_type.each do |sub_type|
|
57
53
|
register(*@@to_register[sub_type.to_s])
|
58
54
|
end
|
55
|
+
set_access_tokens(access_tokens)
|
59
56
|
end
|
60
57
|
|
61
58
|
# Unregister all currently-registered Provider instances.
|
@@ -81,10 +78,19 @@ module OEmbed
|
|
81
78
|
@@fallback
|
82
79
|
end
|
83
80
|
|
84
|
-
# Returns a Provider instance
|
81
|
+
# Returns a Provider instance whose url scheme matches the given url.
|
82
|
+
# Skips any Provider with missing required_query_params.
|
85
83
|
def find(url)
|
86
|
-
|
87
|
-
|
84
|
+
@@urls.keys.each do |url_regexp|
|
85
|
+
next unless url_regexp.match?(url)
|
86
|
+
|
87
|
+
matching_provider = @@urls[url_regexp].detect { |p| p.include?(url) }
|
88
|
+
|
89
|
+
# If we've found a matching provider, return it right away!
|
90
|
+
return matching_provider if matching_provider
|
91
|
+
end
|
92
|
+
|
93
|
+
nil
|
88
94
|
end
|
89
95
|
|
90
96
|
# Finds the appropriate Provider for this url and return the raw response.
|
@@ -118,313 +124,46 @@ module OEmbed
|
|
118
124
|
private
|
119
125
|
|
120
126
|
# Takes an OEmbed::Provider instance and registers it so that when we call
|
121
|
-
# the register_all method, they all register.
|
127
|
+
# the register_all method, they all register.
|
128
|
+
# The sub_type can be be any value
|
122
129
|
# used to uniquely group providers. Official sub_types are:
|
123
130
|
# * nil: a normal provider
|
124
131
|
# * :aggregators: an endpoint for an OEmbed aggregator
|
125
|
-
|
132
|
+
# :access_token takes a Hash with the following required keys:
|
133
|
+
# * :name: A Symbol: the name of access token, to be used with `register_all`
|
134
|
+
# * :method: A Symbol: the name of the required_query_params for the access token.
|
135
|
+
def add_official_provider(provider_class, sub_type=nil, access_token: nil)
|
126
136
|
raise TypeError, "Expected OEmbed::Provider instance but was #{provider_class.class}" \
|
127
137
|
unless provider_class.is_a?(OEmbed::Provider)
|
128
138
|
|
129
139
|
@@to_register[sub_type.to_s] ||= []
|
130
140
|
@@to_register[sub_type.to_s] << provider_class
|
141
|
+
|
142
|
+
if access_token.is_a?(Hash) && access_token[:name] && access_token[:method]
|
143
|
+
setter_method = "#{access_token[:method]}="
|
144
|
+
raise TypeError, "Expected OEmbed::Provider instance to respond to the given access_token method #{setter_method}" \
|
145
|
+
unless provider_class.respond_to?(setter_method)
|
146
|
+
|
147
|
+
@@access_token_setters[access_token[:name]] ||= []
|
148
|
+
@@access_token_setters[access_token[:name]] << provider_class.method(setter_method)
|
149
|
+
end
|
131
150
|
end
|
132
151
|
|
133
|
-
# Takes a Hash of tokens, and
|
152
|
+
# Takes a Hash of tokens, and calls the setter method
|
153
|
+
# for all providers that use the given tokens.
|
134
154
|
# Also supports "OEMBED_*_TOKEN" environment variables.
|
135
155
|
# Currently supported tokens:
|
136
156
|
# * facebook: See https://developers.facebook.com/docs/instagram/oembed#access-tokens
|
137
|
-
def
|
138
|
-
|
157
|
+
def set_access_tokens(access_tokens)
|
158
|
+
access_tokens.each do |token_name, token_value|
|
159
|
+
token_name = token_name.to_sym
|
160
|
+
next unless @@access_token_setters.has_key?(token_name)
|
139
161
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
register OEmbed::Providers::Instagram.new(access_token: tokens[:facebook])
|
162
|
+
@@access_token_setters[token_name].each do |token_setter_method|
|
163
|
+
token_setter_method.call(token_value)
|
164
|
+
end
|
144
165
|
end
|
145
166
|
end
|
146
167
|
end
|
147
|
-
|
148
|
-
# Custom providers:
|
149
|
-
|
150
|
-
# Provider for youtube.com
|
151
|
-
# http://apiblog.youtube.com/2009/10/oembed-support.html
|
152
|
-
#
|
153
|
-
# Options:
|
154
|
-
# * To get the iframe embed code
|
155
|
-
# OEmbed::Providers::Youtube.endpoint += "?iframe=1"
|
156
|
-
# * To get the flash/object embed code
|
157
|
-
# OEmbed::Providers::Youtube.endpoint += "?iframe=0"
|
158
|
-
# * To require https embed code
|
159
|
-
# OEmbed::Providers::Youtube.endpoint += "?scheme=https"
|
160
|
-
Youtube = OEmbed::Provider.new("https://www.youtube.com/oembed?scheme=https")
|
161
|
-
Youtube << "http://*.youtube.com/*"
|
162
|
-
Youtube << "https://*.youtube.com/*"
|
163
|
-
Youtube << "http://*.youtu.be/*"
|
164
|
-
Youtube << "https://*.youtu.be/*"
|
165
|
-
add_official_provider(Youtube)
|
166
|
-
|
167
|
-
# Provider for codepen.io
|
168
|
-
CodePen = OEmbed::Provider.new("https://codepen.io/api/oembed")
|
169
|
-
CodePen << "http://codepen.io/*"
|
170
|
-
CodePen << "https://codepen.io/*"
|
171
|
-
add_official_provider(CodePen)
|
172
|
-
|
173
|
-
# Provider for flickr.com
|
174
|
-
Flickr = OEmbed::Provider.new("https://www.flickr.com/services/oembed/")
|
175
|
-
Flickr << "http://*.flickr.com/*"
|
176
|
-
Flickr << "https://*.flickr.com/*"
|
177
|
-
Flickr << "http://flic.kr/*"
|
178
|
-
Flickr << "https://flic.kr/*"
|
179
|
-
add_official_provider(Flickr)
|
180
|
-
|
181
|
-
# Provider for viddler.com
|
182
|
-
# http://developers.viddler.com/documentation/services/oembed/
|
183
|
-
Viddler = OEmbed::Provider.new("http://lab.viddler.com/services/oembed/")
|
184
|
-
Viddler << "http://*.viddler.com/*"
|
185
|
-
add_official_provider(Viddler)
|
186
|
-
|
187
|
-
# Provider for qik.com
|
188
|
-
# http://qik.com/blog/qik-embraces-oembed-for-embedding-videos/
|
189
|
-
Qik = OEmbed::Provider.new("http://qik.com/api/oembed.{format}")
|
190
|
-
Qik << "http://qik.com/*"
|
191
|
-
Qik << "http://qik.com/video/*"
|
192
|
-
add_official_provider(Qik)
|
193
|
-
|
194
|
-
# Provider for revision3.com
|
195
|
-
Revision3 = OEmbed::Provider.new("http://revision3.com/api/oembed/")
|
196
|
-
Revision3 << "http://*.revision3.com/*"
|
197
|
-
add_official_provider(Revision3)
|
198
|
-
|
199
|
-
# Provider for hulu.com
|
200
|
-
Hulu = OEmbed::Provider.new("https://www.hulu.com/api/oembed.{format}")
|
201
|
-
Hulu << "http://www.hulu.com/watch/*"
|
202
|
-
Hulu << "https://www.hulu.com/watch/*"
|
203
|
-
add_official_provider(Hulu)
|
204
|
-
|
205
|
-
# Provider for vimeo.com
|
206
|
-
# https://developer.vimeo.com/apis/oembed
|
207
|
-
Vimeo = OEmbed::Provider.new("https://vimeo.com/api/oembed.{format}")
|
208
|
-
Vimeo << "http://*.vimeo.com/*"
|
209
|
-
Vimeo << "https://*.vimeo.com/*"
|
210
|
-
add_official_provider(Vimeo)
|
211
|
-
|
212
|
-
# Provider for twitter.com
|
213
|
-
# https://dev.twitter.com/rest/reference/get/statuses/oembed
|
214
|
-
Twitter = OEmbed::Provider.new("https://publish.twitter.com/oembed", :json)
|
215
|
-
Twitter << "https://*.twitter.com/*/status/*"
|
216
|
-
add_official_provider(Twitter)
|
217
|
-
|
218
|
-
# Provider for vine.co
|
219
|
-
# https://dev.twitter.com/web/vine/oembed
|
220
|
-
Vine = OEmbed::Provider.new("https://vine.co/oembed.{format}")
|
221
|
-
Vine << "http://*.vine.co/v/*"
|
222
|
-
Vine << "https://*.vine.co/v/*"
|
223
|
-
add_official_provider(Vine)
|
224
|
-
|
225
|
-
# Provider for slideshare.net
|
226
|
-
# http://www.slideshare.net/developers/oembed
|
227
|
-
Slideshare = OEmbed::Provider.new("https://www.slideshare.net/api/oembed/2")
|
228
|
-
Slideshare << 'http://*.slideshare.net/*/*'
|
229
|
-
Slideshare << 'https://*.slideshare.net/*/*'
|
230
|
-
Slideshare << 'http://*.slideshare.net/mobile/*/*'
|
231
|
-
Slideshare << 'https://*.slideshare.net/mobile/*/*'
|
232
|
-
add_official_provider(Slideshare)
|
233
|
-
|
234
|
-
# Provider for yfrog
|
235
|
-
# http://code.google.com/p/imageshackapi/wiki/OEMBEDSupport
|
236
|
-
Yfrog = OEmbed::Provider.new("https://www.yfrog.com/api/oembed", :json)
|
237
|
-
Yfrog << "http://yfrog.com/*"
|
238
|
-
add_official_provider(Yfrog)
|
239
|
-
|
240
|
-
# Provider for Giphy
|
241
|
-
Giphy = OEmbed::Provider.new("http://giphy.com/services/oembed")
|
242
|
-
Giphy << "http://giphy.com/*"
|
243
|
-
Giphy << "https://giphy.com/*"
|
244
|
-
add_official_provider(Giphy)
|
245
|
-
|
246
|
-
# Provider for imgur.com
|
247
|
-
Imgur = OEmbed::Provider.new("https://api.imgur.com/oembed.{format}")
|
248
|
-
Imgur << "https://*.imgur.com/gallery/*"
|
249
|
-
Imgur << "http://*.imgur.com/gallery/*"
|
250
|
-
add_official_provider(Imgur)
|
251
|
-
|
252
|
-
# Provider for Kickstarter
|
253
|
-
Kickstarter = OEmbed::Provider.new("https://www.kickstarter.com/services/oembed")
|
254
|
-
Kickstarter << "http://www.kickstarter.com/projects/*"
|
255
|
-
Kickstarter << "https://www.kickstarter.com/projects/*"
|
256
|
-
add_official_provider(Kickstarter)
|
257
|
-
|
258
|
-
# provider for mlg-tv
|
259
|
-
# http://tv.majorleaguegaming.com/oembed
|
260
|
-
MlgTv = OEmbed::Provider.new("http://tv.majorleaguegaming.com/oembed")
|
261
|
-
MlgTv << "http://tv.majorleaguegaming.com/video/*"
|
262
|
-
MlgTv << "http://mlg.tv/video/*"
|
263
|
-
add_official_provider(MlgTv)
|
264
|
-
|
265
|
-
# pownce.com closed in 2008
|
266
|
-
#Pownce = OEmbed::Provider.new("http://api.pownce.com/2.1/oembed.{format}")
|
267
|
-
#Pownce << "http://*.pownce.com/*"
|
268
|
-
#add_official_provider(Pownce)
|
269
|
-
|
270
|
-
# Provider for polleverywhere.com
|
271
|
-
PollEverywhere = OEmbed::Provider.new("http://www.polleverywhere.com/services/oembed/")
|
272
|
-
PollEverywhere << "http://www.polleverywhere.com/polls/*"
|
273
|
-
PollEverywhere << "http://www.polleverywhere.com/multiple_choice_polls/*"
|
274
|
-
PollEverywhere << "http://www.polleverywhere.com/free_text_polls/*"
|
275
|
-
add_official_provider(PollEverywhere)
|
276
|
-
|
277
|
-
# Provider for my.opera.com
|
278
|
-
# http://my.opera.com/devblog/blog/2008/12/02/embedding-my-opera-content-oembed
|
279
|
-
MyOpera = OEmbed::Provider.new("http://my.opera.com/service/oembed", :json)
|
280
|
-
MyOpera << "http://my.opera.com/*"
|
281
|
-
add_official_provider(MyOpera)
|
282
|
-
|
283
|
-
# Provider for clearspring.com
|
284
|
-
ClearspringWidgets = OEmbed::Provider.new("http://widgets.clearspring.com/widget/v1/oembed/")
|
285
|
-
ClearspringWidgets << "http://www.clearspring.com/widgets/*"
|
286
|
-
add_official_provider(ClearspringWidgets)
|
287
|
-
|
288
|
-
# Provider for nfb.ca
|
289
|
-
NFBCanada = OEmbed::Provider.new("http://www.nfb.ca/remote/services/oembed/")
|
290
|
-
NFBCanada << "http://*.nfb.ca/film/*"
|
291
|
-
add_official_provider(NFBCanada)
|
292
|
-
|
293
|
-
# Provider for scribd.com
|
294
|
-
Scribd = OEmbed::Provider.new("https://www.scribd.com/services/oembed")
|
295
|
-
Scribd << "http://*.scribd.com/*"
|
296
|
-
add_official_provider(Scribd)
|
297
|
-
|
298
|
-
# Provider for speakerdeck.com
|
299
|
-
# https://speakerdeck.com/faq#oembed
|
300
|
-
SpeakerDeck = OEmbed::Provider.new("https://speakerdeck.com/oembed.json")
|
301
|
-
SpeakerDeck << "http://speakerdeck.com/*/*"
|
302
|
-
SpeakerDeck << "https://speakerdeck.com/*/*"
|
303
|
-
add_official_provider(SpeakerDeck)
|
304
|
-
|
305
|
-
# Provider for movieclips.com
|
306
|
-
MovieClips = OEmbed::Provider.new("http://movieclips.com/services/oembed/")
|
307
|
-
MovieClips << "http://movieclips.com/watch/*/*/"
|
308
|
-
add_official_provider(MovieClips)
|
309
|
-
|
310
|
-
# Provider for 23hq.com
|
311
|
-
TwentyThree = OEmbed::Provider.new("http://www.23hq.com/23/oembed")
|
312
|
-
TwentyThree << "http://www.23hq.com/*"
|
313
|
-
add_official_provider(TwentyThree)
|
314
|
-
|
315
|
-
# Provider for soundcloud.com
|
316
|
-
# http://developers.soundcloud.com/docs/oembed
|
317
|
-
SoundCloud = OEmbed::Provider.new("https://soundcloud.com/oembed", :json)
|
318
|
-
SoundCloud << "http://*.soundcloud.com/*"
|
319
|
-
SoundCloud << "https://*.soundcloud.com/*"
|
320
|
-
add_official_provider(SoundCloud)
|
321
|
-
|
322
|
-
# Provider for spotify.com
|
323
|
-
# https://twitter.com/nicklas2k/status/330094611202723840
|
324
|
-
# http://blog.embed.ly/post/45149936446/oembed-for-spotify
|
325
|
-
Spotify = OEmbed::Provider.new("https://embed.spotify.com/oembed/")
|
326
|
-
Spotify << "http://open.spotify.com/*"
|
327
|
-
Spotify << "https://open.spotify.com/*"
|
328
|
-
Spotify << "http://play.spotify.com/*"
|
329
|
-
Spotify << "https://play.spotify.com/*"
|
330
|
-
Spotify << /^spotify\:(.*?)/
|
331
|
-
add_official_provider(Spotify)
|
332
|
-
|
333
|
-
# Provider for skitch.com
|
334
|
-
# http://skitch.com/oembed/%3C/endpoint
|
335
|
-
Skitch = OEmbed::Provider.new("http://skitch.com/oembed")
|
336
|
-
Skitch << "http://*.skitch.com/*"
|
337
|
-
Skitch << "https://*.skitch.com/*"
|
338
|
-
add_official_provider(Skitch)
|
339
|
-
|
340
|
-
# Provider for TED
|
341
|
-
Ted = OEmbed::Provider.new("https://www.ted.com/talks/oembed.{format}")
|
342
|
-
Ted << "http://*.ted.com/talks/*"
|
343
|
-
Ted << "https://*.ted.com/talks/*"
|
344
|
-
add_official_provider(Ted)
|
345
|
-
|
346
|
-
# Provider for tumblr.com
|
347
|
-
Tumblr = OEmbed::Provider.new("http://www.tumblr.com/oembed/1.0/", :json)
|
348
|
-
Tumblr << "http://*.tumblr.com/post/*"
|
349
|
-
Tumblr << "https://*.tumblr.com/post/*"
|
350
|
-
add_official_provider(Tumblr)
|
351
|
-
|
352
|
-
## Provider for clikthrough.com
|
353
|
-
# http://corporate.clikthrough.com/wp/?p=275
|
354
|
-
#Clickthrough = OEmbed::Provider.new("http://www.clikthrough.com/services/oembed/")
|
355
|
-
#Clickthrough << "http://*.clikthrough.com/theater/video/*"
|
356
|
-
#add_official_provider(Clickthrough)
|
357
|
-
|
358
|
-
## Provider for kinomap.com
|
359
|
-
# http://www.kinomap.com/#!oEmbed
|
360
|
-
#Kinomap = OEmbed::Provider.new("http://www.kinomap.com/oembed")
|
361
|
-
#Kinomap << "http://www.kinomap.com/*"
|
362
|
-
#add_official_provider(Kinomap)
|
363
|
-
|
364
|
-
# Provider for oohembed.com, which is a provider aggregator. See
|
365
|
-
# OEmbed::Providers::OohEmbed.urls for a full list of supported url schemas.
|
366
|
-
# Embed.ly has taken over the oohembed.com domain and as of July 20 all oohEmbed
|
367
|
-
# request will require you use an API key. For details on the transition see
|
368
|
-
# http://blog.embed.ly/oohembed
|
369
|
-
OohEmbed = OEmbed::Provider.new("http://oohembed.com/oohembed/", :json)
|
370
|
-
OohEmbed << "http://*.5min.com/Video/*" # micro-video host
|
371
|
-
OohEmbed << %r{http://(.*?).amazon.(com|co.uk|de|ca|jp)/(.*?)/(gp/product|o/ASIN|obidos/ASIN|dp)/(.*?)} # Online product shopping
|
372
|
-
OohEmbed << "http://*.blip.tv/*"
|
373
|
-
OohEmbed << "http://*.clikthrough.com/theater/video/*"
|
374
|
-
OohEmbed << "http://*.collegehumor.com/video:*" # Comedic & original videos
|
375
|
-
OohEmbed << "http://*.thedailyshow.com/video/*" # Syndicated show
|
376
|
-
OohEmbed << "http://*.dailymotion.com/*"
|
377
|
-
OohEmbed << "http://dotsub.com/view/*"
|
378
|
-
OohEmbed << "http://*.flickr.com/photos/*"
|
379
|
-
OohEmbed << "http://*.funnyordie.com/videos/*" # Comedy video host
|
380
|
-
OohEmbed << "http://video.google.com/videoplay?*" # Video hosting
|
381
|
-
OohEmbed << "http://www.hulu.com/watch/*"
|
382
|
-
OohEmbed << "http://*.kinomap.com/*"
|
383
|
-
OohEmbed << "http://*.livejournal.com/"
|
384
|
-
OohEmbed << "http://*.metacafe.com/watch/*" # Video host
|
385
|
-
OohEmbed << "http://*.nfb.ca/film/*"
|
386
|
-
OohEmbed << "http://*.photobucket.com/albums/*"
|
387
|
-
OohEmbed << "http://*.photobucket.com/groups/*"
|
388
|
-
OohEmbed << "http://*.phodroid.com/*/*/*" # Photo host
|
389
|
-
OohEmbed << "http://qik.com/*"
|
390
|
-
OohEmbed << "http://*.revision3.com/*"
|
391
|
-
OohEmbed << "http://*.scribd.com/*"
|
392
|
-
OohEmbed << "http://*.slideshare.net/*" # Share presentations online
|
393
|
-
OohEmbed << "http://*.twitpic.com/*" # Picture hosting for Twitter
|
394
|
-
OohEmbed << "http://twitter.com/*/statuses/*" # Mirco-blogging network
|
395
|
-
OohEmbed << "http://*.viddler.com/explore/*"
|
396
|
-
OohEmbed << "http://www.vimeo.com/*"
|
397
|
-
OohEmbed << "http://www.vimeo.com/groups/*/videos/*"
|
398
|
-
OohEmbed << "http://*.wikipedia.org/wiki/*" # Online encyclopedia
|
399
|
-
OohEmbed << "http://*.wordpress.com/*/*/*/*" # Blogging Engine & community
|
400
|
-
OohEmbed << "http://*.xkcd.com/*" # A hilarious stick figure comic
|
401
|
-
OohEmbed << %r{http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/(.*?)} # image & video hosting
|
402
|
-
OohEmbed << "http://*.youtube.com/watch*"
|
403
|
-
|
404
|
-
# Provider for noembed.com, which is a provider aggregator. See
|
405
|
-
# OEmbed::Providers::Noembed.urls for a full list of supported url schemas.
|
406
|
-
# https://noembed.com/#supported-sites
|
407
|
-
Noembed = OEmbed::Provider.new("https://noembed.com/embed")
|
408
|
-
# Add all known URL regexps for Noembed.
|
409
|
-
# To update this list run `rake oembed:update_noembed`
|
410
|
-
YAML.load_file(File.join(File.dirname(__FILE__), "/providers/aggregators/noembed_urls.yml")).each do |url|
|
411
|
-
Noembed << Regexp.new(url)
|
412
|
-
end
|
413
|
-
add_official_provider(Noembed, :aggregators)
|
414
|
-
|
415
|
-
# Provider for Embedly.com, which is a provider aggregator. See
|
416
|
-
# OEmbed::Providers::Embedly.urls for a full list of supported url schemas.
|
417
|
-
# http://embed.ly/docs/endpoints/1/oembed
|
418
|
-
#
|
419
|
-
# You can append your Embed.ly API key to the provider so that all requests are signed
|
420
|
-
# OEmbed::Providers::Embedly.endpoint += "?key=#{my_embedly_key}"
|
421
|
-
#
|
422
|
-
# If you don't yet have an API key you'll need to sign up here: http://embed.ly/pricing
|
423
|
-
Embedly = OEmbed::Provider.new("http://api.embed.ly/1/oembed")
|
424
|
-
# Add all known URL regexps for Embedly. To update this list run `rake oembed:update_embedly`
|
425
|
-
YAML.load_file(File.join(File.dirname(__FILE__), "/providers/aggregators/embedly_urls.yml")).each do |url|
|
426
|
-
Embedly << url
|
427
|
-
end
|
428
|
-
add_official_provider(Embedly, :aggregators)
|
429
168
|
end
|
430
169
|
end
|
data/lib/oembed/version.rb
CHANGED
data/lib/oembed.rb
CHANGED
@@ -8,6 +8,7 @@ require 'oembed/formatter'
|
|
8
8
|
require 'oembed/provider'
|
9
9
|
require 'oembed/provider_discovery'
|
10
10
|
require 'oembed/providers'
|
11
|
+
require 'oembed/providers/builtin_providers'
|
11
12
|
require 'oembed/response'
|
12
13
|
require 'oembed/response/photo'
|
13
14
|
require 'oembed/response/video'
|
data/ruby-oembed.gemspec
CHANGED
@@ -17,8 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.homepage = "https://github.com/ruby-oembed/ruby-oembed"
|
18
18
|
s.licenses = ["MIT"]
|
19
19
|
|
20
|
-
s.files = `git ls-files`.split("\n")
|
21
|
-
s.test_files = s.files.grep(%r{^(test|spec|features,integration_test)/})
|
20
|
+
s.files = `git ls-files`.split("\n").reject { |f| f.start_with?('spec/') || f.start_with?('integration_test/') }
|
22
21
|
|
23
22
|
s.rdoc_options = ["--main", "README.rdoc", "--title", "ruby-oembed-#{OEmbed::Version}", "--inline-source", "--exclude", "tasks", "CHANGELOG.rdoc"]
|
24
23
|
s.extra_rdoc_files = s.files.grep(%r{\.rdoc$}) + %w{LICENSE}
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-oembed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus Holm
|
8
8
|
- Alex Kessinger
|
9
9
|
- Aris Bartee
|
10
10
|
- Marcos Wright Kuhns
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-01-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: xml-simple
|
@@ -61,8 +61,6 @@ files:
|
|
61
61
|
- LICENSE
|
62
62
|
- README.md
|
63
63
|
- Rakefile
|
64
|
-
- integration_test/test.rb
|
65
|
-
- integration_test/test_urls.csv
|
66
64
|
- lib/oembed.rb
|
67
65
|
- lib/oembed/errors.rb
|
68
66
|
- lib/oembed/formatter.rb
|
@@ -82,9 +80,11 @@ files:
|
|
82
80
|
- lib/oembed/providers/aggregators/embedly_urls.yml
|
83
81
|
- lib/oembed/providers/aggregators/noembed_urls.yml
|
84
82
|
- lib/oembed/providers/aggregators/oohembed_urls.yml
|
83
|
+
- lib/oembed/providers/builtin_providers.rb
|
85
84
|
- lib/oembed/providers/facebook_post.rb
|
86
85
|
- lib/oembed/providers/facebook_video.rb
|
87
86
|
- lib/oembed/providers/instagram.rb
|
87
|
+
- lib/oembed/providers/tiktok.rb
|
88
88
|
- lib/oembed/response.rb
|
89
89
|
- lib/oembed/response/link.rb
|
90
90
|
- lib/oembed/response/photo.rb
|
@@ -94,38 +94,16 @@ files:
|
|
94
94
|
- lib/tasks/oembed.rake
|
95
95
|
- lib/tasks/rspec.rake
|
96
96
|
- ruby-oembed.gemspec
|
97
|
-
- spec/cassettes/OEmbed_Provider.yml
|
98
|
-
- spec/cassettes/OEmbed_ProviderDiscovery.yml
|
99
|
-
- spec/cassettes/OEmbed_Providers_Slideshare.yml
|
100
|
-
- spec/cassettes/OEmbed_Providers_Twitter.yml
|
101
|
-
- spec/formatter/ducktype_backend_spec.rb
|
102
|
-
- spec/formatter/json/.DS_Store
|
103
|
-
- spec/formatter/json/jsongem_backend_spec.rb
|
104
|
-
- spec/formatter/json/yaml_backend_spec.rb
|
105
|
-
- spec/formatter/xml/nokogiri_backend_spec.rb
|
106
|
-
- spec/formatter/xml/rexml_backend_spec.rb
|
107
|
-
- spec/formatter/xml/xmlsimple_backend_spec.rb
|
108
|
-
- spec/formatter_spec.rb
|
109
|
-
- spec/provider_discovery_spec.rb
|
110
|
-
- spec/provider_spec.rb
|
111
|
-
- spec/providers/facebook_spec.rb
|
112
|
-
- spec/providers/slideshare_spec.rb
|
113
|
-
- spec/providers/twitter_spec.rb
|
114
|
-
- spec/providers_spec.rb
|
115
|
-
- spec/response_spec.rb
|
116
|
-
- spec/spec_helper.rb
|
117
|
-
- spec/spec_helper_examples.yml
|
118
|
-
- spec/support/shared_examples_for_providers.rb
|
119
97
|
homepage: https://github.com/ruby-oembed/ruby-oembed
|
120
98
|
licenses:
|
121
99
|
- MIT
|
122
100
|
metadata: {}
|
123
|
-
post_install_message:
|
101
|
+
post_install_message:
|
124
102
|
rdoc_options:
|
125
103
|
- "--main"
|
126
104
|
- README.rdoc
|
127
105
|
- "--title"
|
128
|
-
- ruby-oembed-0.
|
106
|
+
- ruby-oembed-0.16.1
|
129
107
|
- "--inline-source"
|
130
108
|
- "--exclude"
|
131
109
|
- tasks
|
@@ -144,29 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
122
|
version: '0'
|
145
123
|
requirements: []
|
146
124
|
rubygems_version: 3.1.4
|
147
|
-
signing_key:
|
125
|
+
signing_key:
|
148
126
|
specification_version: 4
|
149
127
|
summary: oEmbed for Ruby
|
150
|
-
test_files:
|
151
|
-
- spec/cassettes/OEmbed_Provider.yml
|
152
|
-
- spec/cassettes/OEmbed_ProviderDiscovery.yml
|
153
|
-
- spec/cassettes/OEmbed_Providers_Slideshare.yml
|
154
|
-
- spec/cassettes/OEmbed_Providers_Twitter.yml
|
155
|
-
- spec/formatter/ducktype_backend_spec.rb
|
156
|
-
- spec/formatter/json/.DS_Store
|
157
|
-
- spec/formatter/json/jsongem_backend_spec.rb
|
158
|
-
- spec/formatter/json/yaml_backend_spec.rb
|
159
|
-
- spec/formatter/xml/nokogiri_backend_spec.rb
|
160
|
-
- spec/formatter/xml/rexml_backend_spec.rb
|
161
|
-
- spec/formatter/xml/xmlsimple_backend_spec.rb
|
162
|
-
- spec/formatter_spec.rb
|
163
|
-
- spec/provider_discovery_spec.rb
|
164
|
-
- spec/provider_spec.rb
|
165
|
-
- spec/providers/facebook_spec.rb
|
166
|
-
- spec/providers/slideshare_spec.rb
|
167
|
-
- spec/providers/twitter_spec.rb
|
168
|
-
- spec/providers_spec.rb
|
169
|
-
- spec/response_spec.rb
|
170
|
-
- spec/spec_helper.rb
|
171
|
-
- spec/spec_helper_examples.yml
|
172
|
-
- spec/support/shared_examples_for_providers.rb
|
128
|
+
test_files: []
|
data/integration_test/test.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require File.dirname(__FILE__) + '/../lib/oembed'
|
3
|
-
OEmbed::Providers.register_all()
|
4
|
-
OEmbed::Providers.register_fallback(OEmbed::ProviderDiscovery, OEmbed::Providers::Embedly, OEmbed::Providers::OohEmbed)
|
5
|
-
|
6
|
-
|
7
|
-
passed = "passed"
|
8
|
-
passed = "failed"
|
9
|
-
File.open("test_urls.csv", "r") do |infile|
|
10
|
-
while (line = infile.gets)
|
11
|
-
begin
|
12
|
-
res = OEmbed::Providers.raw(line, :format => :json)
|
13
|
-
passed = "passed"
|
14
|
-
rescue OEmbed::NotFound => e
|
15
|
-
if e.message == "OEmbed::NotFound"
|
16
|
-
puts "not a supported url: " + line
|
17
|
-
else
|
18
|
-
puts e.message
|
19
|
-
end
|
20
|
-
passed = "failed"
|
21
|
-
rescue OEmbed::UnknownResponse => e
|
22
|
-
puts "got a bad network response" + e.message
|
23
|
-
passed = "failed"
|
24
|
-
rescue Timeout::Error
|
25
|
-
puts "timeout error"
|
26
|
-
passed = "failed"
|
27
|
-
end
|
28
|
-
|
29
|
-
puts passed + ": " + line
|
30
|
-
end
|
31
|
-
end
|