mirror of
https://github.com/xtream1101/humblebundle-downloader.git
synced 2025-02-02 03:52:41 +01:00
This commit is contained in:
parent
b0a06d8bc0
commit
7168258191
@ -1,5 +1,9 @@
|
|||||||
# Change log
|
# Change log
|
||||||
|
|
||||||
|
### 0.0.8
|
||||||
|
- gen-cookies now works with SSO feature and 2FA logins
|
||||||
|
- Added `--include` & `--exclude` cli args to filter file types
|
||||||
|
|
||||||
|
|
||||||
### 0.0.7
|
### 0.0.7
|
||||||
- Replace `:` with ` -` in filenames
|
- Replace `:` with ` -` in filenames
|
||||||
|
@ -53,6 +53,17 @@ def cli():
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help="Display progress bar for downloads",
|
help="Display progress bar for downloads",
|
||||||
)
|
)
|
||||||
|
filter_ext = parser_download.add_mutually_exclusive_group()
|
||||||
|
filter_ext.add_argument(
|
||||||
|
'-e', '--exclude',
|
||||||
|
type=str, nargs='*',
|
||||||
|
help="File extensions to ignore when downloading files. Ex: -e pdf mobi"
|
||||||
|
)
|
||||||
|
filter_ext.add_argument(
|
||||||
|
'-i', '--include',
|
||||||
|
type=str, nargs='*',
|
||||||
|
help="Only download files with these extensions. Ex: -i pdf mobi"
|
||||||
|
)
|
||||||
|
|
||||||
cli_args = parser.parse_args()
|
cli_args = parser.parse_args()
|
||||||
|
|
||||||
@ -65,5 +76,7 @@ def cli():
|
|||||||
download_library(
|
download_library(
|
||||||
cli_args.cookie_file,
|
cli_args.cookie_file,
|
||||||
cli_args.library_path,
|
cli_args.library_path,
|
||||||
progress_bar=cli_args.progress
|
progress_bar=cli_args.progress,
|
||||||
|
ext_include=cli_args.include,
|
||||||
|
ext_exclude=cli_args.exclude
|
||||||
)
|
)
|
||||||
|
@ -17,7 +17,13 @@ def _clean_name(dirty_str):
|
|||||||
return "".join(clean).strip()
|
return "".join(clean).strip()
|
||||||
|
|
||||||
|
|
||||||
def download_library(cookie_path, library_path, progress_bar=False):
|
def download_library(cookie_path, library_path, progress_bar=False,
|
||||||
|
ext_include=None, ext_exclude=None):
|
||||||
|
if ext_include is None:
|
||||||
|
ext_include = []
|
||||||
|
if ext_exclude is None:
|
||||||
|
ext_exclude = []
|
||||||
|
|
||||||
# Load cookies
|
# Load cookies
|
||||||
with open(cookie_path, 'r') as f:
|
with open(cookie_path, 'r') as f:
|
||||||
account_cookies = f.read()
|
account_cookies = f.read()
|
||||||
@ -66,8 +72,15 @@ def download_library(cookie_path, library_path, progress_bar=False):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
logger.info("No url found for " + item_title)
|
logger.info("No url found for " + item_title)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ext = url.split('?')[0].split('.')[-1]
|
ext = url.split('?')[0].split('.')[-1]
|
||||||
file_title = item_title + "." + ext
|
file_title = item_title + "." + ext
|
||||||
|
# Only get the file types we care about
|
||||||
|
if ((ext_include and ext not in ext_include)
|
||||||
|
or (ext_exclude and ext in ext_exclude)):
|
||||||
|
logger.info("Skipping the file " + file_title)
|
||||||
|
continue
|
||||||
|
|
||||||
filename = os.path.join(item_folder, file_title)
|
filename = os.path.join(item_folder, file_title)
|
||||||
item_r = requests.get(url, stream=True)
|
item_r = requests.get(url, stream=True)
|
||||||
logger.debug("Item request: {item_r}, Url: {url}"
|
logger.debug("Item request: {item_r}, Url: {url}"
|
||||||
|
@ -26,7 +26,7 @@ def generate_cookie(cookie_path):
|
|||||||
|
|
||||||
driver.get('https://www.humblebundle.com/login')
|
driver.get('https://www.humblebundle.com/login')
|
||||||
|
|
||||||
while '/login' in driver.current_url:
|
while '/home/library' not in driver.current_url:
|
||||||
# Waiting for the user to login
|
# Waiting for the user to login
|
||||||
time.sleep(.25)
|
time.sleep(.25)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user