├── README.md └── hib-dl-all.py /README.md: -------------------------------------------------------------------------------- 1 | # hib-dl-all 2 | They tell (told?) you to back your stuff up, but don't have a "download everything" button on there, as far as I can tell. 3 | That's why I wrote this. It's really not much, thanks to the very helpful [humblebundle-python](https://github.com/saik0/humblebundle-python) library. 4 | -------------------------------------------------------------------------------- /hib-dl-all.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import humblebundle 3 | import argparse 4 | import os 5 | import subprocess 6 | 7 | def dl(filename, url): 8 | if not os.path.isfile(filename): 9 | subprocess.run(["wget", "-c", "-O", filename, url]).check_returncode() 10 | 11 | parser = argparse.ArgumentParser(description='downloads your whole humble bundle library.') 12 | parser.add_argument('-u', metavar='user@mail.com', help='your humblebundle.com username', dest='username') 13 | parser.add_argument('-p', metavar='hunter2', help='your humblebundle.com password', dest='password') 14 | # not yet implemented 15 | #parser.add_argument('-k', metavar='KEY', help='humble key for a purchase or bundle', dest='keys', nargs='*') 16 | parser.add_argument('-d', metavar='DIRECTORY', help='your games, soundtracks, ebooks, … will be saved here', dest='directory', default='.') 17 | parser.add_argument('-w', metavar='watchdir', help='torrent files will be put here', dest='watchdir', default=None) 18 | #parser.add_argument('-t', help='only download torrent files (falls back to normal download if no torrent available)', dest='torrent_only', action='store_true') 19 | #parser.set_defaults(torrent_only=False) 20 | 21 | args = parser.parse_args() 22 | #if(args.keys == None and args.username == None): 23 | if(args.username == None): 24 | parser.print_help() 25 | exit(1) 26 | 27 | os.chdir(args.directory) 28 | 29 | client = humblebundle.HumbleApi() 30 | client.login(args.username, args.password) 31 | 32 | order_list = client.order_list() 33 | for order in order_list: 34 | if order.subproducts != None: 35 | for subproduct in order.subproducts: 36 | if subproduct.downloads != None: 37 | for download in subproduct.downloads: 38 | for download_struct in download.download_struct: 39 | torrent_url = download_struct.url.bittorrent 40 | web_url = download_struct.url.web 41 | if args.watchdir != None and torrent_url != None: 42 | filename = args.watchdir + "/" + torrent_url.split("/")[4].split("?")[0] 43 | dl(filename, torrent_url) 44 | if torrent_url != None and web_url != None: # and not torrent_only 45 | filename = web_url.split("/")[3].split("?")[0] 46 | dl(filename, web_url) 47 | 48 | --------------------------------------------------------------------------------