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)
|
||||
|
||||
case get_article_content(url) do
|
||||
{:ok, content} ->
|
||||
changeset =
|
||||
Ecto.build_assoc(feed, :items, %{
|
||||
guid: entry.id,
|
||||
title: entry.title,
|
||||
url: url,
|
||||
date: parse_date(entry.published_at),
|
||||
creator: "",
|
||||
content: content
|
||||
})
|
||||
content =
|
||||
case get_article_content(url) do
|
||||
{:ok, content} ->
|
||||
content
|
||||
|
||||
Repo.insert(changeset)
|
||||
{:err, reason} ->
|
||||
Logger.warn("Unable to fetch article for #{url}: #{reason}")
|
||||
entry.content || entry.summary
|
||||
end
|
||||
|
||||
{:err, reason} ->
|
||||
Logger.error("Unable to create item for #{url}: #{reason}")
|
||||
end
|
||||
changeset =
|
||||
Ecto.build_assoc(feed, :items, %{
|
||||
guid: entry.id,
|
||||
title: entry.title,
|
||||
url: url,
|
||||
date: parse_date(entry.published_at),
|
||||
creator: "",
|
||||
content: content
|
||||
})
|
||||
|
||||
Repo.insert(changeset)
|
||||
end
|
||||
|
||||
defp parse_date(str) do
|
||||
|
|
Loading…
Reference in New Issue