Compare commits

...

2 Commits

Author SHA1 Message Date
Alex Gleason
36a5ff7803
Move YouTube oembed hack to oembed parser 2021-02-23 09:50:02 -06:00
Alex Gleason
d2d9080d4c
Fix YouTube embeds by rewriting http to https 2021-02-20 15:45:23 -06:00

View File

@ -21,6 +21,13 @@ defmodule Pleroma.Web.RichMedia.Parsers.OEmbed do
Enum.find_value(attributes, fn {k, v} -> if k == "href", do: v end) Enum.find_value(attributes, fn {k, v} -> if k == "href", do: v end)
end end
# YouTube's oEmbed implementation is broken, requiring this hack.
# https://github.com/oscarotero/Embed/issues/417#issuecomment-746673027
defp get_oembed_data("http://www.youtube.com/oembed?" <> params) do
# Use HTTPS explicitly, even though YouTube returns HTTP
get_oembed_data("https://www.youtube.com/oembed?#{params}")
end
defp get_oembed_data(url) do defp get_oembed_data(url) do
with {:ok, %Tesla.Env{body: json}} <- Pleroma.Web.RichMedia.Helpers.rich_media_get(url) do with {:ok, %Tesla.Env{body: json}} <- Pleroma.Web.RichMedia.Helpers.rich_media_get(url) do
Jason.decode(json) Jason.decode(json)