Compare commits

...

2 Commits

Author SHA1 Message Date
Shadowfacts 04ffe0036d
Fix feed update failing on missing favicon 2020-08-14 21:56:38 -04:00
Shadowfacts bd42073e24
Fix whatever.scalzi.com extractor 2020-08-14 21:55:38 -04:00
2 changed files with 13 additions and 6 deletions

View File

@ -18,11 +18,17 @@ defmodule Frenzy.Pipeline.Extractor.WhateverScalzi do
end
defp get_article_content(html_tree) do
case Floki.find(html_tree, "article.post > div.entry-content") do
[content_elem | _] ->
# remove social media buttons that are included in the .entry-content element
Floki.filter_out(content_elem, "div#jp-post-flair")
# there's no element that contains only the post content
# .postarea contains the headline, post content, social media buttons, and comments
with [{_tag, _attrs, postarea_children} | _] <- Floki.find(html_tree, ".postarea"),
{_before_headline, [_headline | rest]} <-
Enum.split_while(postarea_children, fn {tag, _attrs, _children} -> tag != "h1" end),
{article_content, _rest} <-
Enum.split_while(rest, fn {tag, attrs, _children} ->
tag != "div" || !({"id", "jp-post-flair"} in attrs)
end) do
article_content
else
_ ->
nil
end

View File

@ -25,7 +25,8 @@ defmodule Frenzy.Task.FetchFavicon do
favicon_url =
fetch_favicon_url_from_webpage(site_url) || URI.merge(site_url, "/favicon.ico")
with %Feed{favicon_url: old_url} when old_url != favicon_url <- feed,
with true <- is_binary(favicon_url),
%Feed{favicon_url: old_url} when old_url != favicon_url <- feed,
{:ok, favicon_data} <- fetch_favicon_data(favicon_url) do
changeset =
Feed.changeset(feed, %{