fixed some issue

This commit is contained in:
암냥 2026-01-09 10:02:11 +09:00
commit 66bd084070
No known key found for this signature in database
2 changed files with 16 additions and 4 deletions

View file

@ -16,7 +16,7 @@ pubDate = "published"
channel = "1448338163864174867"
tag = "1448338289147908108"
emoji = "💻"
rss = "https://svrforum.com/rss"
rss = "https://api.imnya.ng/svrforum/rss.xml"
category_filter = ["유머&정보"]
[svrforum.setup]

View file

@ -4,9 +4,21 @@ use htmd::HtmlToMarkdown;
use feed_rs::model::{Feed, Entry};
pub async fn fetch_feed(url: &str) -> Result<Feed> {
let content = reqwest::get(url).await?.bytes().await?;
let feed = feed_rs::parser::parse(&content[..])?;
Ok(feed)
let client = reqwest::Client::builder()
.user_agent("NekoRSS/1.0 (+abuse@imnya.ng)")
.build()?;
let resp = client.get(url).send().await?;
let status = resp.status();
let content = resp.bytes().await?;
match feed_rs::parser::parse(&content[..]) {
Ok(feed) => Ok(feed),
Err(e) => {
let body_preview = String::from_utf8_lossy(&content).chars().take(200).collect::<String>();
anyhow::bail!("Failed to parse feed (Status: {}): {} | Body preview: {}", status, e, body_preview);
}
}
}
pub fn get_field_value(