Once hb-downloader-settings.yaml has been setup you'll need to execute hb-downloader.py at least once prior to any automation. The script will detect that you need to login and prompt you for your Authy token. Once you've successfully authenticated, the _session_auth cookie will be stored in the file specified by the cookie filename and you won't have to enter any credentials. (And, if you're the paranoid sort, you can remove your credentials from the hb-downloader-settings.yaml file.)
+Alternatively, you can directly enter the value of the _simple_auth cookie from your browser in the yaml configuration file, or pass it trough the command line.
+
The sessions are occasionally invalidated by humblebundle.com so keep an eye out if executions begin to fail.
## Issues
download_location = ""
debug = True
cookie_filename = "cookies.txt"
+ auth_sess_cookie = ""
write_md5 = True
read_md5 = True
force_md5 = False
ConfigData.debug = saved_config.get("debug", ConfigData.debug)
ConfigData.download_location = saved_config.get("download-location", ConfigData.download_location)
ConfigData.cookie_filename = saved_config.get("cookie-filename", ConfigData.cookie_filename)
+ ConfigData.auth_sess_cookie = saved_config.get("session-cookie", ConfigData.auth_sess_cookie)
ConfigData.username = saved_config.get("username", ConfigData.username)
ConfigData.password = saved_config.get("password", ConfigData.password)
ConfigData.resume_downloads = saved_config.get("resume_downloads", ConfigData.resume_downloads)
parser.add_argument("-cs", "--chunksize", nargs="?",
default=ConfigData.chunk_size,
help="The size to use when calculating MD5s and downloading files.", type=int)
+ parser.add_argument("-c", "--auth_cookie", nargs="?",
+ default=ConfigData.auth_sess_cookie,
+ help="The _simple_auth cookie value from a web browser", type=str)
args = parser.parse_args()
ConfigData.cookie_filename = args.cookie_filename
ConfigData.download_location = args.download_location
ConfigData.chunk_size = args.chunksize
+ ConfigData.auth_sess_cookie = args.auth_cookie
+
+ print("auth cookie:")
@staticmethod
def dump_configuration():
# download-location: /mnt/Storage/HumbleBundle/Games/
cookie-filename: cookies.txt
+# alternatively, paste a session cookie from your browser here, in single quotes, to replace normal authentication
+session-cookie: ''
username: <enter your username here>
password: <enter your password here>
download-location: \\megatron\mila\Games\Humble Bundle\
# Initialize the event handlers.
EventHandler.initialize()
-hapi = HumbleApi(ConfigData.cookie_filename)
+hapi = HumbleApi(ConfigData.cookie_filename, ConfigData.auth_sess_cookie)
if not hapi.check_login():
ConfigData.authy_token = input("Enter your Authy token: ")
"""
# URLs.
- LOGIN_URL = "https://www.humblebundle.com/login"
+ LOGIN_URL = "https://www.humblebundle.com/processlogin"
ORDER_LIST_URL = "https://www.humblebundle.com/api/v1/user/order"
ORDER_URL = "https://www.humblebundle.com/api/v1/order/{order_id}"
# default_params specifies the default querystring parameters added to each request sent to humblebundle.com.
default_params = {"ajax": "true"}
- def __init__(self, cookie_location="cookie.txt"):
+ def __init__(self, cookie_location="cookie.txt", auth_sess_cookie=""):
"""
Base constructor. Responsible for setting up the requests object and cookie jar.
All configuration values should be set prior to constructing an object of this
self.session = requests.Session()
self.session.cookies = http.cookiejar.LWPCookieJar(cookie_location)
+ if auth_sess_cookie != "":
+ auth_sess_cookie = bytes(auth_sess_cookie, "utf-8").decode("unicode_escape")
+ cookie = http.cookiejar.Cookie(0, "_simpleauth_sess", auth_sess_cookie, None, None, "www.humblebundle.com", None, None, "/", None, True, None, False, None, None, None)
+ self.session.cookies.set_cookie(cookie)
try:
self.session.cookies.load()
except IOError: