Fallback to RSS item content when article fetching fails
This commit is contained in:
parent
eaa463f2c0
commit
0ebaca4a83
|
@ -93,23 +93,27 @@ defmodule Frenzy.UpdateFeeds do
|
||||||
|
|
||||||
url = get_real_url(entry)
|
url = get_real_url(entry)
|
||||||
|
|
||||||
case get_article_content(url) do
|
content =
|
||||||
{:ok, content} ->
|
case get_article_content(url) do
|
||||||
changeset =
|
{:ok, content} ->
|
||||||
Ecto.build_assoc(feed, :items, %{
|
content
|
||||||
guid: entry.id,
|
|
||||||
title: entry.title,
|
|
||||||
url: url,
|
|
||||||
date: parse_date(entry.published_at),
|
|
||||||
creator: "",
|
|
||||||
content: content
|
|
||||||
})
|
|
||||||
|
|
||||||
Repo.insert(changeset)
|
{:err, reason} ->
|
||||||
|
Logger.warn("Unable to fetch article for #{url}: #{reason}")
|
||||||
|
entry.content || entry.summary
|
||||||
|
end
|
||||||
|
|
||||||
{:err, reason} ->
|
changeset =
|
||||||
Logger.error("Unable to create item for #{url}: #{reason}")
|
Ecto.build_assoc(feed, :items, %{
|
||||||
end
|
guid: entry.id,
|
||||||
|
title: entry.title,
|
||||||
|
url: url,
|
||||||
|
date: parse_date(entry.published_at),
|
||||||
|
creator: "",
|
||||||
|
content: content
|
||||||
|
})
|
||||||
|
|
||||||
|
Repo.insert(changeset)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp parse_date(str) do
|
defp parse_date(str) do
|
||||||
|
|
Loading…
Reference in New Issue