| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
use chrono::prelude::*; |
| 21 |
use url::Url; |
| 22 |
|
| 23 |
pub(crate) type UrlString = String; |
| 24 |
|
| 25 |
#[derive(Clone, Debug)] |
| 26 |
pub struct FoundPodcast { |
| 27 |
pub feed: UrlString, |
| 28 |
pub title: String, |
| 29 |
pub author: String, |
| 30 |
pub description: String, |
| 31 |
pub art: UrlString, |
| 32 |
pub episode_count: Option<i32>, |
| 33 |
pub last_publication: Option<DateTime<Local>>, |
| 34 |
} |
| 35 |
|
| 36 |
impl PartialEq for FoundPodcast { |
| 37 |
fn eq(&self, other: &Self) -> bool { |
| 38 |
let a = Url::parse(&self.feed); |
| 39 |
let b = Url::parse(&other.feed); |
| 40 |
|
| 41 |
if let (Ok(a), Ok(b)) = (a, b) { |
| 42 |
a.path().trim_end_matches('/') == b.path().trim_end_matches('/') |
| 43 |
&& a.host() == b.host() |
| 44 |
&& a.query() == b.query() |
| 45 |
} else { |
| 46 |
self.feed == other.feed |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
impl FoundPodcast { |
| 52 |
|
| 53 |
pub(crate) fn combine(&mut self, other: FoundPodcast) { |
| 54 |
if other.episode_count.unwrap_or_default() > self.episode_count.unwrap_or_default() { |
| 55 |
self.episode_count = other.episode_count; |
| 56 |
} |
| 57 |
if other.description.len() > self.description.len() { |
| 58 |
self.description = other.description; |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
pub const ALL_PLATFORM_IDS: [&str; 2] = ["fyyd.de", "itunes.apple.com"]; |