akkoma/lib/pleroma/web/rich_media/parser.ex

15 lines
393 B
Elixir
Raw Normal View History

2019-01-01 20:26:40 +00:00
defmodule Pleroma.Web.RichMedia.Parser do
@parsers [Pleroma.Web.RichMedia.Parsers.OGP]
def parse(url) do
{:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url)
Enum.reduce_while(@parsers, %Pleroma.Web.RichMedia.Data{}, fn parser, acc ->
case parser.parse(html, acc) do
{:ok, data} -> {:halt, data}
{:error, _msg} -> {:cont, acc}
end
end)
end
end