Skip to content

Instantly share code, notes, and snippets.

@vitezfh
Last active April 14, 2024 04:12
Show Gist options
  • Save vitezfh/86f8867013f9b1305b3933eab2cc29a5 to your computer and use it in GitHub Desktop.
Save vitezfh/86f8867013f9b1305b3933eab2cc29a5 to your computer and use it in GitHub Desktop.
#! /bin/bash
url="https://gumroad.com/d/7b65cbcb5004935ce63bdd4cdd22ccba"
button_links=$(curl -c ./cookies-gumroad-com.txt -b ./cookies-gumroad-com.txt $url -L -Ss | grep '"download_click" data-url="' | awk '{print $7}' | cut -d '"' -f2)
# Possible replacement: button_links=$(curl -c ./cookies-gumroad-com.txt -b ./cookies-gumroad-com.txt $url -L -Ss | grep -oP '(?<=download_click" data-url=").*?(?=")')
for link in $button_links; do
curl --limit-rate 4000k -C - "gumroad.com$link" -L -c ./cookies-gumroad-com.txt -b ./cookies-gumroad-com.txt \
-o "mde_paywall/$(awk -F '/' '{print $4}' <<< $link).mp4"
#Possible replacement: wget -P mde_paywall -nd -r -l 1 -H -D files.gumroad.com -A mp4,webm "gumroad.com$link" --load-cookies="cookies-gumroad-com.txt" --save-cookies="cookies-gumroad-com.txt"
done
@vitezfh
Copy link
Author

vitezfh commented Apr 16, 2020

You also need your cookies from gumroad for this to work. The lazy can do this by using an extension called "Export Cookies" for Firefox ( or something comparable for your browser). Name them cookies-gumroad-com.txt in the case of this script.
This script is very hacky, so I encourage you to improve it.

@cco
Copy link

cco commented Oct 8, 2020

Does this still work as intended on your system? Trying to grab a config or script that'll archive it all in one go for me, but I'm not versed in scraping.

@vitezfh
Copy link
Author

vitezfh commented Oct 11, 2020

Does this still work as intended on your system? Trying to grab a config or script that'll archive it all in one go for me, but I'm not versed in scraping.

Hey, not sure since I'm no longer subscribed, but let me see:
the $url should link to the page where all the mde video files are listed.
The way the $links variable is built is:
1. curl fetches the html for $url (also authenticates over the cookies file cookies-gumroad-com.txt).
2. Then it greps the html for all download buttons aka "download_click" data-url=". This might be different now.
3. Awk gets part of the link
4. cut removes the double quotes.
Then we loop over the $links and fetch them with curl.
Btw, curl has the "--limit-rate 4000k" flag, which will limit your download speed.

I'm pretty sure you can run it multiple times and it won't download the same files again.

@cco
Copy link

cco commented Oct 13, 2020

Unfortunately there is no data-url= as far as I can tell anymore.

<button href="#" data-event-name="download_click" class="button button-default js-track-click-event">Download</button>

Redirects when clicked to gumroad.com/r/******** which holds the file.

@vitezfh
Copy link
Author

vitezfh commented Oct 13, 2020

Seems to me like they made all the pages uniform. But I have no way of checking since I'm not subscribed.
If it looks like the picture I attached; You might just have an option to download it all in a zip file (on the right, "Download as ZIP"

image

@cco
Copy link

cco commented Oct 14, 2020

Seems the issue is that they limit the ability to archive entire content libraries based on the size, so after x amount they stop offering that feature. Seems like I'll have to play around in phantomjs and get around the javascript issues.

@gatekeepr
Copy link

gatekeepr commented Oct 24, 2020

Hello everyone, made a quick gist using python to accomplish this, only tested it with the mde gumroad but should work for every other mp4 based gumroad. If you have any issues lmk.

https://gist.github.com/gatekeepr/97d6244dc074280b32f505443fbd7fe6

EDIT: fixed extension but could break on special characters in filenames that interfere with the path (only removing : due to it breaking on linux, let me know if you find others)

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