From 0b6cedb6583fc76267ad489c5aaef1e62d1cdcd5 Mon Sep 17 00:00:00 2001 From: Felipe M Date: Thu, 14 Jan 2021 23:07:50 +0100 Subject: [PATCH] retroarch: Download covers from libretro --- README.md | 2 +- pkg/providers/retroarch/retroarch.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index edb7432..06d7521 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Use the appropriate ID with the `-provider` flag. [See examples below](#Usage) | Minecraft | `minecraft` | Linux, Linux Flatpak, macOS, Windows | No | | Nintendo Switch | `nintendo-switch` | Requires `-input-path` | No | | PlayStation 4 | `playstation-4` | Requires `-input-path` | No | -| RetroArch | `retroarch` | Requires `-input-path` | No | +| RetroArch | `retroarch` | Requires `-input-path` | Yes | ## How it works diff --git a/pkg/providers/retroarch/retroarch.go b/pkg/providers/retroarch/retroarch.go index 0d2e72b..ddb78ec 100644 --- a/pkg/providers/retroarch/retroarch.go +++ b/pkg/providers/retroarch/retroarch.go @@ -154,11 +154,24 @@ func GetGames(inputPath string, downloadCovers bool) []games.Game { for playlistName := range playlists { for _, item := range playlists[playlistName].Items { + var cover games.Screenshot + + if downloadCovers { + coverURL := formatLibretroBoxartURL(playlistName, item.Label) + boxartPath, err := helpers.DownloadURLIntoTempFile(coverURL) + if err == nil { + cover = games.Screenshot{Path: boxartPath, DestinationName: ".cover"} + } else { + log.Printf("[error] Error downloading cover for %s: %s", item.Label, err) + } + } + userGames = append(userGames, games.Game{ Platform: cleanPlatformName(playlistName), Name: cleanGameName(item.Label), Provider: providerName, Screenshots: findScreenshotsForGame(item), + Cover: cover, }) } }