Skip to content

Commit

Permalink
fix: skip releases with no downloads
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
Ovyerus committed Aug 6, 2024
1 parent d86a356 commit 2be782e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Skip over releases that don't have any downloads.

## [0.3.2] - 2024-07-16

### Fixed
Expand Down
8 changes: 7 additions & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,13 @@ impl Api {
audio_format: &str,
m: &indicatif::MultiProgress,
) -> Result<(), Box<dyn Error>> {
let download_url = &item.downloads.get(audio_format).unwrap().url;
let download_url = &item
.downloads
.as_ref()
.expect("cannot download a release with no downloads")
.get(audio_format)
.unwrap()
.url;
let res = self.request(Method::GET, download_url)?;

let len = res.content_length().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/api/structs/digital_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const FORMAT: &str = "%d %b %Y %T %Z";

#[derive(Clone, Deserialize, Debug)]
pub struct DigitalItem {
pub downloads: HashMap<String, DigitalItemDownload>,
pub downloads: Option<HashMap<String, DigitalItemDownload>>,
pub package_release_date: Option<String>,
pub title: String,
pub artist: String,
Expand Down
8 changes: 7 additions & 1 deletion src/cmds/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,20 @@ pub fn command(
Ok(Some(item)) => item,
Ok(None) => {
let cache = cache.lock().unwrap();
// warn that item doesnt exist
warn!("Could not find digital item for {id}");
skip_err!(cache.add(&id, "UNKNOWN"));
continue;
}
Err(_) => continue,
};

if let None = item.downloads {
let cache = cache.lock().unwrap();
warn!("Skipping {id}, does not have any downloads");
skip_err!(cache.add(&id, "No downloads"));
continue;
}

if dry_run {
let results_lock = dry_run_results.lock();
if let Ok(mut results) = results_lock {
Expand Down

0 comments on commit 2be782e

Please sign in to comment.