Skip to content

Instantly share code, notes, and snippets.

@fjctp
Last active April 27, 2021 05:51
Show Gist options
  • Save fjctp/43262f885eab0464a830c52bc6150b5d to your computer and use it in GitHub Desktop.
Save fjctp/43262f885eab0464a830c52bc6150b5d to your computer and use it in GitHub Desktop.
Download all URLs in humblebundle's order page
#!/usr/bin/python3
import argparse
import json
import subprocess
parser = argparse.ArgumentParser(description='Download from humblebundle')
parser.add_argument('filename', help='.json')
args = parser.parse_args()
filename = args.filename
count = 0
with open(filename, 'r') as f:
urls = json.load(f)
print("Being download")
for e in urls:
name = e['name']
url = e['href']
cmd = ["wget", "-O", name, "-o", "/dev/null", url]
#print(" ".join(cmd))
count = count + 1
print(str(count) + "/" + str(len(urls)) + ": " + name)
p = subprocess.run(cmd, stdin=None, stdout=None, stderr=None, capture_output=False, shell=False)
print("Done")
function download_hb_all(ext) {
// Run the script in Chrome's developer tool (ctrl + shift + J)
// Make sure it is in the order page with all the download links
const wait_ms = 5000;
// Get all <a> tags that has URL
const selector = 'div.row > div.downloads > div.download-buttons > div > div.download.small > span.js-start-download > a.a';
var tags = document.querySelectorAll(selector);
var filtered = Array.from(tags).filter(x => x.getAttribute('href').includes(ext));
var count = 0;
const total = filtered.length;
// Click a <a> tag to download
function download_one() {
var tag = filtered.pop();
tag.click();
var url = tag.getAttribute('href');
console.log(++count + '/' + total + ': ' + url);
if(filtered.length != 0) {
setTimeout(download_one, wait_ms);
} else {
console.log('Done');
}
}
// Start
console.log('Begin download')
if(filtered.length != 0) {
setTimeout(download_one, wait_ms);
} else {
console.log('Done');
}
}
function extract_hb_urls(ext) {
// Run the script in Chrome's developer tool (ctrl + shift + J)
// Make sure it is in the order page with all the download links
// Get all <a> tags that has URL
const selector = 'div.row > div.downloads > div.download-buttons > div > div.download.small > span.js-start-download > a.a';
var tags = document.querySelectorAll(selector);
var filtered = Array.from(tags).filter(x => x.getAttribute('href').includes(ext));
function extract_data(tag) {
const url = tag.getAttribute('href')
const regex1 = /\.com\/(?<name>.*)\?/gm;
const match = regex1.exec(url);
return {
'name': match.groups.name,
'href': url,
};
}
return filtered.map(extract_data);
}
// copy(output)
// then paste it in a text editor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment