-
-
Save virgiliu/eefbadef4de9d2ecb2e01020ae471892 to your computer and use it in GitHub Desktop.
// Run this in the content download page and it will trigger download for everything | |
var sleep = (milliseconds) => { | |
return new Promise(resolve => setTimeout(resolve, milliseconds)) | |
} | |
var waitTime = 1500; //ms | |
var x = $( "button:contains('Download')" ); | |
for(var i = 0; i < x.length ; i++) | |
{ | |
(function(idx) { | |
// Wait needed because browser blocks network calls if you make too many too fast | |
sleep(i * waitTime).then(() => { | |
x[idx].click(); | |
}); | |
})(i) | |
} | |
I forgot to tell, I fixed it about an hour ago lol
I tried it out and it should work. Probably..
I forgot to tell, I fixed it about an hour ago lol I tried it out and it should work. Probably..
Yup, looks like its working, thanks a bunch!!!!
I tried @Kawaru86 's gumload plugin, and what I got was this:
Updating Library...
Failed to update library due to ['NoneType' object has no attribute 'string']
Downloading 0 files
My config.json:
{
"threads": 5,
"only_specified_creators": true,
"match_size_using_content_info": true,
"db_path": "gumload.json",
"refresh": true,
"folder": "E:\_GumroadResults\",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0",
"_gumroad_app_session": "redacted",
"_gumroad_guid": "redacted",
"creators": [
]
}
Maybe it's because the creators array was empty... How do I get the right values to put in for name, id and count? I'd also like to note that I tried the stuff in the article that itswzyss made, but JDownloader didn't work with the text files outputted by either script.
Try changing using
"only_specified_creators": false
instead of "only_specified_creators": true
@InfiniteCanvas thanks for your work, the script works flawlessly!
Hi all! I've update https://github.com/obsessedcake/gumroad-utils. If anyone interested, take a look 😄
@InfiniteCanvas @Kawaru86 Thanks, it worked!
Hi all! I've update https://github.com/obsessedcake/gumroad-utils. If anyone interested, take a look 😄
@obsessedcake Thanks for building and sharing that. For me the original script was a one-time thing which I made public by mistake, but since people started talking I decided to leave it up even though I don't have the time to maintain it 😅
Can anyone please help me to download from the beginning and how to code it please.. that'd be great help thankyou
Hi all! I've update https://github.com/obsessedcake/gumroad-utils. If anyone interested, take a look 😄
I've tried using the library but can't download any files via the URL I'm getting an error
What is this error and is there any way to fix it
@itswzyss Good idea. Went through little tests with my file. Once a number of links attained, Gumroad decide to cut the flow and stop the connexion. So, I decided to reduce the file in multiple files, once per artist (even if you have multiple purchases). 🤣 One thing more. Content creator can use external links to host their files instead of gumroad. I alert of that in the files & console.
let promises = await Promise.all(Array.from(document.querySelectorAll("article a.stretched-link")) // Get promises with purchases download links. .map((link) => { return link.href }) .map((link) => { return fetch(link) // Get link from purchase link. .then(res => res.text()) .then(text => { let parser = new DOMParser(); // Create DOMContent from fetch content with download links. let doc = parser.parseFromString(text, "text/html"); var script = doc.querySelector("script[data-component-name]");// Get script in which the download content JS is. if(JSON.parse(script.innerText).content.content_items.length === 0) console.log(JSON.parse(script.innerText).creator.name + " use an external hosting service. Please watch their files to get the purchased download links"); // Alert in console for external hosting services. return { artist: JSON.parse(script.innerText).creator.name, links: (JSON.parse(script.innerText).content.content_items.length > 0 ? JSON.parse(script.innerText).content.content_items.map((item) => { return "https://app.gumroad.com" + item.download_url }) : ["external link in following page : " + link]) };// Return both the artist and the associated download URLs (if content is in external website from gumroad, the page will be alerted). }); })); let timer = 0; // Timer to delay the download (to avoid download throttle). promises // Need the promises to be resolved from here. .reduce((acc, d) => { const found = acc.find(a => a.artist === d.artist); const value = d.links.flat(Infinity); if (!found) acc.push({ artist: d.artist, links: [value] }) else found.links.push(value); return acc; }, [])// Regroup links per artist. .sort(function (a, b) { return a.artist.localeCompare(b.artist); })// Sort artist per name. .forEach((data) => { setTimeout(function () { var blob = new Blob([data.links.flat(Infinity).join("\n")], { type: "text/plain;charset=utf-8" }); var url = window.URL || window.webkitURL; var link = url.createObjectURL(blob);// Creation of download link. var a = document.createElement("a"); a.download = "downloads_" + data.artist + "_gumroad.txt"; document.body.appendChild(a); a.href = link;// Creation of the download button. a.click(); // Click to begin download. a.remove(); // Remove the download button. }, timer += 1500);// Delay to avoid download throttle. });// From this, download ```
Small problem found, the element selector for the JSON wasn't correct anymore. Here is an updated version:
let promises = await Promise.all(Array.from(document.querySelectorAll("article a.stretched-link")) // Get promises with purchases download links.
.map((link) => { return link.href })
.map((link) => {
return fetch(link) // Get link from purchase link.
.then(res => res.text())
.then(text => {
let parser = new DOMParser(); // Create DOMContent from fetch content with download links.
let doc = parser.parseFromString(text, "text/html");
var script = doc.querySelector("script[data-component-name=\"DownloadPageWithContent\"]");// Get script in which the download content JS is.
if(JSON.parse(script.innerText).content.content_items.length === 0)
console.log(JSON.parse(script.innerText).creator.name + " use an external hosting service. Please watch their files to get the purchased download links"); // Alert in console for external hosting services.
return {
artist: JSON.parse(script.innerText).creator.name,
links: (JSON.parse(script.innerText).content.content_items.length > 0 ?
JSON.parse(script.innerText).content.content_items.map((item) => { return "https://app.gumroad.com" + item.download_url }) :
["external link in following page : " + link])
};// Return both the artist and the associated download URLs (if content is in external website from gumroad, the page will be alerted).
});
}));
let timer = 0; // Timer to delay the download (to avoid download throttle).
promises // Need the promises to be resolved from here.
.reduce((acc, d) => {
const found = acc.find(a => a.artist === d.artist);
const value = d.links.flat(Infinity);
if (!found) acc.push({ artist: d.artist, links: [value] })
else found.links.push(value);
return acc;
}, [])// Regroup links per artist.
.sort(function (a, b) {
return a.artist.localeCompare(b.artist);
})// Sort artist per name.
.forEach((data) => {
setTimeout(function () {
var blob = new Blob([data.links.flat(Infinity).join("\n")], { type: "text/plain;charset=utf-8" });
var url = window.URL || window.webkitURL;
var link = url.createObjectURL(blob);// Creation of download link.
var a = document.createElement("a");
a.download = "downloads_" + data.artist + "_gumroad.txt";
document.body.appendChild(a);
a.href = link;// Creation of the download button.
a.click(); // Click to begin download.
a.remove(); // Remove the download button.
}, timer += 1500);// Delay to avoid download throttle.
});// From this, download
hi sorry am I missing something? I've put the code in developer tools same with the download page, It just shows an error or does nothing apart from says undefined. Do I need to put the code somewhere else?
hi sorry am I missing something? I've put the code in developer tools same with the download page, It just shows an error or does nothing apart from says undefined. Do I need to put the code somewhere else?
Try replacing button:contains('Download')
with a:contains('Download')
I had to modify the script for it to work. I'm using the "href" attribute, and simply adding http://gumroad.com in front of that variable. The previous script was using the "data-resource-id" which is empty / undefined.
Also I had some problems using console download managers to download the urls, since gumroad asks for confirmation before starting the file download. But I was able to use the Chrono Chrome extension. Just simply press the "new" button and paste in the list of URLs with each URL in a new line.
var x = $("a.button:contains('Download')");
var result = [];
for (var i = 0; i < x.length; i++) {
result.push(x[i].getAttribute("href"));
}
var currentUrl = window.location.href;
var newBaseUrl = currentUrl.replace("/d/", "/r/");
var newUrls = [];
result.forEach(function (resourceId) {
newUrls.push("https://gumroad.com" + resourceId);
});
var blob = new Blob([newUrls.join("\n")], { type: "text/plain" });
var a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = "urls.txt";
a.style.display = "none";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(a.href);
Ah okay. XD