[gnome-games/wip/exalm/steam] steam: Load new-style covers
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/steam] steam: Load new-style covers
- Date: Sat, 9 Nov 2019 09:44:23 +0000 (UTC)
commit d9cc4c587f84542889c66c6f4ab4291d87f888a4
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Nov 9 14:35:08 2019 +0500
steam: Load new-style covers
Steam supports 300x450/600x900 covers now. Try loading these first, then
fall back to the previously used header images.
plugins/steam/src/steam-cover.vala | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/plugins/steam/src/steam-cover.vala b/plugins/steam/src/steam-cover.vala
index 517db2a8..bf1c277c 100644
--- a/plugins/steam/src/steam-cover.vala
+++ b/plugins/steam/src/steam-cover.vala
@@ -1,6 +1,12 @@
// This file is part of GNOME Games. License: GPL-3.0+.
public class Games.SteamCover : Object, Cover {
+ private string[] URIS = {
+ "http://cdn.akamai.steamstatic.com/steam/apps/%s/library_600x900_2x.jpg",
+ "http://cdn.akamai.steamstatic.com/steam/apps/%s/library_600x900.jpg",
+ "http://cdn.akamai.steamstatic.com/steam/apps/%s/header.jpg"
+ };
+
private string game_id;
private GLib.Icon icon;
private bool resolving;
@@ -23,8 +29,7 @@ public class Games.SteamCover : Object, Cover {
resolving = true;
- var uri = @"http://cdn.akamai.steamstatic.com/steam/apps/$game_id/header.jpg";
- fetch_cover.begin (uri);
+ fetch_covers.begin ();
return null;
}
@@ -35,7 +40,14 @@ public class Games.SteamCover : Object, Cover {
return @"$dir/steam-$game_id.jpg";
}
- private async void fetch_cover (string uri) {
+ private async void fetch_covers () {
+ foreach (var uri in URIS) {
+ if (yield fetch_cover (uri.printf (game_id)))
+ break;
+ }
+ }
+
+ private async bool fetch_cover (string uri) {
var dir = Application.get_covers_dir ();
Application.try_make_dir (dir);
@@ -43,21 +55,27 @@ public class Games.SteamCover : Object, Cover {
var session = new Soup.Session ();
var message = new Soup.Message ("GET", uri);
+ var success = false;
session.queue_message (message, (sess, mess) => {
if (mess.status_code != Soup.Status.OK) {
debug ("Failed to load %s: %u %s.", uri, mess.status_code,
mess.reason_phrase);
-
+ fetch_cover.callback ();
return;
}
try {
FileUtils.set_data (cover_path, mess.response_body.data);
load_cover ();
+ success = true;
} catch (Error e) {
warning (e.message);
}
+
+ fetch_cover.callback ();
});
+ yield;
+ return success;
}
private void load_cover () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]