Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
TBS1996 committed Mar 26, 2024
1 parent ce1bfc8 commit 3429b7a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
result
default.nix
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
11 changes: 6 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

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 ];

meta = with pkgs.lib; {
description = "simple cli podcast manager";
homepage = "https://github.com/tbs1996/cringecast";
license = licenses.mit;
maintainers = with maintainers; [ maintainers.<your-nixpkgs-username> ];
maintainers = with maintainers; [ maintainers.tbs1996 ];
};
}

15 changes: 9 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down Expand Up @@ -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<()> {
Expand All @@ -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(())
}
}
Expand Down

0 comments on commit 3429b7a

Please sign in to comment.