From a2e5c666d55afb1319cee9e986272fde22b2d826 Mon Sep 17 00:00:00 2001 From: Fanir Date: Mon, 21 Mar 2022 01:20:31 +0100 Subject: [PATCH] created gamedl with build, hbd and itch-download commands --- gamedl | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 gamedl diff --git a/gamedl b/gamedl new file mode 100755 index 0000000..8183fb2 --- /dev/null +++ b/gamedl @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset + +IMAGE=gamedl +CONTAINER=$IMAGE + +function build_image () { + echo "building $IMAGE..." + # docker build --tag "$IMAGE" . + + docker build --tag "$IMAGE" - << EOF +FROM python:3-alpine +RUN apk add --no-cache git +RUN pip install itchiodl +WORKDIR /usr/src/humble-dl +RUN \ + git clone 'https://github.com/xtream1101/humblebundle-downloader.git' . &&\ + wget -O trovefix.patch 'https://patch-diff.githubusercontent.com/raw/xtream1101/humblebundle-downloader/pull/59.patch' &&\ + git apply trovefix.patch &&\ + pip install -e . +CMD echo "Usage: gamedl []" +EOF +} + +function check_image () { + if ! (docker image inspect "$IMAGE" >/dev/null); then + echo "cannot access docker image $IMAGE, it probably does not exist." + + while true; do + read -p "build image? [yn] " yn + case $yn in + [Yy]* ) build_image; exit ;; + [Nn]* ) echo "bye"; exit ;; + * ) echo "Please answer yes or no." ;; + esac + done + fi +} + +function run_image () { + echo "mounting your local working dir as /dl" + docker run -u $(id -u):$(id -g) -v $PWD:/dl -it --rm --name "$CONTAINER" "$IMAGE" "$@" +} + +function show_help () { + echo "Usage $0 [] +Commands: + hbd + Run the Humble downloader. + itch-download + Run the Itch.io downloader. + + build + (Re)build the gamedl-image. + help + That is what you are reading now. +" +} + +cmd="help" +if [ $# -ge 1 ]; then + cmd="$1" +fi + +case "$cmd" in + help | h | -h ) + show_help; exit ;; + build ) + build_image; exit ;; + * ) + run_image $@; exit ;; +esac +