Skip to content

Commit

Permalink
Option to only download missing Artwork
Browse files Browse the repository at this point in the history
Add command line option to restrict downloaded images to games without official artwork.
  • Loading branch information
Lucki authored and boppreh committed Mar 1, 2021
1 parent cb81b59 commit 83b2572
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ again when you get more games or want to update the category overlays.
* *(optional)* Append `--types <preference>` to choose your preferences between animated steam covers or static ones Available choices : `animated`,`static`. Default : `static`. You can use `animated,static` to download both while preferring animated covers, and `static,animated` for preferring static covers.
* *(optional)* Append `--styles <preference>` to choose your preferences between the different covers styles from steamgriddb. Available choices : `material`,`white_logo`,`alternate`,`blurred`,`no_logo`. Default: `alternate`. You can also input multiple comma-separated choices in the same manners of the `--types` argument.
* *(optional)* Append `--appids <appid1,appid2>` to only process the specified appID(s)
* *(optional)* Append `--onlymissingartwork` to only download artworks missing on the official servers.
* *(tip)* Run with `--help` to see all available options.
6. Read the report and open Steam in grid view to check the results.

---
Expand Down
14 changes: 11 additions & 3 deletions download.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,24 @@ const steamCdnURLFormat = `cdn.akamai.steamstatic.com/steam/apps/%v/`
// sources. Returns the final response received and a flag indicating if it was
// from a Google search (useful because we want to log the lower quality
// images).
func getImageAlternatives(game *Game, artStyle string, artStyleExtensions []string, skipSteam bool, steamGridDBApiKey string, steamGridFilter string, IGDBApiKey string, skipGoogle bool) (response *http.Response, from string, err error) {
func getImageAlternatives(game *Game, artStyle string, artStyleExtensions []string, skipSteam bool, steamGridDBApiKey string, steamGridFilter string, IGDBApiKey string, skipGoogle bool, onlyMissingArtwork bool) (response *http.Response, from string, err error) {
from = "steam server"
if !skipSteam {
response, err = tryDownload(fmt.Sprintf(akamaiURLFormat+artStyleExtensions[2], game.ID))
if err == nil && response != nil {
if onlyMissingArtwork {
// Abort if image is available
return nil, "", nil
}
return
}

response, err = tryDownload(fmt.Sprintf(steamCdnURLFormat+artStyleExtensions[2], game.ID))
if err == nil && response != nil {
if onlyMissingArtwork {
// Abort if image is available
return nil, "", nil
}
return
}
}
Expand Down Expand Up @@ -365,8 +373,8 @@ func getImageAlternatives(game *Game, artStyle string, artStyleExtensions []stri
// DownloadImage tries to download the game images, saving it in game.ImageBytes. Returns
// flags indicating if the operation succeeded and if the image downloaded was
// from a search.
func DownloadImage(gridDir string, game *Game, artStyle string, artStyleExtensions []string, skipSteam bool, steamGridDBApiKey string, steamGridFilter string, IGDBApiKey string, skipGoogle bool) (string, error) {
response, from, err := getImageAlternatives(game, artStyle, artStyleExtensions, skipSteam, steamGridDBApiKey, steamGridFilter, IGDBApiKey, skipGoogle)
func DownloadImage(gridDir string, game *Game, artStyle string, artStyleExtensions []string, skipSteam bool, steamGridDBApiKey string, steamGridFilter string, IGDBApiKey string, skipGoogle bool, onlyMissingArtwork bool) (string, error) {
response, from, err := getImageAlternatives(game, artStyle, artStyleExtensions, skipSteam, steamGridDBApiKey, steamGridFilter, IGDBApiKey, skipGoogle, onlyMissingArtwork)
if response == nil || err != nil {
return "", err
}
Expand Down
3 changes: 2 additions & 1 deletion steamgrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func startApplication() {
skipLogo := flag.Bool("skiplogo", false, "Skip search and processing logo artwork")
nonSteamOnly := flag.Bool("nonsteamonly", false, "Only search artwork for Non-Steam-Games")
appIDs := flag.String("appids", "", "Comma separated list of appIds that should be processed")
onlyMissingArtwork := flag.Bool("onlymissingartwork", false, "Only download artworks missing on the official servers")
flag.Parse()
if flag.NArg() == 1 {
steamDir = &flag.Args()[0]
Expand Down Expand Up @@ -193,7 +194,7 @@ func startApplication() {
// Download if missing.
///////////////////////
if game.ImageSource == "" {
from, err := DownloadImage(gridDir, game, artStyle, artStyleExtensions, *skipSteam, *steamGridDBApiKey, steamGridFilter, *IGDBApiKey, *skipGoogle)
from, err := DownloadImage(gridDir, game, artStyle, artStyleExtensions, *skipSteam, *steamGridDBApiKey, steamGridFilter, *IGDBApiKey, *skipGoogle, *onlyMissingArtwork)
if err != nil && err.Error() == "SteamGridDB authorization token is missing or invalid" {
// Wrong api key
*steamGridDBApiKey = ""
Expand Down

0 comments on commit 83b2572

Please sign in to comment.