nicohman / wyvern

A simple CLI client for installing and maintaining linux GOG games
GNU General Public License v3.0
86 stars 5 forks source link

Download everything into folders per game #34

Open sluedecke opened 3 years ago

sluedecke commented 3 years ago

So far wyvern down and wyvern extras both support the --output flag. But wyvern down -a does not create folders per game. wyvern extras does, so one might end up with a folder full of install files, patch files and a bunch of subdirs for extras. And still wyvern extras needs to be called per game.

I have > 50 games on gog so this is not tidy enough for me. It would be very nice for wyvern to have an option to automatically create one folder per game based on the metadata received from gog.com (e.g. game title).

Until then this script might come in handy (it mentions zsh, but should run on bash, too) (it requires: wyvern, json_pp and jq):

#!/bin/bash

GAMESDIR=SOMEPLACE/gog-games
(
    cd $GAMESDIR
    wyvern ls --json | json_pp > ALLGAMES

    for row in `jq -r '.games[].ProductInfo | {title: .title, id: .id} | @base64' ALLGAMES`
    do 
        R=`echo ${row} | base64 --decode`
        D=`echo $R | jq -r '.title'`
        I=`echo $R | jq -r '.id'`
        echo Downloading $D
        mkdir "$D"
        cd "$D"
        wyvern down -D -r -w --id $I
        wyvern extras -a --id $I
        cd -
    done

) 2>&1 | tee -a $GAMESDIR/log-`date +%Y-%m-%d`.log 

Update: redirection of stderr fixed, uses bash