ipod syncing; updated readme; rust 2024; version bump

This commit is contained in:
Aaron Manning
2025-09-21 09:07:18 +10:00
parent fcc6acda56
commit 19330e66c9
11 changed files with 419 additions and 82 deletions

View File

@@ -1,4 +1,5 @@
mod rss;
mod sync;
mod input;
mod manage;
mod folders;
@@ -34,8 +35,8 @@ fn main() -> anyhow::Result<()> {
Command::Download { podcast } => {
// Updating single podcast
if let Some(alias) = podcast {
if let Some(feed_url) = config.podcasts.get(&alias) {
download::update_podcast(&alias, root, feed_url)?;
if let Some(source) = config.podcasts.get(&alias) {
download::update_podcast(&alias, root, source)?;
}
else {
anyhow::bail!(r#"podcast "{}" not found in configuration file"#, alias)
@@ -43,14 +44,14 @@ fn main() -> anyhow::Result<()> {
}
// Updating all podcasts
else {
for (alias, feed_url) in config.podcasts {
download::update_podcast(&alias, root, &feed_url)?;
for (alias, source) in config.podcasts {
download::update_podcast(&alias, root, &source)?;
}
}
},
}
Command::List { status, podcast } => {
let output = folders::podcast_folder(root, &podcast);
let spec_file = output.join("spec.toml");
let spec_file = output.join(folders::SPEC_FILE);
let spec = manage::Specification::read_from(&spec_file)?;
@@ -63,10 +64,10 @@ fn main() -> anyhow::Result<()> {
}
}
}
},
}
Command::Mark { status, podcast } => {
let output = folders::podcast_folder(root, &podcast);
let spec_file = output.join("spec.toml");
let spec_file = output.join(folders::SPEC_FILE);
let mut spec = manage::Specification::read_from(&spec_file)?;
@@ -77,7 +78,7 @@ fn main() -> anyhow::Result<()> {
}
spec.write_to(&spec_file)?;
},
}
Command::Playlist { podcast } => {
if let Some(alias) = podcast {
playlist::generate_podcast_m3u(alias.as_str(), root, false)?;
@@ -89,7 +90,32 @@ fn main() -> anyhow::Result<()> {
}
playlist::generate_master_m3u(&config, root)?;
}
},
}
Command::Sync { ipod_dir, download } => {
// Sync listened podcasts
sync::sync_listened(
root,
&ipod_dir.join(folders::LOCAL_PLAYLISTS_DIR).join(folders::LISTENED_PLAYLIST_PATH),
true,
)?;
if download {
// Download all new episodes
for (alias, source) in &config.podcasts {
download::update_podcast(&alias, root, &source)?;
}
}
// Generate updated playlist files
for (alias, _) in &config.podcasts {
playlist::generate_podcast_m3u(alias.as_str(), root, true)?;
playlist::generate_podcast_m3u(alias.as_str(), root, false)?;
}
playlist::generate_master_m3u(&config, root)?;
// Sync podcasts and playlists
sync::sync(root, &config, &ipod_dir)?;
}
};
Ok(())