Move YouTube oembed hack to oembed parser
This commit is contained in:
parent
d2d9080d4c
commit
36a5ff7803
@ -78,13 +78,6 @@ defmodule Pleroma.Web.RichMedia.Helpers do
|
|||||||
|
|
||||||
def fetch_data_for_activity(_), 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
|
def rich_media_get(url) do
|
||||||
headers = [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]
|
headers = [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user