diff --git a/.gitignore b/.gitignore index ea8c4bf..4d4c33a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target +result +default.nix diff --git a/Cargo.lock b/Cargo.lock index acd09f6..830a259 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cringecast" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 53cfd69..bb346e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cringecast" -version = "0.1.1" +version = "0.1.2" edition = "2021" description = "Simple podcast manager for your terminal" license = "MIT" diff --git a/default.nix b/default.nix index a8dff00..b3b090e 100644 --- a/default.nix +++ b/default.nix @@ -2,16 +2,17 @@ pkgs.rustPlatform.buildRustPackage rec { pname = "cringecast"; - version = "0.1.0"; + version = "0.1.1"; src = fetchFromGitHub { owner = "tbs1996"; repo = pname; - rev = "117b01c6f6d723d930290aef7d73f24edee19247"; - sha256 = "0000000000000000000000000000000000000000000000000000"; + rev = "ce1bfc8cfb5b63f4acfbcf801fc363fd39dbc650"; + sha256 = "vG1f+gJMaRaLEyNrjJFbztOGFaHgvjXN4NJ0Izh8eD0="; }; - cargoSha256 = "0000000000000000000000000000000000000000000000000000"; + cargoSha256 = "kdgjp1soGEreMiR+f1Wcc27vCQCuKbmqAojKj6s7qxA="; + buildInputs = [ pkgs.openssl pkgs.pkg-config ]; @@ -19,7 +20,7 @@ pkgs.rustPlatform.buildRustPackage rec { description = "simple cli podcast manager"; homepage = "https://github.com/tbs1996/cringecast"; license = licenses.mit; - maintainers = with maintainers; [ maintainers. ]; + maintainers = with maintainers; [ maintainers.tbs1996 ]; }; } diff --git a/src/main.rs b/src/main.rs index a8f31ae..a0e6afd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,12 +13,13 @@ mod config; fn main() -> Result<()> { let global_config = Arc::new(GlobalConfig::load()?); - let podcasts = Podcast::load_all(global_config)?; - for podcast in podcasts { + for podcast in Podcast::load_all(global_config)? { podcast.sync()?; } + println!("Syncing finished."); + Ok(()) } @@ -125,10 +126,10 @@ impl Podcast { } fn should_download(&self, episode: &Episode) -> bool { - self.downloaded.contains_episode(episode) + !(self.downloaded.contains_episode(episode) || self.config.max_age().is_some_and(|max_age| { - (chrono::Utc::now().timestamp() - episode.published) < max_age as i64 * 86400 - }) + (chrono::Utc::now().timestamp() - episode.published) > max_age as i64 * 86400 + })) } fn mark_downloaded(&self, episode: &Episode) -> Result<()> { @@ -153,12 +154,14 @@ impl Podcast { println!("downloading {} episodes!", episodes.len()); for episode in episodes { - println!("downloading {}", &episode.title); + println!("downloading: \"{}\"", &episode.title); episode.download(self.download_folder()?.as_path())?; self.mark_downloaded(&episode)?; } + println!("{} finished syncing.", &self.name); + Ok(()) } }