mirror of
https://github.com/xtream1101/humblebundle-downloader.git
synced 2025-02-02 03:52:41 +01:00
Updated readme regarding cookies. Added --session-auth cookie option. Fixed #32, Fixed #37, Fixed #30
This commit is contained in:
parent
b335e35242
commit
c451d407d8
12
README.md
12
README.md
@ -24,9 +24,15 @@ The first time this runs it may take a while because it will download everything
|
|||||||
## Instructions
|
## Instructions
|
||||||
|
|
||||||
### 1. Getting cookies
|
### 1. Getting cookies
|
||||||
First thing to do is get your account cookies. The cookies should be in the Netscape format. You can get them by using a browser extension. These are the ones that I tested, but others may work as well...
|
First thing to do is get your account cookies. This can be done by getting a browser extension that lest you see or export your cookies.
|
||||||
- Firefox: https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/
|
|
||||||
- Chrome: https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg/
|
- **Method 1 (recommended)**
|
||||||
|
- Get the value of the cookie called `_simpleauth_sess` and pass that value using `-s "COOKIE_VALUE"`
|
||||||
|
|
||||||
|
- **Method 2**
|
||||||
|
- Export the cookies in the Netscape format using an extension.
|
||||||
|
If your exported cookie file is not working, it may be a formatting issue, this can be fixed by running the command `curl -b cookies.orig.txt --cookie-jar cookies.txt http://bogus`
|
||||||
|
|
||||||
|
|
||||||
### 2. Downloading your library
|
### 2. Downloading your library
|
||||||
Use the following command to download your Humble Bundle Library:
|
Use the following command to download your Humble Bundle Library:
|
||||||
|
@ -25,10 +25,14 @@ def cli():
|
|||||||
'download',
|
'download',
|
||||||
help="Download content in your humble bundle library",
|
help="Download content in your humble bundle library",
|
||||||
)
|
)
|
||||||
parser_download.add_argument(
|
cookie = parser_download.add_mutually_exclusive_group(required=True)
|
||||||
|
cookie.add_argument(
|
||||||
'-c', '--cookie-file', type=str,
|
'-c', '--cookie-file', type=str,
|
||||||
help="Location of the cookies file",
|
help="Location of the cookies file",
|
||||||
required=True,
|
)
|
||||||
|
cookie.add_argument(
|
||||||
|
'-s', '--session-auth', type=str,
|
||||||
|
help="Value of the cookie _simpleauth_sess. WRAP IN QUOTES",
|
||||||
)
|
)
|
||||||
parser_download.add_argument(
|
parser_download.add_argument(
|
||||||
'-l', '--library-path', type=str,
|
'-l', '--library-path', type=str,
|
||||||
@ -80,8 +84,9 @@ def cli():
|
|||||||
# Still keep the download action to keep compatibility
|
# Still keep the download action to keep compatibility
|
||||||
from .download_library import DownloadLibrary
|
from .download_library import DownloadLibrary
|
||||||
DownloadLibrary(
|
DownloadLibrary(
|
||||||
cli_args.cookie_file,
|
|
||||||
cli_args.library_path,
|
cli_args.library_path,
|
||||||
|
cookie_path=cli_args.cookie_file,
|
||||||
|
cookie_auth=cli_args.session_auth,
|
||||||
progress_bar=cli_args.progress,
|
progress_bar=cli_args.progress,
|
||||||
ext_include=cli_args.include,
|
ext_include=cli_args.include,
|
||||||
ext_exclude=cli_args.exclude,
|
ext_exclude=cli_args.exclude,
|
||||||
|
@ -23,9 +23,10 @@ def _clean_name(dirty_str):
|
|||||||
|
|
||||||
class DownloadLibrary:
|
class DownloadLibrary:
|
||||||
|
|
||||||
def __init__(self, cookie_path, library_path, progress_bar=False,
|
def __init__(self, library_path, cookie_path=None, cookie_auth=None,
|
||||||
ext_include=None, ext_exclude=None, platform_include=None,
|
progress_bar=False, ext_include=None, ext_exclude=None,
|
||||||
purchase_keys=None, trove=False, update=False):
|
platform_include=None, purchase_keys=None, trove=False,
|
||||||
|
update=False):
|
||||||
self.library_path = library_path
|
self.library_path = library_path
|
||||||
self.progress_bar = progress_bar
|
self.progress_bar = progress_bar
|
||||||
self.ext_include = [] if ext_include is None else list(map(str.lower, ext_include)) # noqa: E501
|
self.ext_include = [] if ext_include is None else list(map(str.lower, ext_include)) # noqa: E501
|
||||||
@ -42,6 +43,7 @@ class DownloadLibrary:
|
|||||||
self.update = update
|
self.update = update
|
||||||
|
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
if cookie_path:
|
||||||
try:
|
try:
|
||||||
cookie_jar = http.cookiejar.MozillaCookieJar(cookie_path)
|
cookie_jar = http.cookiejar.MozillaCookieJar(cookie_path)
|
||||||
cookie_jar.load()
|
cookie_jar.load()
|
||||||
@ -50,6 +52,10 @@ class DownloadLibrary:
|
|||||||
# Still support the original cookie method
|
# Still support the original cookie method
|
||||||
with open(cookie_path, 'r') as f:
|
with open(cookie_path, 'r') as f:
|
||||||
self.session.headers.update({'cookie': f.read().strip()})
|
self.session.headers.update({'cookie': f.read().strip()})
|
||||||
|
elif cookie_auth:
|
||||||
|
self.session.headers.update(
|
||||||
|
{'cookie': '_simpleauth_sess={}'.format(cookie_auth)}
|
||||||
|
)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user