XIHPYOWDLQY2MVMVUQPH23O3TBALRG4G2CHSLWSCAYMY5NVJ32WQC
/target/
**/*.rs.bk
[package]
name = "podcast"
version = "0.1.0"
authors = ["njaremko <njaremko@gmail.com>"]
[dependencies]
rss = "0.7"
use std::fs::File;
use std::io::BufReader;
use rss::{Channel, Item};
pub struct Podcast(Channel);
pub struct Episode(Item);
impl From<Channel> for Podcast {
fn from(channel: Channel) -> Podcast {
Podcast(channel)
}
}
impl From<Item> for Episode {
fn from(item: Item) -> Episode {
Episode(item)
}
}
impl Podcast {
pub fn episodes(&self) -> Vec<Episode> {
let mut result = Vec::new();
let items = self.0.items().to_vec();
for item in items {
result.push(Episode::from(item));
}
result
}
pub fn list_titles(&self) -> Vec<&str> {
let mut result = Vec::new();
let items = self.0.items();
for item in items {
match item.title() {
Some(val) => result.push(val),
None => (),
}
}
result
}
}
impl Episode {
pub fn download_url(&self) -> Option<&str> {
match self.0.enclosure() {
Some(val) => Some(val.url()),
None => None,
}
}
}
extern crate rss;
mod structs;
use std::fs::File;
use std::io::BufReader;
use rss::{Channel, Item};
use structs::*;
fn main() {
let file = File::open("rss.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
let podcast = Podcast::from(channel);
for title in podcast.list_titles() {
println!("{}", title);
}
let ep = &podcast.episodes()[0];
println!(
"{}",
match ep.download_url() {
Some(val) => val,
None => "",
}
);
}
extern crate rss;
mod structs;
use std::fs::File;
use std::io::BufReader;
use rss::{Channel, Item};
use structs::*;
fn main() {
let file = File::open("rss.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
let podcast = Podcast::from(channel);
for title in podcast.list_titles() {
println!("{}", title);
}
let ep = &podcast.episodes()[0];
println!(
"{}",
match ep.download_url() {
Some(val) => val,
None => "",
}
);
}
use std::fs::File;
use std::io::BufReader;
use rss::{Channel, Item};
pub struct Podcast(Channel);
pub struct Episode(Item);
impl From<Channel> for Podcast {
fn from(channel: Channel) -> Podcast {
Podcast(channel)
}
}
impl From<Item> for Episode {
fn from(item: Item) -> Episode {
Episode(item)
}
}
impl Podcast {
pub fn episodes(&self) -> Vec<Episode> {
let mut result = Vec::new();
let items = self.0.items().to_vec();
for item in items {
result.push(Episode::from(item));
}
result
}
pub fn list_titles(&self) -> Vec<&str> {
let mut result = Vec::new();
let items = self.0.items();
for item in items {
match item.title() {
Some(val) => result.push(val),
None => (),
}
}
result
}
}
impl Episode {
pub fn download_url(&self) -> Option<&str> {
match self.0.enclosure() {
Some(val) => Some(val.url()),
None => None,
}
}
}