From 27401cf4275e1984af207e274b3d9d61fb7b74eb Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Tue, 1 Aug 2023 12:31:20 +0500 Subject: [PATCH] Basic etterna pack browser and downloader --- bash_scripts/etterna_pack_dl.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 bash_scripts/etterna_pack_dl.sh diff --git a/bash_scripts/etterna_pack_dl.sh b/bash_scripts/etterna_pack_dl.sh new file mode 100755 index 0000000..5546e7f --- /dev/null +++ b/bash_scripts/etterna_pack_dl.sh @@ -0,0 +1,21 @@ +#!/usr/bin/bash +min_diff=${1:-0} +max_diff=${2:-99} +max_size_bytes=${3:-$((512 * 1024 * 1024))} +ETTERNA_PATH=~/Desktop/Etterna + +if [ $(cat /sys/class/net/wlo1/carrier) -eq 0 ] && [ $(cat /sys/class/net/enp*/carrier) -eq 0 ]; then + echo 'No internet' + exit 1 +fi + +PACKS=$(curl --silent 'https://api.etternaonline.com/v2/packs') +DL_LINK=$(echo $PACKS | jq ".data | .[] | select(.attributes.average >= $min_diff and .attributes.average <= $max_diff and .attributes.size <= $max_size_bytes) | .attributes.name + \";\" + .attributes.download" | fzf -d ";" --with-nth 1 --bind 'enter:become(echo {2})') +if [ $? -ne 0 ]; then + echo "Abort" + exit 1 +fi +cd $ETTERNA_PATH/Songs +wget --no-check-certificate "$DL_LINK" && { + unzip *.zip && rm *.zip +}