Fallback to RSS item content when article fetching fails

This commit is contained in:
Shadowfacts 2019-03-10 19:44:31 -04:00
parent eaa463f2c0
commit 0ebaca4a83
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 19 additions and 15 deletions

View File

@ -93,8 +93,16 @@ defmodule Frenzy.UpdateFeeds do
url = get_real_url(entry) url = get_real_url(entry)
content =
case get_article_content(url) do case get_article_content(url) do
{:ok, content} -> {:ok, content} ->
content
{:err, reason} ->
Logger.warn("Unable to fetch article for #{url}: #{reason}")
entry.content || entry.summary
end
changeset = changeset =
Ecto.build_assoc(feed, :items, %{ Ecto.build_assoc(feed, :items, %{
guid: entry.id, guid: entry.id,
@ -106,10 +114,6 @@ defmodule Frenzy.UpdateFeeds do
}) })
Repo.insert(changeset) Repo.insert(changeset)
{:err, reason} ->
Logger.error("Unable to create item for #{url}: #{reason}")
end
end end
defp parse_date(str) do defp parse_date(str) do