From cb1f7075688d6b059e3c7a92dda550603e9cae75 Mon Sep 17 00:00:00 2001 From: Ilia Pozdnyakov Date: Tue, 2 May 2023 14:10:07 +0600 Subject: [PATCH] implement XBLA title info fallback when querying unity --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/unity.rs | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc2fdf9..01b4f53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -661,7 +661,7 @@ dependencies = [ [[package]] name = "iso2god" -version = "1.4.4" +version = "1.4.5" dependencies = [ "anyhow", "bitflags 2.2.1", diff --git a/Cargo.toml b/Cargo.toml index b7a19ac..1e989ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iso2god" -version = "1.4.4" +version = "1.4.5" description = "A tool to convert between Xbox 360 ISO and Games On Demand file formats" repository = "https://github.com/iliazeus/iso2god-rs" edition = "2021" diff --git a/src/unity.rs b/src/unity.rs index 5771c96..0ca9af5 100644 --- a/src/unity.rs +++ b/src/unity.rs @@ -67,6 +67,9 @@ pub enum TitleType { #[serde(rename = "360")] Xbox360, + #[serde(rename = "XBLA")] + Xbla, + Xbox1, } @@ -75,6 +78,7 @@ impl fmt::Display for TitleType { match self { Self::Xbox => write!(f, "Xbox title"), Self::Xbox360 => write!(f, "Xbox 360 title"), + Self::Xbla => write!(f, "Xbox Live Arcade title"), Self::Xbox1 => write!(f, "Xbox One title"), } } @@ -128,11 +132,17 @@ impl Client { let title_list = self.search(&title_id)?; - let title = title_list + let best_title = title_list .items .into_iter() - .find(|title| title.title_type == TitleType::Xbox360 && title.title_id == title_id); - - Ok(title) + .filter(|t| t.title_id == title_id) + .filter(|t| t.title_type == TitleType::Xbox360 || t.title_type == TitleType::Xbla) + .min_by_key(|t| match t.title_type { + TitleType::Xbox360 => 0, + TitleType::Xbla => 1, + _ => 2, + }); + + Ok(best_title) } }