FEATURE: Facebook video onebox

FEATURE: Facebook video onebox

diff --git a/lib/onebox/engine.rb b/lib/onebox/engine.rb
index 7571148..5cea541 100644
--- a/lib/onebox/engine.rb
+++ b/lib/onebox/engine.rb
@@ -178,3 +178,4 @@ require_relative "engine/google_photos_onebox"
 require_relative "engine/kaltura_onebox"
 require_relative "engine/reddit_media_onebox"
 require_relative "engine/google_drive_onebox"
+require_relative "engine/facebook_media_onebox"
diff --git a/lib/onebox/engine/facebook_media_onebox.rb b/lib/onebox/engine/facebook_media_onebox.rb
new file mode 100644
index 0000000..c7c1203
--- /dev/null
+++ b/lib/onebox/engine/facebook_media_onebox.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Onebox
+  module Engine
+    class FacebookMediaOnebox
+      include Engine
+      include StandardEmbed
+
+      matches_regexp(/^https?:\/\/.*\.facebook\.com\/(\w+)\/(videos|\?).*/)
+      always_https
+
+      def to_html
+        metadata = get_twitter
+        if metadata.present? && metadata[:card] == "player" && metadata[:player].present?
+          <<-HTML
+            <iframe src="#{metadata[:player]}"
+                    width="#{metadata[:player_width]}"
+                    height="#{metadata[:player_height]}"
+                    scrolling="no"
+                    frameborder="0"
+                    allowfullscreen>
+            </iframe>
+          HTML
+        else
+          html = Onebox::Engine::WhitelistedGenericOnebox.new(@url, @timeout).to_html
+          return if Onebox::Helpers.blank?(html)
+          html
+        end
+      end
+    end
+  end
+end

GitHub sha: dabced70

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/video-embeds-from-facebook-com-and-other-sites-fail/149366/27