diff --git a/Cargo.lock b/Cargo.lock index b2dd772..045115c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -269,33 +269,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "cringecast" -version = "0.1.6" -dependencies = [ - "chrono", - "clap", - "dirs", - "futures", - "futures-util", - "id3", - "indicatif", - "mime_guess", - "opml", - "quick-xml 0.31.0", - "quickxml_to_serde", - "regex", - "reqwest", - "rss", - "serde", - "serde_json", - "strum", - "strum_macros", - "tokio", - "toml", - "unicode-width", -] - [[package]] name = "darling" version = "0.14.4" @@ -1537,6 +1510,34 @@ dependencies = [ "libc", ] +[[package]] +name = "talecast" +version = "0.1.7" +dependencies = [ + "chrono", + "clap", + "dirs", + "futures", + "futures-util", + "id3", + "indicatif", + "mime_guess", + "opml", + "quick-xml 0.31.0", + "quickxml_to_serde", + "regex", + "reqwest", + "rss", + "serde", + "serde_json", + "strum", + "strum_macros", + "tokio", + "toml", + "unicode-width", + "uuid", +] + [[package]] name = "tempfile" version = "3.10.1" @@ -1760,6 +1761,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index d1b8101..174a3ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "cringecast" -version = "0.1.6" +name = "talecast" +version = "0.1.7" edition = "2021" description = "Simple CLI podcatcher" license = "MIT" @@ -30,4 +30,5 @@ quick-xml = "0.31.0" quickxml_to_serde = "0.6.0" strum = "0.21" strum_macros = "0.21" +uuid = "1.8.0" diff --git a/README.md b/README.md index e74b0c4..eefa341 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# CringeCast +# TaleCast Simple CLI podcatcher. -https://github.com/TBS1996/CringeCast/assets/56874491/ca3b08e0-b509-44a2-a214-5b7c20a0f609 +https://github.com/TBS1996/TaleCast/assets/56874491/ca3b08e0-b509-44a2-a214-5b7c20a0f609 ## why? @@ -21,15 +21,15 @@ I dislike databases for simple terminal programs. Other programs tend to use a d ## how to install? -you gotta have rust installed atm. You can do `cargo install cringecast` or clone the repo and run it. +you gotta have rust installed atm. You can do `cargo install talecast` or clone the repo and run it. ## how to configure it? the global config is located in: -`~/.config/cringecast/config.toml` +`~/.config/talecast/config.toml` you put your podcasts in this file: -~/.config/cringecast/podcasts.toml` +~/.config/talecast/podcasts.toml` example podcasts.toml: @@ -98,10 +98,3 @@ path="/foo/bar/baz" delete or modify the `.downloaded` file in the folder where the episodes are downloaded. -## why the name? - -'broadcast' in norwegian means kringkasting. I thought the "kasting" sounds the 'cast' in 'podcast'. while the 'kring' part sounds like cringe. so, cringecast. pretty dumb i know. - - - - diff --git a/src/main.rs b/src/main.rs index a8fb300..2ff97fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ mod podcast; mod tags; mod utils; -pub const APPNAME: &'static str = "cringecast"; +pub const APPNAME: &'static str = "talecast"; #[derive(Parser)] #[command(version, about, long_about = None)] diff --git a/src/opml.rs b/src/opml.rs index 23c7639..316e662 100644 --- a/src/opml.rs +++ b/src/opml.rs @@ -8,7 +8,7 @@ pub async fn export(p: &Path, config_path: &Path, filter: Option<®ex::Regex>) let mut opml = OPML { head: Some(Head { - title: Some("Cringecast Podcast Feeds".to_string()), + title: Some("TaleCast Podcast Feeds".to_string()), date_created: Some(chrono::Utc::now().to_rfc2822()), ..Head::default() }), diff --git a/src/patterns.rs b/src/patterns.rs index 9913aa4..46392ab 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -6,55 +6,6 @@ use crate::podcast::Podcast; use regex::Regex; -#[derive(PartialEq)] -pub enum SourceType { - Episode, - Podcast, - Id3, -} - -impl SourceType { - pub fn all() -> Vec { - vec![Self::Episode, Self::Podcast, Self::Id3] - } -} - -#[derive(Default, Clone, Copy)] -pub struct DataSources<'a> { - id3: Option<&'a id3::Tag>, - episode: Option<&'a Episode<'a>>, - podcast: Option<&'a Podcast>, -} - -impl<'a> DataSources<'a> { - fn id3(&self) -> &'a id3::Tag { - self.id3.unwrap() - } - - fn episode(&self) -> &'a Episode<'a> { - self.episode.unwrap() - } - - fn podcast(&self) -> &'a Podcast { - self.podcast.unwrap() - } - - pub fn set_episode(mut self, episode: &'a Episode<'a>) -> Self { - self.episode = Some(episode); - self - } - - pub fn set_podcast(mut self, podcast: &'a Podcast) -> Self { - self.podcast = Some(podcast); - self - } - - pub fn set_id3(mut self, id3: &'a id3::Tag) -> Self { - self.id3 = Some(id3); - self - } -} - #[derive(Debug, Clone)] pub struct FullPattern(Vec); @@ -69,11 +20,17 @@ impl FullPattern { for c in s.chars() { if c == '}' { assert!(is_inside); - let pattern = std::mem::take(&mut pattern); - let pattern = Pattern::from_str(&pattern).unwrap(); + let text_pattern = std::mem::take(&mut pattern); + let pattern = Pattern::from_str(&text_pattern); if let Some(required_source) = pattern.required_source() { if !available_sources.contains(&required_source) { - panic!("invalid tag"); + eprintln!("CONFIGURATION ERROR"); + eprintln!( + "invalid pattern: {}\n{:?} requires the \"{:?}\"-source which is not available for this configuration setting.", + s, text_pattern, required_source + ); + + std::process::exit(1); } } let segment = Segment::Pattern(pattern); @@ -109,6 +66,55 @@ enum Segment { Pattern(Pattern), } +#[derive(PartialEq, Debug)] +pub enum SourceType { + Episode, + Podcast, + Id3, +} + +impl SourceType { + pub fn all() -> Vec { + vec![Self::Episode, Self::Podcast, Self::Id3] + } +} + +#[derive(Default, Clone, Copy)] +pub struct DataSources<'a> { + id3: Option<&'a id3::Tag>, + episode: Option<&'a Episode<'a>>, + podcast: Option<&'a Podcast>, +} + +impl<'a> DataSources<'a> { + fn id3(&self) -> &'a id3::Tag { + self.id3.unwrap() + } + + fn episode(&self) -> &'a Episode<'a> { + self.episode.unwrap() + } + + fn podcast(&self) -> &'a Podcast { + self.podcast.unwrap() + } + + pub fn set_episode(mut self, episode: &'a Episode<'a>) -> Self { + self.episode = Some(episode); + self + } + + pub fn set_podcast(mut self, podcast: &'a Podcast) -> Self { + self.podcast = Some(podcast); + self + } + + pub fn set_id3(mut self, id3: &'a id3::Tag) -> Self { + self.id3 = Some(id3); + self + } +} + #[derive(Debug, Clone)] enum Pattern { Unit(UnitPattern), @@ -116,13 +122,14 @@ enum Pattern { } impl Pattern { - fn from_str(s: &str) -> Option { + fn from_str(s: &str) -> Self { if let Some(unit) = UnitPattern::from_str(s) { - Some(Self::Unit(unit)) + Self::Unit(unit) } else if let Some(data) = DataPattern::from_str(s) { - Some(Self::Data(data)) + Self::Data(data) } else { - None + eprintln!("invalid pattern: \"{}\"", s); + std::process::exit(1); } } diff --git a/src/utils.rs b/src/utils.rs index d0baaf9..75c769d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -55,7 +55,7 @@ pub fn tutorial() -> &'static str { # Get started 1. find a podcast you like, for example from `https://podcastindex.org`. -2. click 'copy rss'. Then open or create the `podcasts.toml` file in your `~/.config/cringecast/` directory. +2. click 'copy rss'. Then open or create the `podcasts.toml` file in your `~/.config/talecast/` directory. 3. format it as so: [podcast_name]