diff --git a/CHANGELOG.md b/CHANGELOG.md index ae80029..8f87e2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- A feed whose own artwork is missing shows its website's icon instead of nothing. - The log has no terminal colour codes when it is not going to a terminal, as in `docker logs`. - A feed whose website names an icon that is missing shows the site's `/favicon.ico` instead of no artwork. diff --git a/src/feed.rs b/src/feed.rs index 5fa2ba0..c23ed57 100644 --- a/src/feed.rs +++ b/src/feed.rs @@ -385,19 +385,19 @@ pub async fn site_icon(client: &reqwest::Client, site: &str) -> Option { && let Ok(page) = resp.bytes().await && let Some(href) = page_icon(&page) && let Ok(url) = base.join(&href) - && is_image(client, &url).await + && is_image(client, url.as_str()).await { return Some(url.into()); } let ico = base.join("/favicon.ico").ok()?; - is_image(client, &ico).await.then(|| ico.into()) + is_image(client, ico.as_str()).await.then(|| ico.into()) } /// Whether `url` answers with an image. A site with no favicon often answers 200 with its home /// page, which is not an icon. -async fn is_image(client: &reqwest::Client, url: &reqwest::Url) -> bool { +pub async fn is_image(client: &reqwest::Client, url: &str) -> bool { let timeout = std::time::Duration::from_secs(20); - let Ok(resp) = client.get(url.clone()).timeout(timeout).send().await else { return false }; + let Ok(resp) = client.get(url).timeout(timeout).send().await else { return false }; resp.status().is_success() && resp .headers() diff --git a/src/main.rs b/src/main.rs index a539754..c0df746 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1258,6 +1258,14 @@ async fn scan_one( // is stored as "", which the page draws as no art, and which stops the refetch above. // ponytail: a feed without validators is read in full every scan and asks its site each // time too; keep a checked-at time per feed if that shows up in anyone's logs. + // A feed's own artwork has to be there too: Ken and Robin's names a 404, and stored unasked + // it stood in the way of the site's icon, which works (#89). + if let Some(art) = &parsed.image + && !feed::is_image(&ctx.client, art).await + { + tracing::info!(feed = id, art = %art, "the feed's artwork is not an image; trying its site's icon"); + parsed.image = None; + } if parsed.image.is_none() { parsed.image = Some(match &parsed.site { Some(site) => feed::site_icon(&ctx.client, site).await.unwrap_or_default(),