Compare commits
No commits in common. "04ffe0036dd568d1d9a441e590535edd58ce9157" and "5f3be5213254446c83672d1c6796d01c1d20ff6e" have entirely different histories.
04ffe0036d
...
5f3be52132
|
@ -18,17 +18,11 @@ defmodule Frenzy.Pipeline.Extractor.WhateverScalzi do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_article_content(html_tree) do
|
defp get_article_content(html_tree) do
|
||||||
# there's no element that contains only the post content
|
case Floki.find(html_tree, "article.post > div.entry-content") do
|
||||||
# .postarea contains the headline, post content, social media buttons, and comments
|
[content_elem | _] ->
|
||||||
with [{_tag, _attrs, postarea_children} | _] <- Floki.find(html_tree, ".postarea"),
|
# remove social media buttons that are included in the .entry-content element
|
||||||
{_before_headline, [_headline | rest]} <-
|
Floki.filter_out(content_elem, "div#jp-post-flair")
|
||||||
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
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,8 +25,7 @@ defmodule Frenzy.Task.FetchFavicon do
|
||||||
favicon_url =
|
favicon_url =
|
||||||
fetch_favicon_url_from_webpage(site_url) || URI.merge(site_url, "/favicon.ico")
|
fetch_favicon_url_from_webpage(site_url) || URI.merge(site_url, "/favicon.ico")
|
||||||
|
|
||||||
with true <- is_binary(favicon_url),
|
with %Feed{favicon_url: old_url} when old_url != favicon_url <- feed,
|
||||||
%Feed{favicon_url: old_url} when old_url != favicon_url <- feed,
|
|
||||||
{:ok, favicon_data} <- fetch_favicon_data(favicon_url) do
|
{:ok, favicon_data} <- fetch_favicon_data(favicon_url) do
|
||||||
changeset =
|
changeset =
|
||||||
Feed.changeset(feed, %{
|
Feed.changeset(feed, %{
|
||||||
|
|
Loading…
Reference in New Issue