Last active
December 11, 2023 03:36
-
-
Save vitezfh/4aa5d140de44a6d5676c8a2f06efaa98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Bash gumroad downloader based on a python script from user gatekeepr: | |
# https://gist.github.com/gatekeepr/97d6244dc074280b32f505443fbd7fe6 | |
# Easily extendable with GNU Parallel! (if you have the download capacity :) | |
# TODO: Could use a fancy bar or download counter... | |
url="https://gumroad.com/d/a795646b9ddc4a496c6cab5e3fa179b5" | |
cookies_path="./cookies.txt" | |
download_path="./" | |
# Replaces /d/ in url to /r/ | |
url="${url/'\/d\/'/'\/r\/'}" | |
# Finds the json between 'DownloadPage/FileList" data-react-props="' and '" data-hydrate="t" data-react-cache-id=' | |
elements=$(curl -c /cookies.txt -b ./cookies.txt $url -L -Ss | grep -oP '(?<=DownloadPage/FileList" data-react-props=").*(?=" data-hydrate="t" data-react-cache-id=)') | |
# Converts all the " to actual quotes: | |
elements="${elements//'"'/'"'}" | |
# Uses jq to build arrays for our files | |
names=($(echo $elements | jq -r ".files[].file_name | @sh")) | |
urls=($(echo $elements | jq -r ".files[].url")) | |
extensions=($(echo $elements | jq -r ".files[].extension")) | |
ITER=0 | |
for url in ${urls[@]}; do | |
name=$(cut -d "'" -f2 <<< ${names[$ITER]}) # Remove single quotes | |
file_name="$download_path/$name.${extensions[$ITER]}" | |
curl $url \ | |
--continue-at - --location \ | |
-c $cookies_path -b $cookies_path \ | |
-o $file_name | |
((ITER++)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No wonder, it's old. It can stay just to refer folks to your comment and as reference for a future bash implementation.
Anyway... Thank you for your wonderful project!!