Last active 1440821890

Steven Smith revised this gist 1427864049. Go to revision

1 file changed, 1 insertion, 1 deletion

gethbdownloads.py

@@ -28,7 +28,7 @@ def main():
28 28 if dl.platform == platform:
29 29 info = dl.download_struct[0]
30 30 if not info.url.web:
31 - print("*** Url not found for {}: {}".format(info.machine_name, info.message), file=stderr)
31 + print("*** Url not found for {}: {}".format(dl.machine_name, info.message), file=stderr)
32 32 continue
33 33 f.write("{} *{}\n".format(info.md5, info.url.web.split("/")[-1].split("?")[0]))
34 34 if torrent and not info.url.bittorrent:

Steven Smith revised this gist 1427863984. Go to revision

1 file changed, 5 insertions, 2 deletions

gethbdownloads.py

@@ -5,7 +5,7 @@
5 5 from __future__ import print_function
6 6 from sys import stderr, exit
7 7 from getpass import getpass
8 - import humblebundle # https://pypi.python.org/pypi/humblebundle
8 + import humblebundle
9 9
10 10 ERRORS = {1: "Login failed, please check details"}
11 11
@@ -27,6 +27,9 @@ def main():
27 27 for dl in product.downloads:
28 28 if dl.platform == platform:
29 29 info = dl.download_struct[0]
30 + if not info.url.web:
31 + print("*** Url not found for {}: {}".format(info.machine_name, info.message), file=stderr)
32 + continue
30 33 f.write("{} *{}\n".format(info.md5, info.url.web.split("/")[-1].split("?")[0]))
31 34 if torrent and not info.url.bittorrent:
32 35 print("*** Url is not a torrent url: " + info.url.web, file=stderr)
@@ -36,4 +39,4 @@ if __name__ == "__main__":
36 39 retcode = main()
37 40 if retcode in ERRORS:
38 41 print(ERRORS[retcode], file=stderr)
39 - exit(retcode)
42 + exit(retcode)

Steven Smith revised this gist 1427863258. Go to revision

1 file changed, 39 insertions

gethbdownloads.py(file created)

@@ -0,0 +1,39 @@
1 + # Usage: gethbdownloads.py > filelist.txt
2 + # Then: wget --content-disposition --no-check-certificate -c -i filelist.txt
3 + # Defaults to returning torrent urls, easily configurable
4 +
5 + from __future__ import print_function
6 + from sys import stderr, exit
7 + from getpass import getpass
8 + import humblebundle # https://pypi.python.org/pypi/humblebundle
9 +
10 + ERRORS = {1: "Login failed, please check details"}
11 +
12 + def query(prompt=None, default=None):
13 + if prompt:
14 + stderr.write(str(prompt))
15 + return raw_input() or default
16 +
17 + def main():
18 + client = humblebundle.HumbleApi()
19 + if not client.login(query("humblebundle.com email: "), getpass("humblebundle.com password: ", stderr)):
20 + return 1
21 + platform = query("Platform [windows]: ", "windows")
22 + torrent = query("Bittorrent [true]: ", "true").lower()[0] in ['t', '1', 'y']
23 + with open("HB-{}.md5".format(platform), "w") as f:
24 + for order in [client.get_order(gamekey) for gamekey in client.get_gamekeys()]:
25 + if order and order.subproducts:
26 + for product in order.subproducts:
27 + for dl in product.downloads:
28 + if dl.platform == platform:
29 + info = dl.download_struct[0]
30 + f.write("{} *{}\n".format(info.md5, info.url.web.split("/")[-1].split("?")[0]))
31 + if torrent and not info.url.bittorrent:
32 + print("*** Url is not a torrent url: " + info.url.web, file=stderr)
33 + print(info.url.bittorrent if torrent and info.url.bittorrent else info.url.web)
34 +
35 + if __name__ == "__main__":
36 + retcode = main()
37 + if retcode in ERRORS:
38 + print(ERRORS[retcode], file=stderr)
39 + exit(retcode)
Newer Older