ruby-oembed 0.14.0 → 0.16.1

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/CHANGELOG.rdoc +25 -2
  4. data/README.md +5 -7
  5. data/lib/oembed/provider.rb +54 -5
  6. data/lib/oembed/providers/builtin_providers.rb +292 -0
  7. data/lib/oembed/providers/facebook_post.rb +27 -17
  8. data/lib/oembed/providers/facebook_video.rb +22 -10
  9. data/lib/oembed/providers/instagram.rb +37 -20
  10. data/lib/oembed/providers/tiktok.rb +13 -0
  11. data/lib/oembed/providers.rb +39 -300
  12. data/lib/oembed/version.rb +2 -2
  13. data/lib/oembed.rb +1 -0
  14. data/ruby-oembed.gemspec +1 -2
  15. metadata +9 -53
  16. data/integration_test/test.rb +0 -31
  17. data/integration_test/test_urls.csv +0 -502
  18. data/spec/cassettes/OEmbed_Provider.yml +0 -987
  19. data/spec/cassettes/OEmbed_ProviderDiscovery.yml +0 -27184
  20. data/spec/cassettes/OEmbed_Providers_Slideshare.yml +0 -1433
  21. data/spec/cassettes/OEmbed_Providers_Twitter.yml +0 -612
  22. data/spec/formatter/ducktype_backend_spec.rb +0 -94
  23. data/spec/formatter/json/.DS_Store +0 -0
  24. data/spec/formatter/json/jsongem_backend_spec.rb +0 -71
  25. data/spec/formatter/json/yaml_backend_spec.rb +0 -55
  26. data/spec/formatter/xml/nokogiri_backend_spec.rb +0 -59
  27. data/spec/formatter/xml/rexml_backend_spec.rb +0 -55
  28. data/spec/formatter/xml/xmlsimple_backend_spec.rb +0 -59
  29. data/spec/formatter_spec.rb +0 -37
  30. data/spec/provider_discovery_spec.rb +0 -141
  31. data/spec/provider_spec.rb +0 -366
  32. data/spec/providers/facebook_spec.rb +0 -50
  33. data/spec/providers/slideshare_spec.rb +0 -42
  34. data/spec/providers/twitter_spec.rb +0 -44
  35. data/spec/providers_spec.rb +0 -306
  36. data/spec/response_spec.rb +0 -230
  37. data/spec/spec_helper.rb +0 -111
  38. data/spec/spec_helper_examples.yml +0 -27
  39. data/spec/support/shared_examples_for_providers.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ce690eea65c79e7df55ec323c59bf8c2ec43c9b94c1f084ad558b70c392cef9
4
- data.tar.gz: b964d57ad3902a1dc99911aecc7f7f566a89ce2b6fdaa22ab34763c01a4e8aba
3
+ metadata.gz: dfcdff2a45ff8d739d78d8b44f0694735d6bb962b01ff6e0fef85e0a089d1d23
4
+ data.tar.gz: 3fdef0f50c4d9f65a316099e069fde6e50c3dcdd52bb3251fa3c97d300736dbb
5
5
  SHA512:
6
- metadata.gz: 5e694d02b886ff90fa2d14afcbaefeda99ab258e632d8126e0e2d61c308edb0eb3001cd517ce1342e3eea033d31eeca1a8016068392e406689ffb08c95242c02
7
- data.tar.gz: 3aba0c2994ae8fa2b87a172e03dfb4a529eec7ccfabd393b2182a91822bb4856ae2409983d0cb3755a092a191729d0af84c755f14e384a3cd5a2ce9c80b814f6
6
+ metadata.gz: a6f93f4aa24f1cbf281c94657d2f58749599f1b7628e835475feb61eed2136333736478ce34f82bff209b9557ce70dd6ef1214ddaffdd99ba36fcdd6bb1a3793
7
+ data.tar.gz: bd3bdbd9a24b06c715498ca90691998d13fb05b13332f698b1f4065cd639d46db9644404328ef4f0d7a74cc46488008f1d36688b89f8b99324df6c6ed4ca48a2
data/.travis.yml CHANGED
@@ -5,5 +5,8 @@ before_install:
5
5
  bundler_args: --without guard
6
6
  cache: bundler
7
7
  rvm:
8
- - 2.4.1
9
- - 2.6.5
8
+ - 2.6.9
9
+ - 3.0.3
10
+ env:
11
+ global:
12
+ - RUN_ALL_TESTS=true
data/CHANGELOG.rdoc CHANGED
@@ -1,11 +1,34 @@
1
1
  = CHANGELOG
2
2
 
3
- == Unreleased (0.14.1)
3
+ == Unreleased (0.16.2)
4
4
 
5
+ == 0.16.1 - 13 January 2022
6
+
7
+ * Fix the "already initialized constant OEmbed::Providers::TikTok" warning; Pull #84 (Christopher Nelson)
8
+
9
+ == 0.16.0 - 8 January 2022
10
+
11
+ * Add a built-in TikTok provider.
12
+ * Reduce gem size by excluding test files; Pull #81 (fauno)
13
+
14
+ == 0.15.0 - 1 January 2021
15
+
16
+ * *DEPRECATION* When creating an `OEmbed::Provider` instance, specifying the format via positional argument is now deprecated. Please use a named argument instead: `OEmbed::Provider.new(@endpoint_url, format: :json)`
17
+ * *DEPRECATION* Do not use the `new` method for `Instagram`, `FacebookPost`, or `FacebookVideo` providers to set your access token. Instead either use the `OEMBED_FACEBOOK_TOKEN` environment variable or call `Instagram.access_token = @your_token`.
18
+ * Fix Issue #77: Built-in Instagram & Facebook providers are now instances again.
19
+ * Add support for `OEmbed::Provider` instances with `required_query_params` (like access tokens), where the provider will fail to answer until it is fully configured.
20
+ * Add support for Instgram Reels URLs to the built-in OEmbed::Providers::Instagram.
21
+ * Support focused rspec tests for local development (e.g. "fcontext" or "fit")
22
+ * Fix a few typos in documentation & tests; Pull #76 (Inge Jørgensen)
23
+
24
+ == 0.14.1 - 28 December 2020
25
+
26
+ * Fix the YouTube provider when given a private video; Issue #79 (Sebastian Schulze)
5
27
 
6
28
  == 0.14.0 - 5 November 2020
7
29
 
8
- * Add support for Facebook/Instragram access tokens; Pull #75 (Inge Jørgensen)
30
+ * *BREAKING* Built-in providers for Instagram & Facebook are now classes, not instances, and therefore can't manually be registered via `OEmbed::Providers.register(OEmbed::Providers::Instagram)`; See Issue #77
31
+ * Add support for Facebook/Instagram access tokens; Pull #75 (Inge Jørgensen)
9
32
 
10
33
  == 0.13.1 - 25 May 2020
11
34
 
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # ruby-oembed
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/ruby-oembed.svg)](https://rubygems.org/gems/ruby-oembed)
4
- [![Travis branch](https://img.shields.io/travis/ruby-oembed/ruby-oembed/master.svg)](https://travis-ci.org/ruby-oembed/ruby-oembed/branches)
4
+ [![Travis CI](https://img.shields.io/travis/com/ruby-oembed/ruby-oembed.svg)](https://app.travis-ci.com/github/ruby-oembed/ruby-oembed)
5
5
  [![Code Climate](https://img.shields.io/codeclimate/maintainability/ruby-oembed/ruby-oembed.svg)](https://codeclimate.com/github/ruby-oembed/ruby-oembed)
6
6
  [![Coveralls](https://coveralls.io/repos/github/ruby-oembed/ruby-oembed/badge.svg?branch=coveralls)](https://coveralls.io/github/ruby-oembed/ruby-oembed?branch=coveralls)
7
- ![Maintenance](https://img.shields.io/maintenance/yes/2020.svg)
7
+ ![Maintenance](https://img.shields.io/maintenance/yes/2022.svg)
8
8
 
9
9
 
10
10
  An oEmbed consumer library written in Ruby, letting you easily get embeddable HTML representations of supported web pages, based on their URLs. See [oembed.com](http://oembed.com) for more about the protocol.
@@ -50,8 +50,8 @@ OEmbed::Providers.register_all
50
50
 
51
51
  #### Currently supported access tokens
52
52
 
53
- | access_token | environment variable | Associaed Providers |
54
- |--------------|-------------------------|---------------------|
53
+ | access_token | environment variable | Associated Providers |
54
+ |--------------|-------------------------|----------------------|
55
55
  | `:facebook` | `OEMBED_FACEBOOK_TOKEN` | `FacebookPost`, `FacebookVideo`, `Instagram` |
56
56
 
57
57
  ## Custom Providers
@@ -106,8 +106,6 @@ The following, optional, backends are currently supported:
106
106
 
107
107
  # Lend a Hand
108
108
 
109
- **Note:** Work is under way on a v1.0 of ruby-oembed. If you'd like to contribute, take a look at [the rubocop branch!](https://github.com/ruby-oembed/ruby-oembed/tree/rubocop)
110
-
111
109
  Code for the ruby-oembed library is [hosted on GitHub](https://github.com/ruby-oembed/ruby-oembed).
112
110
 
113
111
  ```bash
@@ -127,7 +125,7 @@ If you encounter any bug, feel free to [create an Issue](https://github.com/ruby
127
125
 
128
126
  We gladly accept pull requests! Just [fork](http://help.github.com/forking/) the library and commit your changes along with relevant tests. Once you're happy with the changes, [send a pull request](http://help.github.com/pull-requests/).
129
127
 
130
- We do our best to [keep our tests green](http://travis-ci.org/ruby-oembed/ruby-oembed)
128
+ We do our best to [keep our tests green](https://app.travis-ci.com/github/ruby-oembed/ruby-oembed)
131
129
 
132
130
  # Contributors
133
131
 
@@ -36,9 +36,15 @@ module OEmbed
36
36
  # In actual requests to this Provider, this string will be replaced with a String
37
37
  # representing the request format (e.g. "json").
38
38
  #
39
- # If give, the format should be the name of the default format for all request
39
+ # The `format:` option should be the name of the default format for all request
40
40
  # to this Provider (e.g. 'json'). Defaults to OEmbed::Formatter.default
41
41
  #
42
+ # # @deprecated *Note*: The `positional_format` is deprecated. Please used the named argument instead.
43
+ #
44
+ # The `required_query_params:` option should be a Hash
45
+ # representing query params that will be appended to the endpoint on each request
46
+ # and the optional name of an environment variable (i.e. ENV) whose value will be used
47
+ #
42
48
  # For example:
43
49
  # # If requests should be sent to:
44
50
  # # "http://my.service.com/oembed?format=#{OEmbed::Formatter.default}"
@@ -46,14 +52,31 @@ module OEmbed
46
52
  #
47
53
  # # If requests should be sent to:
48
54
  # # "http://my.service.com/oembed.xml"
49
- # @xml_provider = OEmbed::Provider.new("http://my.service.com/oembed.{format}", :xml)
50
- def initialize(endpoint, format = OEmbed::Formatter.default)
55
+ # @xml_provider = OEmbed::Provider.new("http://my.service.com/oembed.{format}", format: :xml)
56
+ #
57
+ # # If the endpoint requires an `access_token` be specified:
58
+ # @provider_with_auth = OEmbed::Provider.new("http://my.service.com/oembed", required_query_params: { access_token: 'MY_SERVICE_ACCESS_TOKEN' })
59
+ # # You can optionally override the value from `ENV['MY_SERVICE_ACCESS_TOKEN']`
60
+ # @provider_with_auth.access_token = @my_access_token
61
+ def initialize(endpoint, positional_format = OEmbed::Formatter.default, format: nil, required_query_params: {})
51
62
  endpoint_uri = URI.parse(endpoint.gsub(/[\{\}]/,'')) rescue nil
52
63
  raise ArgumentError, "The given endpoint isn't a valid http(s) URI: #{endpoint.to_s}" unless endpoint_uri.is_a?(URI::HTTP)
53
64
 
65
+ @required_query_params = {}
66
+ required_query_params.each do |param, default_env_var|
67
+ param = param.to_sym
68
+ @required_query_params[param] = nil
69
+ set_required_query_params(param, ENV[default_env_var]) if default_env_var
70
+
71
+ # Define a getter and a setter for each required_query_param
72
+ define_singleton_method("#{param}") { @required_query_params[param] } unless respond_to?("#{param}")
73
+ define_singleton_method("#{param}=") { |val| set_required_query_params(param, val) } unless respond_to?("#{param}=")
74
+ end
75
+ required_query_params_set?(reset_cache: true)
76
+
54
77
  @endpoint = endpoint
55
78
  @urls = []
56
- @format = format
79
+ @format = format || positional_format
57
80
  end
58
81
 
59
82
  # Adds the given url scheme to this Provider instance.
@@ -75,6 +98,28 @@ module OEmbed
75
98
  @urls << url
76
99
  end
77
100
 
101
+ # Given the name of a required_query_param and a value
102
+ # store that value internally, so that it can be sent along
103
+ # with requests to this provider's endpoint.
104
+ # Raises an ArgumentError if the given param is not listed with required_query_params
105
+ # during instantiation.
106
+ def set_required_query_params(param, val)
107
+ raise ArgumentError.new("This provider does NOT have a required_query_param named #{param.inspect}") unless @required_query_params.has_key?(param)
108
+
109
+ @required_query_params[param] = val.nil? ? nil : ::CGI.escape(val.to_s)
110
+
111
+ required_query_params_set?(reset_cache: true)
112
+
113
+ @required_query_params[param]
114
+ end
115
+
116
+ # Returns true if all of this provider's required_query_params have a value
117
+ def required_query_params_set?(reset_cache: false)
118
+ return @all_required_query_params_set unless reset_cache || @all_required_query_params_set.nil?
119
+
120
+ @all_required_query_params_set = !@required_query_params.values.include?(nil)
121
+ end
122
+
78
123
  # Send a request to the Provider endpoint to get information about the
79
124
  # given url and return the appropriate OEmbed::Response.
80
125
  #
@@ -92,7 +137,9 @@ module OEmbed
92
137
 
93
138
  # Determine whether the given url is supported by this Provider by matching
94
139
  # against the Provider's URL schemes.
140
+ # It will always return false of a provider has required_query_params that are not set.
95
141
  def include?(url)
142
+ return false unless required_query_params_set?
96
143
  @urls.empty? || !!@urls.detect{ |u| u =~ url }
97
144
  end
98
145
 
@@ -100,10 +147,12 @@ module OEmbed
100
147
  def build(url, query = {})
101
148
  raise OEmbed::NotFound, url unless include?(url)
102
149
 
103
- query = query.merge({:url => ::CGI.escape(url)})
104
150
  query.delete(:timeout)
105
151
  query.delete(:max_redirects)
106
152
 
153
+ query = query.merge(@required_query_params)
154
+ query = query.merge({:url => ::CGI.escape(url)})
155
+
107
156
  # TODO: move this code exclusively into the get method, once build is private.
108
157
  this_format = (query[:format] ||= @format.to_s).to_s
109
158
 
@@ -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/tiktok'
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
- class FacebookPost < OEmbed::Provider
5
- def initialize(access_token:)
6
- super("https://graph.facebook.com/v8.0/oembed_post?access_token=#{access_token}", :json)
7
- register_urls!
8
- end
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
- private
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
- def register_urls!
13
- ['https://www.facebook.com/*/posts/*',
14
- 'https://www.facebook.com/*/activity/*',
15
- 'https://www.facebook.com/photo*',
16
- 'https://www.facebook.com/photos*',
17
- 'https://www.facebook.com/*/photos*',
18
- 'https://www.facebook.com/permalink*',
19
- 'https://www.facebook.com/media*',
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
- class FacebookVideo < OEmbed::Provider
5
- def initialize(access_token:)
6
- super("https://graph.facebook.com/v8.0/oembed_video?access_token=#{access_token}", :json)
7
- register_urls!
8
- end
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
- private
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
- def register_urls!
13
- ['https://www.facebook.com/*/videos/*',
14
- 'https://www.facebook.com/video*'].each { |u| self << u }
15
- end
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