mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
feat: store games get their logo from the store
GOG (api.gog.com v2 `_links.logo`), Epic (catalog keyImage `DieselGameBoxLogo`) and Amazon (`productDetail.details.logoUrl`) logos are kept in the install record as an optional `logo` field and written next to the game as logo.png when the install finishes. The PNG is kept as it came, transparency included, and anything that does not decode as an image is dropped. Older install records without the field still read as before.
This commit is contained in:
1 parent
5970de928e
commit
8ceff5641a
15 files changed
+193
-12
No files matched your search
@@ -21,6 +21,7 @@ pub struct Game {
|
||||
pub parent_product_id: String,
|
||||
pub art: String,
|
||||
pub hero: String,
|
||||
pub logo: String,
|
||||
pub developer: String,
|
||||
pub publisher: String,
|
||||
}
|
||||
@@ -39,6 +40,7 @@ impl Game {
|
||||
"sku": self.sku,
|
||||
"art": self.art,
|
||||
"hero": self.hero,
|
||||
"logo": self.logo,
|
||||
"developer": self.developer,
|
||||
"publisher": self.publisher,
|
||||
"dlc": self.is_dlc(),
|
||||
@@ -83,6 +85,7 @@ pub fn read_entitlement(e: &Value) -> Option<Game> {
|
||||
],
|
||||
)
|
||||
.to_string(),
|
||||
logo: str_at(product, &["productDetail", "details", "logoUrl"]).to_string(),
|
||||
developer: str_at(product, &["productDetail", "details", "developer"]).to_string(),
|
||||
publisher: str_at(product, &["productDetail", "details", "publisher"]).to_string(),
|
||||
})
|
||||
@@ -178,17 +181,20 @@ mod tests {
|
||||
fn entitlement_fields_and_fallbacks() {
|
||||
let e = json!({"id":"ent-1","product":{"id":"amzn1.adg.product.x","title":"Game","sku":"SKU1",
|
||||
"productDetail":{"iconUrl":"","details":{"pgCrownImageUrl":"crown","backgroundUrl1":"bg1",
|
||||
"developer":"Dev","publisher":"Pub","productType":"GAME"}}}});
|
||||
"logoUrl":"logo","developer":"Dev","publisher":"Pub","productType":"GAME"}}}});
|
||||
let g = read_entitlement(&e).unwrap();
|
||||
assert_eq!(g.entitlement_id, "ent-1");
|
||||
assert_eq!(g.art, "crown");
|
||||
assert_eq!(g.hero, "bg1");
|
||||
assert_eq!(g.logo, "logo");
|
||||
assert_eq!(g.to_json()["logo"], "logo");
|
||||
assert_eq!(g.product_type, "GAME");
|
||||
assert!(!g.is_dlc());
|
||||
let untitled = read_entitlement(&json!({"product":{"id":"p","type":"DLC","baseProductId":"q"}})).unwrap();
|
||||
assert_eq!(untitled.title, "Unknown");
|
||||
assert_eq!(untitled.entitlement_id, "");
|
||||
assert_eq!(untitled.parent_product_id, "q");
|
||||
assert_eq!(untitled.logo, "");
|
||||
assert!(untitled.is_dlc());
|
||||
assert!(read_entitlement(&json!({"id":"x"})).is_none());
|
||||
assert!(read_entitlement(&json!({"id":"x","product":{"id":""}})).is_none());
|
||||
|
||||
@@ -71,6 +71,7 @@ pub fn details_of(entry: &Value) -> Value {
|
||||
"releaseDate": release,
|
||||
"tall": image(entry, &["DieselGameBoxTall"]),
|
||||
"wide": image(entry, &["DieselGameBox", "Thumbnail"]),
|
||||
"logo": image(entry, &["DieselGameBoxLogo"]),
|
||||
"canRunOffline": offline,
|
||||
"dlc": main_game.is_some_and(|m| !m.is_null()),
|
||||
"mainGameId": main_game.map(|m| net::str_of(m, "id")).unwrap_or(""),
|
||||
@@ -102,7 +103,8 @@ mod tests {
|
||||
"keyImages": [
|
||||
{"type": "Thumbnail", "url": "thumb"},
|
||||
{"type": "DieselGameBox", "url": ""},
|
||||
{"type": "DieselGameBoxTall", "url": "tall"}
|
||||
{"type": "DieselGameBoxTall", "url": "tall"},
|
||||
{"type": "DieselGameBoxLogo", "url": "logo"}
|
||||
],
|
||||
"customAttributes": {"CanRunOffline": {"value": "FALSE"}, "publisherName": {"value": " Pub "}},
|
||||
"seller": {"name": "Seller"},
|
||||
@@ -113,6 +115,7 @@ mod tests {
|
||||
assert_eq!(d["title"], "Game");
|
||||
assert_eq!(d["tall"], "tall");
|
||||
assert_eq!(d["wide"], "thumb");
|
||||
assert_eq!(d["logo"], "logo");
|
||||
assert_eq!(d["publisher"], "Pub");
|
||||
assert_eq!(d["canRunOffline"], false);
|
||||
assert_eq!(d["releaseDate"], "2020-01-01T00:00:00.000Z");
|
||||
@@ -123,6 +126,7 @@ mod tests {
|
||||
assert_eq!(dlc["publisher"], "S");
|
||||
assert_eq!(dlc["releaseDate"], "v");
|
||||
assert_eq!(dlc["canRunOffline"], true);
|
||||
assert_eq!(dlc["logo"], "");
|
||||
assert_eq!(pick_entry(&json!({"x": {"title": "Only"}}), "y").unwrap()["title"], "Only");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user