ruby-oembed 0.13.1 → 0.16.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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/CHANGELOG.rdoc +25 -1
  4. data/README.md +23 -5
  5. data/lib/oembed/provider.rb +54 -5
  6. data/lib/oembed/providers/{embedly_urls.yml → aggregators/embedly_urls.yml} +0 -0
  7. data/lib/oembed/providers/{noembed_urls.yml → aggregators/noembed_urls.yml} +0 -0
  8. data/lib/oembed/providers/{oohembed_urls.yml → aggregators/oohembed_urls.yml} +0 -0
  9. data/lib/oembed/providers/builtin_providers.rb +297 -0
  10. data/lib/oembed/providers/facebook_post.rb +35 -0
  11. data/lib/oembed/providers/facebook_video.rb +30 -0
  12. data/lib/oembed/providers/instagram.rb +45 -0
  13. data/lib/oembed/providers/tiktok.rb +13 -0
  14. data/lib/oembed/providers.rb +46 -322
  15. data/lib/oembed/version.rb +2 -2
  16. data/lib/oembed.rb +1 -0
  17. data/lib/tasks/oembed.rake +2 -2
  18. data/ruby-oembed.gemspec +1 -2
  19. metadata +16 -55
  20. data/integration_test/test.rb +0 -31
  21. data/integration_test/test_urls.csv +0 -502
  22. data/spec/cassettes/OEmbed_Provider.yml +0 -987
  23. data/spec/cassettes/OEmbed_ProviderDiscovery.yml +0 -27184
  24. data/spec/cassettes/OEmbed_Providers_Slideshare.yml +0 -1433
  25. data/spec/cassettes/OEmbed_Providers_Twitter.yml +0 -612
  26. data/spec/formatter/ducktype_backend_spec.rb +0 -94
  27. data/spec/formatter/json/.DS_Store +0 -0
  28. data/spec/formatter/json/jsongem_backend_spec.rb +0 -71
  29. data/spec/formatter/json/yaml_backend_spec.rb +0 -55
  30. data/spec/formatter/xml/nokogiri_backend_spec.rb +0 -59
  31. data/spec/formatter/xml/rexml_backend_spec.rb +0 -55
  32. data/spec/formatter/xml/xmlsimple_backend_spec.rb +0 -59
  33. data/spec/formatter_spec.rb +0 -37
  34. data/spec/provider_discovery_spec.rb +0 -141
  35. data/spec/provider_spec.rb +0 -366
  36. data/spec/providers/slideshare_spec.rb +0 -42
  37. data/spec/providers/twitter_spec.rb +0 -44
  38. data/spec/providers_spec.rb +0 -258
  39. data/spec/response_spec.rb +0 -230
  40. data/spec/spec_helper.rb +0 -111
  41. data/spec/spec_helper_examples.yml +0 -27
  42. 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: aa5b49cbc24d498437a79986c23aa129502844807e5569038cc4a7e06877cfd0
4
- data.tar.gz: 8e159677b5573eb78ee741ec327c6163cccacd87ed6c69407e588d19d0cf9673
3
+ metadata.gz: eeb96fbccad7fd520db58a1a89c977249ec15af8318b1a40800e2467a3c2e341
4
+ data.tar.gz: 80ac3291c0193e290ddae08a434bcefa40d94767a2f3db3986c83554f6ff05b7
5
5
  SHA512:
6
- metadata.gz: b08a12d66076295e5a46182112bf3c62ca3ec7da449e0e2fbe65ef531232b3e5eef45ce46fa79ad6963b04cfe93bca0971f930cbc1076e899b591dd9584e3a7f
7
- data.tar.gz: a51468e9dc43fa6f0e027259cabbb121eb231c5d70f76046642945755f392527a71a6e4c045d6a5e3a761d7b09089ddaa94e3655adb0b533c4ce7c7ca1d88079
6
+ metadata.gz: 06bd338f7b9f3d33e0cb865e9c605cd38393d4324d5191d1654089862a0f5fc81c7cb54c14557fc5c1f842ffdd935b8e463368af40ce6532bddd4cc56dd6ecef
7
+ data.tar.gz: 529bc64612cb52c8950e0fa93d4ab3afc6a13b2c1ca2cf31b2b69d41a0ed7f7244695f1f2d2dc8577c8614d769893ce748dd504f260d6d081dabd5a1c8a3d639
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,6 +1,30 @@
1
1
  = CHANGELOG
2
2
 
3
- == Unreleased (0.13.2)
3
+ == Unreleased (0.16.1)
4
+
5
+ == 0.16.0 - 8 January 2022
6
+
7
+ * Add a built-in TikTok provider.
8
+ * Reduce gem size by excluding test files; Pull #81 (fauno)
9
+
10
+ == 0.15.0 - 1 January 2021
11
+
12
+ * *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)`
13
+ * *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`.
14
+ * Fix Issue #77: Built-in Instagram & Facebook providers are now instances again.
15
+ * 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.
16
+ * Add support for Instgram Reels URLs to the built-in OEmbed::Providers::Instagram.
17
+ * Support focused rspec tests for local development (e.g. "fcontext" or "fit")
18
+ * Fix a few typos in documentation & tests; Pull #76 (Inge Jørgensen)
19
+
20
+ == 0.14.1 - 28 December 2020
21
+
22
+ * Fix the YouTube provider when given a private video; Issue #79 (Sebastian Schulze)
23
+
24
+ == 0.14.0 - 5 November 2020
25
+
26
+ * *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
27
+ * Add support for Facebook/Instagram access tokens; Pull #75 (Inge Jørgensen)
4
28
 
5
29
  == 0.13.1 - 25 May 2020
6
30
 
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.
@@ -34,6 +34,26 @@ resource.html #=> <<-HTML
34
34
  HTML
35
35
  ```
36
36
 
37
+ ### Providers requiring an access token
38
+
39
+ Some built-in providers require authorization in order to work. These providers won't be registered unless an access token is provided. You can either pass access tokens to the `register_app` method.
40
+
41
+ ```ruby
42
+ OEmbed::Providers.register_all(access_tokens: { facebook: @my_facebook_token })
43
+ ```
44
+
45
+ Or you can provide access tokens via environment variable
46
+ ```ruby
47
+ ENV['OEMBED_FACEBOOK_TOKEN'] #=> 'my-access-token'
48
+ OEmbed::Providers.register_all
49
+ ```
50
+
51
+ #### Currently supported access tokens
52
+
53
+ | access_token | environment variable | Associated Providers |
54
+ |--------------|-------------------------|----------------------|
55
+ | `:facebook` | `OEMBED_FACEBOOK_TOKEN` | `FacebookPost`, `FacebookVideo`, `Instagram` |
56
+
37
57
  ## Custom Providers
38
58
 
39
59
  If you'd like to use a provider that isn't included in the library, it's easy to create one. Just provide the oEmbed API endpoint and URL scheme(s).
@@ -86,8 +106,6 @@ The following, optional, backends are currently supported:
86
106
 
87
107
  # Lend a Hand
88
108
 
89
- **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)
90
-
91
109
  Code for the ruby-oembed library is [hosted on GitHub](https://github.com/ruby-oembed/ruby-oembed).
92
110
 
93
111
  ```bash
@@ -107,7 +125,7 @@ If you encounter any bug, feel free to [create an Issue](https://github.com/ruby
107
125
 
108
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/).
109
127
 
110
- 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)
111
129
 
112
130
  # Contributors
113
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,297 @@
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 TikTok
209
+ # See https://developers.tiktok.com/doc/embed-videos
210
+ TikTok = OEmbed::Provider.new("https://www.tiktok.com/oembed", format: :json)
211
+ TikTok << "https://www.tiktok.com/*/video/*"
212
+
213
+ # Provider for tumblr.com
214
+ Tumblr = OEmbed::Provider.new("http://www.tumblr.com/oembed/1.0/", format: :json)
215
+ Tumblr << "http://*.tumblr.com/post/*"
216
+ Tumblr << "https://*.tumblr.com/post/*"
217
+ add_official_provider(Tumblr)
218
+
219
+ ## Provider for clikthrough.com
220
+ # http://corporate.clikthrough.com/wp/?p=275
221
+ #Clickthrough = OEmbed::Provider.new("http://www.clikthrough.com/services/oembed/")
222
+ #Clickthrough << "http://*.clikthrough.com/theater/video/*"
223
+ #add_official_provider(Clickthrough)
224
+
225
+ ## Provider for kinomap.com
226
+ # http://www.kinomap.com/#!oEmbed
227
+ #Kinomap = OEmbed::Provider.new("http://www.kinomap.com/oembed")
228
+ #Kinomap << "http://www.kinomap.com/*"
229
+ #add_official_provider(Kinomap)
230
+
231
+ # Provider for oohembed.com, which is a provider aggregator. See
232
+ # OEmbed::Providers::OohEmbed.urls for a full list of supported url schemas.
233
+ # Embed.ly has taken over the oohembed.com domain and as of July 20 all oohEmbed
234
+ # request will require you use an API key. For details on the transition see
235
+ # http://blog.embed.ly/oohembed
236
+ OohEmbed = OEmbed::Provider.new("http://oohembed.com/oohembed/", format: :json)
237
+ OohEmbed << "http://*.5min.com/Video/*" # micro-video host
238
+ OohEmbed << %r{http://(.*?).amazon.(com|co.uk|de|ca|jp)/(.*?)/(gp/product|o/ASIN|obidos/ASIN|dp)/(.*?)} # Online product shopping
239
+ OohEmbed << "http://*.blip.tv/*"
240
+ OohEmbed << "http://*.clikthrough.com/theater/video/*"
241
+ OohEmbed << "http://*.collegehumor.com/video:*" # Comedic & original videos
242
+ OohEmbed << "http://*.thedailyshow.com/video/*" # Syndicated show
243
+ OohEmbed << "http://*.dailymotion.com/*"
244
+ OohEmbed << "http://dotsub.com/view/*"
245
+ OohEmbed << "http://*.flickr.com/photos/*"
246
+ OohEmbed << "http://*.funnyordie.com/videos/*" # Comedy video host
247
+ OohEmbed << "http://video.google.com/videoplay?*" # Video hosting
248
+ OohEmbed << "http://www.hulu.com/watch/*"
249
+ OohEmbed << "http://*.kinomap.com/*"
250
+ OohEmbed << "http://*.livejournal.com/"
251
+ OohEmbed << "http://*.metacafe.com/watch/*" # Video host
252
+ OohEmbed << "http://*.nfb.ca/film/*"
253
+ OohEmbed << "http://*.photobucket.com/albums/*"
254
+ OohEmbed << "http://*.photobucket.com/groups/*"
255
+ OohEmbed << "http://*.phodroid.com/*/*/*" # Photo host
256
+ OohEmbed << "http://qik.com/*"
257
+ OohEmbed << "http://*.revision3.com/*"
258
+ OohEmbed << "http://*.scribd.com/*"
259
+ OohEmbed << "http://*.slideshare.net/*" # Share presentations online
260
+ OohEmbed << "http://*.twitpic.com/*" # Picture hosting for Twitter
261
+ OohEmbed << "http://twitter.com/*/statuses/*" # Mirco-blogging network
262
+ OohEmbed << "http://*.viddler.com/explore/*"
263
+ OohEmbed << "http://www.vimeo.com/*"
264
+ OohEmbed << "http://www.vimeo.com/groups/*/videos/*"
265
+ OohEmbed << "http://*.wikipedia.org/wiki/*" # Online encyclopedia
266
+ OohEmbed << "http://*.wordpress.com/*/*/*/*" # Blogging Engine & community
267
+ OohEmbed << "http://*.xkcd.com/*" # A hilarious stick figure comic
268
+ OohEmbed << %r{http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/(.*?)} # image & video hosting
269
+ OohEmbed << "http://*.youtube.com/watch*"
270
+
271
+ # Provider for noembed.com, which is a provider aggregator. See
272
+ # OEmbed::Providers::Noembed.urls for a full list of supported url schemas.
273
+ # https://noembed.com/#supported-sites
274
+ Noembed = OEmbed::Provider.new("https://noembed.com/embed")
275
+ # Add all known URL regexps for Noembed.
276
+ # To update this list run `rake oembed:update_noembed`
277
+ YAML.load_file(File.join(File.dirname(__FILE__), "/aggregators/noembed_urls.yml")).each do |url|
278
+ Noembed << Regexp.new(url)
279
+ end
280
+ add_official_provider(Noembed, :aggregators)
281
+
282
+ # Provider for Embedly.com, which is a provider aggregator. See
283
+ # OEmbed::Providers::Embedly.urls for a full list of supported url schemas.
284
+ # http://embed.ly/docs/endpoints/1/oembed
285
+ #
286
+ # You can append your Embed.ly API key to the provider so that all requests are signed
287
+ # OEmbed::Providers::Embedly.endpoint += "?key=#{my_embedly_key}"
288
+ #
289
+ # If you don't yet have an API key you'll need to sign up here: http://embed.ly/pricing
290
+ Embedly = OEmbed::Provider.new("http://api.embed.ly/1/oembed")
291
+ # Add all known URL regexps for Embedly. To update this list run `rake oembed:update_embedly`
292
+ YAML.load_file(File.join(File.dirname(__FILE__), "/aggregators/embedly_urls.yml")).each do |url|
293
+ Embedly << url
294
+ end
295
+ add_official_provider(Embedly, :aggregators)
296
+ end
297
+ end
@@ -0,0 +1,35 @@
1
+ module OEmbed
2
+ class Providers
3
+ # Provider for Facebook posts
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*'
18
+
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})
24
+
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
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,30 @@
1
+ module OEmbed
2
+ class Providers
3
+ # Provider for Facebook videos
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*'
13
+
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})
19
+
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
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ module OEmbed
2
+ class Providers
3
+ # Provider for instagram.com
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/*"
16
+
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/*"
23
+
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
43
+ end
44
+ end
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