first draft of new version
This commit is contained in:
12
src/lib.rs
12
src/lib.rs
@@ -18,12 +18,13 @@ impl Feed {
|
|||||||
|
|
||||||
pub async fn fetch(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn fetch(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let broadcasts = get_all_broadcasts().await?;
|
let broadcasts = get_all_broadcasts().await?;
|
||||||
println!("hea");
|
|
||||||
|
|
||||||
for broadcast in broadcasts {
|
for broadcast in broadcasts {
|
||||||
if !self.has_broadcast_url(&broadcast) {
|
if !self.has_broadcast_url(&broadcast) {
|
||||||
if let Ok(Some(broadcast)) = Broadcast::from(broadcast).await {
|
if let Some(broadcast) = Broadcast::from(broadcast).await.unwrap() {
|
||||||
self.episodes.push(broadcast);
|
self.episodes.push(broadcast);
|
||||||
|
} else {
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,8 +80,11 @@ async fn get_all_broadcasts() -> Result<Vec<String>, Box<dyn std::error::Error>>
|
|||||||
for day in days {
|
for day in days {
|
||||||
if let Some(broadcasts) = day["broadcasts"].as_array() {
|
if let Some(broadcasts) = day["broadcasts"].as_array() {
|
||||||
for broadcast in broadcasts {
|
for broadcast in broadcasts {
|
||||||
// if broadcast["title"] in [];
|
if ["Ö1 Morgenjournal", "Ö1 Mittagsjournal", "Ö1 Abendjournal"]
|
||||||
ret.push(broadcast["href"].to_string());
|
.contains(&broadcast["title"].as_str().unwrap())
|
||||||
|
{
|
||||||
|
ret.push(broadcast["href"].as_str().unwrap().into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user