Support atom feeds too
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -2,12 +2,14 @@ use anyhow::{
|
||||
Context,
|
||||
Result,
|
||||
};
|
||||
use rss::Channel;
|
||||
use feed_rs::{
|
||||
parser::parse,
|
||||
model::Feed,
|
||||
};
|
||||
|
||||
fn fetch_feed() -> Result<Channel> {
|
||||
let content = reqwest::blocking::get("https://feed.zugfunk-podcast.de/")?.bytes()?;
|
||||
let channel = Channel::read_from(&content[..])?;
|
||||
Ok(channel)
|
||||
fn fetch_feed() -> Result<Feed> {
|
||||
let content = reqwest::blocking::get("https://www.youtube.com/feeds/videos.xml?channel_id=UC0intLFzLaudFG-xAvUEO-A")?.bytes()?;
|
||||
Ok(parse(&content[..])?)
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -23,8 +25,8 @@ fn main() -> Result<()> {
|
||||
|
||||
out.push_str("<ul>\n");
|
||||
|
||||
for item in feed.items {
|
||||
out.push_str(&format!("<li><a href=\"{}\">{}</a></li>\n", item.link.context("No link found")?, item.title.context("No title found")?));
|
||||
for item in feed.entries {
|
||||
out.push_str(&format!("<li><a href=\"{}\">{}</a></li>\n", item.links.first().context("No link found")?.href, item.title.context("No title found")?.content));
|
||||
}
|
||||
|
||||
out.push_str("</ul>\n");
|
||||
|
Reference in New Issue
Block a user