Fix YouTube embeds by rewriting http to https

This commit is contained in:
Alex Gleason 2021-02-20 15:35:36 -06:00
parent 8829a408ec
commit d2d9080d4c
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -78,6 +78,13 @@ defmodule Pleroma.Web.RichMedia.Helpers do
def fetch_data_for_activity(_), do: %{}
# YouTube's oEmbed implementation is broken, requiring this hack.
# https://github.com/oscarotero/Embed/issues/417#issuecomment-746673027
def rich_media_get("http://www.youtube.com/oembed?" <> params) do
# Use HTTPS explicitly, even though YouTube returns HTTP
rich_media_get("https://www.youtube.com/oembed?#{params}")
end
def rich_media_get(url) do
headers = [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]