Skip to content

Instantly share code, notes, and snippets.

@vitezfh
Last active December 11, 2023 03:36
Show Gist options
  • Save vitezfh/4aa5d140de44a6d5676c8a2f06efaa98 to your computer and use it in GitHub Desktop.
Save vitezfh/4aa5d140de44a6d5676c8a2f06efaa98 to your computer and use it in GitHub Desktop.
#! /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 &quot; to actual quotes:
elements="${elements//'&quot;'/'"'}"
# 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
@obsessedcake
Copy link

Thanks for a script! Unfortunately it doesn't work for me... so I created another python script: https://github.com/obsessedcake/gumroad-utils

@vitezfh
Copy link
Author

vitezfh commented Dec 11, 2023

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!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment