ruby-oembed 0.14.1 → 0.15.0
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/.travis.yml +3 -0
- data/CHANGELOG.rdoc +13 -1
- data/lib/oembed.rb +1 -0
- data/lib/oembed/provider.rb +54 -5
- data/lib/oembed/providers.rb +39 -300
- data/lib/oembed/providers/aggregators/embedly_urls.yml +167 -6
- 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/tik_tok.rb +11 -0
- data/lib/oembed/version.rb +2 -2
- data/spec/cassettes/OEmbed_Provider.yml +117 -16
- data/spec/cassettes/OEmbed_Providers_CodePen.yml +177 -0
- data/spec/cassettes/OEmbed_Providers_FacebookPost.yml +539 -0
- data/spec/cassettes/OEmbed_Providers_FacebookVideo.yml +267 -0
- data/spec/cassettes/OEmbed_Providers_Instagram.yml +1473 -0
- data/spec/cassettes/OEmbed_Providers_Slideshare.yml +420 -834
- data/spec/cassettes/OEmbed_Providers_TikTok.yml +293 -0
- data/spec/cassettes/OEmbed_Providers_Twitter.yml +84 -357
- data/spec/cassettes/OEmbed_Providers_Youtube.yml +188 -26
- data/spec/provider_spec.rb +315 -138
- data/spec/providers/code_pen_spec.rb +21 -0
- data/spec/providers/facebook_post_spec.rb +54 -0
- data/spec/providers/facebook_video_spec.rb +48 -0
- data/spec/providers/instagram_spec.rb +48 -0
- data/spec/providers/slideshare_spec.rb +2 -9
- data/spec/providers/tik_tok_spec.rb +26 -0
- data/spec/providers/twitter_spec.rb +3 -10
- data/spec/providers/youtube_spec.rb +3 -9
- data/spec/providers_spec.rb +151 -16
- data/spec/response_spec.rb +2 -2
- data/spec/spec_helper.rb +19 -1
- data/spec/support/shared_examples_for_providers.rb +32 -20
- metadata +25 -5
- data/spec/providers/facebook_spec.rb +0 -50
@@ -0,0 +1,292 @@
|
|
1
|
+
# This file is used to load all built-in providers.
|
2
|
+
# In the short term most of them are specified in this file
|
3
|
+
# though we've _started_ moving provider definitions into their own files!
|
4
|
+
|
5
|
+
require 'oembed/providers/facebook_post'
|
6
|
+
require 'oembed/providers/facebook_video'
|
7
|
+
require 'oembed/providers/instagram'
|
8
|
+
require 'oembed/providers/tik_tok'
|
9
|
+
|
10
|
+
module OEmbed
|
11
|
+
class Providers
|
12
|
+
# Provider for youtube.com
|
13
|
+
# http://apiblog.youtube.com/2009/10/oembed-support.html
|
14
|
+
#
|
15
|
+
# Options:
|
16
|
+
# * To get the iframe embed code
|
17
|
+
# OEmbed::Providers::Youtube.endpoint += "?iframe=1"
|
18
|
+
# * To get the flash/object embed code
|
19
|
+
# OEmbed::Providers::Youtube.endpoint += "?iframe=0"
|
20
|
+
# * To require https embed code
|
21
|
+
# OEmbed::Providers::Youtube.endpoint += "?scheme=https"
|
22
|
+
Youtube = OEmbed::Provider.new("https://www.youtube.com/oembed/?scheme=https")
|
23
|
+
Youtube << "http://*.youtube.com/*"
|
24
|
+
Youtube << "https://*.youtube.com/*"
|
25
|
+
Youtube << "http://*.youtu.be/*"
|
26
|
+
Youtube << "https://*.youtu.be/*"
|
27
|
+
add_official_provider(Youtube)
|
28
|
+
|
29
|
+
# Provider for codepen.io
|
30
|
+
CodePen = OEmbed::Provider.new("https://codepen.io/api/oembed")
|
31
|
+
CodePen << "http://codepen.io/*"
|
32
|
+
CodePen << "https://codepen.io/*"
|
33
|
+
add_official_provider(CodePen)
|
34
|
+
|
35
|
+
# Provider for flickr.com
|
36
|
+
Flickr = OEmbed::Provider.new("https://www.flickr.com/services/oembed/")
|
37
|
+
Flickr << "http://*.flickr.com/*"
|
38
|
+
Flickr << "https://*.flickr.com/*"
|
39
|
+
Flickr << "http://flic.kr/*"
|
40
|
+
Flickr << "https://flic.kr/*"
|
41
|
+
add_official_provider(Flickr)
|
42
|
+
|
43
|
+
# Provider for viddler.com
|
44
|
+
# http://developers.viddler.com/documentation/services/oembed/
|
45
|
+
Viddler = OEmbed::Provider.new("http://lab.viddler.com/services/oembed/")
|
46
|
+
Viddler << "http://*.viddler.com/*"
|
47
|
+
add_official_provider(Viddler)
|
48
|
+
|
49
|
+
# Provider for qik.com
|
50
|
+
# http://qik.com/blog/qik-embraces-oembed-for-embedding-videos/
|
51
|
+
Qik = OEmbed::Provider.new("http://qik.com/api/oembed.{format}")
|
52
|
+
Qik << "http://qik.com/*"
|
53
|
+
Qik << "http://qik.com/video/*"
|
54
|
+
add_official_provider(Qik)
|
55
|
+
|
56
|
+
# Provider for revision3.com
|
57
|
+
Revision3 = OEmbed::Provider.new("http://revision3.com/api/oembed/")
|
58
|
+
Revision3 << "http://*.revision3.com/*"
|
59
|
+
add_official_provider(Revision3)
|
60
|
+
|
61
|
+
# Provider for hulu.com
|
62
|
+
Hulu = OEmbed::Provider.new("https://www.hulu.com/api/oembed.{format}")
|
63
|
+
Hulu << "http://www.hulu.com/watch/*"
|
64
|
+
Hulu << "https://www.hulu.com/watch/*"
|
65
|
+
add_official_provider(Hulu)
|
66
|
+
|
67
|
+
# Provider for vimeo.com
|
68
|
+
# https://developer.vimeo.com/apis/oembed
|
69
|
+
Vimeo = OEmbed::Provider.new("https://vimeo.com/api/oembed.{format}")
|
70
|
+
Vimeo << "http://*.vimeo.com/*"
|
71
|
+
Vimeo << "https://*.vimeo.com/*"
|
72
|
+
add_official_provider(Vimeo)
|
73
|
+
|
74
|
+
# Provider for twitter.com
|
75
|
+
# https://dev.twitter.com/rest/reference/get/statuses/oembed
|
76
|
+
Twitter = OEmbed::Provider.new("https://publish.twitter.com/oembed", format: :json)
|
77
|
+
Twitter << "https://*.twitter.com/*/status/*"
|
78
|
+
add_official_provider(Twitter)
|
79
|
+
|
80
|
+
# Provider for vine.co
|
81
|
+
# https://dev.twitter.com/web/vine/oembed
|
82
|
+
Vine = OEmbed::Provider.new("https://vine.co/oembed.{format}")
|
83
|
+
Vine << "http://*.vine.co/v/*"
|
84
|
+
Vine << "https://*.vine.co/v/*"
|
85
|
+
add_official_provider(Vine)
|
86
|
+
|
87
|
+
# Provider for slideshare.net
|
88
|
+
# http://www.slideshare.net/developers/oembed
|
89
|
+
Slideshare = OEmbed::Provider.new("https://www.slideshare.net/api/oembed/2")
|
90
|
+
Slideshare << 'http://*.slideshare.net/*/*'
|
91
|
+
Slideshare << 'https://*.slideshare.net/*/*'
|
92
|
+
Slideshare << 'http://*.slideshare.net/mobile/*/*'
|
93
|
+
Slideshare << 'https://*.slideshare.net/mobile/*/*'
|
94
|
+
add_official_provider(Slideshare)
|
95
|
+
|
96
|
+
# Provider for yfrog
|
97
|
+
# http://code.google.com/p/imageshackapi/wiki/OEMBEDSupport
|
98
|
+
Yfrog = OEmbed::Provider.new("https://www.yfrog.com/api/oembed", format: :json)
|
99
|
+
Yfrog << "http://yfrog.com/*"
|
100
|
+
add_official_provider(Yfrog)
|
101
|
+
|
102
|
+
# Provider for Giphy
|
103
|
+
Giphy = OEmbed::Provider.new("http://giphy.com/services/oembed")
|
104
|
+
Giphy << "http://giphy.com/*"
|
105
|
+
Giphy << "https://giphy.com/*"
|
106
|
+
add_official_provider(Giphy)
|
107
|
+
|
108
|
+
# Provider for imgur.com
|
109
|
+
Imgur = OEmbed::Provider.new("https://api.imgur.com/oembed.{format}")
|
110
|
+
Imgur << "https://*.imgur.com/gallery/*"
|
111
|
+
Imgur << "http://*.imgur.com/gallery/*"
|
112
|
+
add_official_provider(Imgur)
|
113
|
+
|
114
|
+
# Provider for Kickstarter
|
115
|
+
Kickstarter = OEmbed::Provider.new("https://www.kickstarter.com/services/oembed")
|
116
|
+
Kickstarter << "http://www.kickstarter.com/projects/*"
|
117
|
+
Kickstarter << "https://www.kickstarter.com/projects/*"
|
118
|
+
add_official_provider(Kickstarter)
|
119
|
+
|
120
|
+
# provider for mlg-tv
|
121
|
+
# http://tv.majorleaguegaming.com/oembed
|
122
|
+
MlgTv = OEmbed::Provider.new("http://tv.majorleaguegaming.com/oembed")
|
123
|
+
MlgTv << "http://tv.majorleaguegaming.com/video/*"
|
124
|
+
MlgTv << "http://mlg.tv/video/*"
|
125
|
+
add_official_provider(MlgTv)
|
126
|
+
|
127
|
+
# pownce.com closed in 2008
|
128
|
+
#Pownce = OEmbed::Provider.new("http://api.pownce.com/2.1/oembed.{format}")
|
129
|
+
#Pownce << "http://*.pownce.com/*"
|
130
|
+
#add_official_provider(Pownce)
|
131
|
+
|
132
|
+
# Provider for polleverywhere.com
|
133
|
+
PollEverywhere = OEmbed::Provider.new("http://www.polleverywhere.com/services/oembed/")
|
134
|
+
PollEverywhere << "http://www.polleverywhere.com/polls/*"
|
135
|
+
PollEverywhere << "http://www.polleverywhere.com/multiple_choice_polls/*"
|
136
|
+
PollEverywhere << "http://www.polleverywhere.com/free_text_polls/*"
|
137
|
+
add_official_provider(PollEverywhere)
|
138
|
+
|
139
|
+
# Provider for my.opera.com
|
140
|
+
# http://my.opera.com/devblog/blog/2008/12/02/embedding-my-opera-content-oembed
|
141
|
+
MyOpera = OEmbed::Provider.new("http://my.opera.com/service/oembed", format: :json)
|
142
|
+
MyOpera << "http://my.opera.com/*"
|
143
|
+
add_official_provider(MyOpera)
|
144
|
+
|
145
|
+
# Provider for clearspring.com
|
146
|
+
ClearspringWidgets = OEmbed::Provider.new("http://widgets.clearspring.com/widget/v1/oembed/")
|
147
|
+
ClearspringWidgets << "http://www.clearspring.com/widgets/*"
|
148
|
+
add_official_provider(ClearspringWidgets)
|
149
|
+
|
150
|
+
# Provider for nfb.ca
|
151
|
+
NFBCanada = OEmbed::Provider.new("http://www.nfb.ca/remote/services/oembed/")
|
152
|
+
NFBCanada << "http://*.nfb.ca/film/*"
|
153
|
+
add_official_provider(NFBCanada)
|
154
|
+
|
155
|
+
# Provider for scribd.com
|
156
|
+
Scribd = OEmbed::Provider.new("https://www.scribd.com/services/oembed")
|
157
|
+
Scribd << "http://*.scribd.com/*"
|
158
|
+
add_official_provider(Scribd)
|
159
|
+
|
160
|
+
# Provider for speakerdeck.com
|
161
|
+
# https://speakerdeck.com/faq#oembed
|
162
|
+
SpeakerDeck = OEmbed::Provider.new("https://speakerdeck.com/oembed.json")
|
163
|
+
SpeakerDeck << "http://speakerdeck.com/*/*"
|
164
|
+
SpeakerDeck << "https://speakerdeck.com/*/*"
|
165
|
+
add_official_provider(SpeakerDeck)
|
166
|
+
|
167
|
+
# Provider for movieclips.com
|
168
|
+
MovieClips = OEmbed::Provider.new("http://movieclips.com/services/oembed/")
|
169
|
+
MovieClips << "http://movieclips.com/watch/*/*/"
|
170
|
+
add_official_provider(MovieClips)
|
171
|
+
|
172
|
+
# Provider for 23hq.com
|
173
|
+
TwentyThree = OEmbed::Provider.new("http://www.23hq.com/23/oembed")
|
174
|
+
TwentyThree << "http://www.23hq.com/*"
|
175
|
+
add_official_provider(TwentyThree)
|
176
|
+
|
177
|
+
# Provider for soundcloud.com
|
178
|
+
# http://developers.soundcloud.com/docs/oembed
|
179
|
+
SoundCloud = OEmbed::Provider.new("https://soundcloud.com/oembed", format: :json)
|
180
|
+
SoundCloud << "http://*.soundcloud.com/*"
|
181
|
+
SoundCloud << "https://*.soundcloud.com/*"
|
182
|
+
add_official_provider(SoundCloud)
|
183
|
+
|
184
|
+
# Provider for spotify.com
|
185
|
+
# https://twitter.com/nicklas2k/status/330094611202723840
|
186
|
+
# http://blog.embed.ly/post/45149936446/oembed-for-spotify
|
187
|
+
Spotify = OEmbed::Provider.new("https://embed.spotify.com/oembed/")
|
188
|
+
Spotify << "http://open.spotify.com/*"
|
189
|
+
Spotify << "https://open.spotify.com/*"
|
190
|
+
Spotify << "http://play.spotify.com/*"
|
191
|
+
Spotify << "https://play.spotify.com/*"
|
192
|
+
Spotify << /^spotify\:(.*?)/
|
193
|
+
add_official_provider(Spotify)
|
194
|
+
|
195
|
+
# Provider for skitch.com
|
196
|
+
# http://skitch.com/oembed/%3C/endpoint
|
197
|
+
Skitch = OEmbed::Provider.new("http://skitch.com/oembed")
|
198
|
+
Skitch << "http://*.skitch.com/*"
|
199
|
+
Skitch << "https://*.skitch.com/*"
|
200
|
+
add_official_provider(Skitch)
|
201
|
+
|
202
|
+
# Provider for TED
|
203
|
+
Ted = OEmbed::Provider.new("https://www.ted.com/talks/oembed.{format}")
|
204
|
+
Ted << "http://*.ted.com/talks/*"
|
205
|
+
Ted << "https://*.ted.com/talks/*"
|
206
|
+
add_official_provider(Ted)
|
207
|
+
|
208
|
+
# Provider for tumblr.com
|
209
|
+
Tumblr = OEmbed::Provider.new("http://www.tumblr.com/oembed/1.0/", format: :json)
|
210
|
+
Tumblr << "http://*.tumblr.com/post/*"
|
211
|
+
Tumblr << "https://*.tumblr.com/post/*"
|
212
|
+
add_official_provider(Tumblr)
|
213
|
+
|
214
|
+
## Provider for clikthrough.com
|
215
|
+
# http://corporate.clikthrough.com/wp/?p=275
|
216
|
+
#Clickthrough = OEmbed::Provider.new("http://www.clikthrough.com/services/oembed/")
|
217
|
+
#Clickthrough << "http://*.clikthrough.com/theater/video/*"
|
218
|
+
#add_official_provider(Clickthrough)
|
219
|
+
|
220
|
+
## Provider for kinomap.com
|
221
|
+
# http://www.kinomap.com/#!oEmbed
|
222
|
+
#Kinomap = OEmbed::Provider.new("http://www.kinomap.com/oembed")
|
223
|
+
#Kinomap << "http://www.kinomap.com/*"
|
224
|
+
#add_official_provider(Kinomap)
|
225
|
+
|
226
|
+
# Provider for oohembed.com, which is a provider aggregator. See
|
227
|
+
# OEmbed::Providers::OohEmbed.urls for a full list of supported url schemas.
|
228
|
+
# Embed.ly has taken over the oohembed.com domain and as of July 20 all oohEmbed
|
229
|
+
# request will require you use an API key. For details on the transition see
|
230
|
+
# http://blog.embed.ly/oohembed
|
231
|
+
OohEmbed = OEmbed::Provider.new("http://oohembed.com/oohembed/", format: :json)
|
232
|
+
OohEmbed << "http://*.5min.com/Video/*" # micro-video host
|
233
|
+
OohEmbed << %r{http://(.*?).amazon.(com|co.uk|de|ca|jp)/(.*?)/(gp/product|o/ASIN|obidos/ASIN|dp)/(.*?)} # Online product shopping
|
234
|
+
OohEmbed << "http://*.blip.tv/*"
|
235
|
+
OohEmbed << "http://*.clikthrough.com/theater/video/*"
|
236
|
+
OohEmbed << "http://*.collegehumor.com/video:*" # Comedic & original videos
|
237
|
+
OohEmbed << "http://*.thedailyshow.com/video/*" # Syndicated show
|
238
|
+
OohEmbed << "http://*.dailymotion.com/*"
|
239
|
+
OohEmbed << "http://dotsub.com/view/*"
|
240
|
+
OohEmbed << "http://*.flickr.com/photos/*"
|
241
|
+
OohEmbed << "http://*.funnyordie.com/videos/*" # Comedy video host
|
242
|
+
OohEmbed << "http://video.google.com/videoplay?*" # Video hosting
|
243
|
+
OohEmbed << "http://www.hulu.com/watch/*"
|
244
|
+
OohEmbed << "http://*.kinomap.com/*"
|
245
|
+
OohEmbed << "http://*.livejournal.com/"
|
246
|
+
OohEmbed << "http://*.metacafe.com/watch/*" # Video host
|
247
|
+
OohEmbed << "http://*.nfb.ca/film/*"
|
248
|
+
OohEmbed << "http://*.photobucket.com/albums/*"
|
249
|
+
OohEmbed << "http://*.photobucket.com/groups/*"
|
250
|
+
OohEmbed << "http://*.phodroid.com/*/*/*" # Photo host
|
251
|
+
OohEmbed << "http://qik.com/*"
|
252
|
+
OohEmbed << "http://*.revision3.com/*"
|
253
|
+
OohEmbed << "http://*.scribd.com/*"
|
254
|
+
OohEmbed << "http://*.slideshare.net/*" # Share presentations online
|
255
|
+
OohEmbed << "http://*.twitpic.com/*" # Picture hosting for Twitter
|
256
|
+
OohEmbed << "http://twitter.com/*/statuses/*" # Mirco-blogging network
|
257
|
+
OohEmbed << "http://*.viddler.com/explore/*"
|
258
|
+
OohEmbed << "http://www.vimeo.com/*"
|
259
|
+
OohEmbed << "http://www.vimeo.com/groups/*/videos/*"
|
260
|
+
OohEmbed << "http://*.wikipedia.org/wiki/*" # Online encyclopedia
|
261
|
+
OohEmbed << "http://*.wordpress.com/*/*/*/*" # Blogging Engine & community
|
262
|
+
OohEmbed << "http://*.xkcd.com/*" # A hilarious stick figure comic
|
263
|
+
OohEmbed << %r{http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/(.*?)} # image & video hosting
|
264
|
+
OohEmbed << "http://*.youtube.com/watch*"
|
265
|
+
|
266
|
+
# Provider for noembed.com, which is a provider aggregator. See
|
267
|
+
# OEmbed::Providers::Noembed.urls for a full list of supported url schemas.
|
268
|
+
# https://noembed.com/#supported-sites
|
269
|
+
Noembed = OEmbed::Provider.new("https://noembed.com/embed")
|
270
|
+
# Add all known URL regexps for Noembed.
|
271
|
+
# To update this list run `rake oembed:update_noembed`
|
272
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "/aggregators/noembed_urls.yml")).each do |url|
|
273
|
+
Noembed << Regexp.new(url)
|
274
|
+
end
|
275
|
+
add_official_provider(Noembed, :aggregators)
|
276
|
+
|
277
|
+
# Provider for Embedly.com, which is a provider aggregator. See
|
278
|
+
# OEmbed::Providers::Embedly.urls for a full list of supported url schemas.
|
279
|
+
# http://embed.ly/docs/endpoints/1/oembed
|
280
|
+
#
|
281
|
+
# You can append your Embed.ly API key to the provider so that all requests are signed
|
282
|
+
# OEmbed::Providers::Embedly.endpoint += "?key=#{my_embedly_key}"
|
283
|
+
#
|
284
|
+
# If you don't yet have an API key you'll need to sign up here: http://embed.ly/pricing
|
285
|
+
Embedly = OEmbed::Provider.new("http://api.embed.ly/1/oembed")
|
286
|
+
# Add all known URL regexps for Embedly. To update this list run `rake oembed:update_embedly`
|
287
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "/aggregators/embedly_urls.yml")).each do |url|
|
288
|
+
Embedly << url
|
289
|
+
end
|
290
|
+
add_official_provider(Embedly, :aggregators)
|
291
|
+
end
|
292
|
+
end
|
@@ -1,25 +1,35 @@
|
|
1
1
|
module OEmbed
|
2
2
|
class Providers
|
3
3
|
# Provider for Facebook posts
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
# See https://developers.facebook.com/docs/plugins/oembed
|
5
|
+
# See https://developers.facebook.com/docs/graph-api/reference/v8.0/oembed-post
|
6
|
+
FacebookPost = OEmbed::Provider.new(
|
7
|
+
"https://graph.facebook.com/v8.0/oembed_post",
|
8
|
+
required_query_params: { access_token: 'OEMBED_FACEBOOK_TOKEN' },
|
9
|
+
format: :json
|
10
|
+
)
|
11
|
+
FacebookPost << 'https://www.facebook.com/*/posts/*'
|
12
|
+
FacebookPost << 'https://www.facebook.com/*/activity/*'
|
13
|
+
FacebookPost << 'https://www.facebook.com/photo*'
|
14
|
+
FacebookPost << 'https://www.facebook.com/*/photo*'
|
15
|
+
FacebookPost << 'https://www.facebook.com/media*'
|
16
|
+
FacebookPost << 'https://www.facebook.com/questions*'
|
17
|
+
FacebookPost << 'https://www.facebook.com/notes*'
|
9
18
|
|
10
|
-
|
19
|
+
# Note: even though FacebookPost is automatically registered as an official provider
|
20
|
+
# it will NOT resolve any URLs unless its access_token is set
|
21
|
+
# either via the OEMBED_FACEBOOK_TOKEN environment variable
|
22
|
+
# or by calling `OEmbed::Providers::FacebookPost.access_token = @your_token`
|
23
|
+
add_official_provider(FacebookPost, nil, access_token: {name: :facebook, method: :access_token})
|
11
24
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
'https://www.facebook.com/questions*',
|
21
|
-
'https://www.facebook.com/notes*'].each { |u| self << u }
|
22
|
-
end
|
25
|
+
# Respond to the `new` method to maintain backwards compatibility with v0.14.0
|
26
|
+
# See also:
|
27
|
+
# * https://github.com/ruby-oembed/ruby-oembed/pull/75
|
28
|
+
# * https://github.com/ruby-oembed/ruby-oembed/issues/77#issuecomment-727024682
|
29
|
+
# @deprecated *Note*: This method will be be removed in the future.
|
30
|
+
def FacebookPost.new(access_token:)
|
31
|
+
self.access_token = access_token
|
32
|
+
self
|
23
33
|
end
|
24
34
|
end
|
25
35
|
end
|
@@ -1,18 +1,30 @@
|
|
1
1
|
module OEmbed
|
2
2
|
class Providers
|
3
3
|
# Provider for Facebook videos
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
# See https://developers.facebook.com/docs/plugins/oembed
|
5
|
+
# See https://developers.facebook.com/docs/graph-api/reference/v8.0/oembed-video
|
6
|
+
FacebookVideo = OEmbed::Provider.new(
|
7
|
+
"https://graph.facebook.com/v8.0/oembed_video",
|
8
|
+
required_query_params: { access_token: 'OEMBED_FACEBOOK_TOKEN' },
|
9
|
+
format: :json
|
10
|
+
)
|
11
|
+
FacebookVideo << 'https://www.facebook.com/*/videos/*'
|
12
|
+
FacebookVideo << 'https://www.facebook.com/video*'
|
9
13
|
|
10
|
-
|
14
|
+
# Note: even though FacebookVideo is automatically registered as an official provider
|
15
|
+
# it will NOT resolve any URLs unless its access_token is set
|
16
|
+
# either via the OEMBED_FACEBOOK_TOKEN environment variable
|
17
|
+
# or by calling `OEmbed::Providers::FacebookVideo.access_token = @your_token`
|
18
|
+
add_official_provider(FacebookVideo, nil, access_token: {name: :facebook, method: :access_token})
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
20
|
+
# Respond to the `new` method to maintain backwards compatibility with v0.14.0
|
21
|
+
# See also:
|
22
|
+
# * https://github.com/ruby-oembed/ruby-oembed/pull/75
|
23
|
+
# * https://github.com/ruby-oembed/ruby-oembed/issues/77#issuecomment-727024682
|
24
|
+
# @deprecated *Note*: This method will be be removed in the future.
|
25
|
+
def FacebookVideo.new(access_token:)
|
26
|
+
self.access_token = access_token
|
27
|
+
self
|
16
28
|
end
|
17
29
|
end
|
18
30
|
end
|
@@ -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
|