Skip to content

Commit

Permalink
Deprecate the download argument. Fixes xtream1101#38
Browse files Browse the repository at this point in the history
  • Loading branch information
xtream1101 committed May 21, 2021
1 parent c6bb459 commit 95302d8
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pypi-package:
tag:
stage: release
only:
- master
- main
script:
- *write_permission
- export VERSION=$(echo $(python -c "import humblebundle_downloader._version as v; print(v.__version__)"))
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change log


### 0.4.0
- Deprecate the `download` argument. It is no longer needed since that is the only action that can be taken


### 0.3.4
- Merged in [PR 35](https://github.com/xtream1101/humblebundle-downloader/pull/35) to fix some trove games not downloading

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ First thing to do is get your account cookies. This can be done by getting a bro

### 2. Downloading your library
Use the following command to download your Humble Bundle Library:
`hbd download --cookie-file cookies.txt --library-path "Downloaded Library" --progress`
`hbd --cookie-file cookies.txt --library-path "Downloaded Library" --progress`

This directory structure will be used:
`Downloaded Library/Purchase Name/Item Name/downloaded_file.ext`
Expand Down
2 changes: 1 addition & 1 deletion humblebundle_downloader/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.4'
__version__ = '0.4.0'
66 changes: 32 additions & 34 deletions humblebundle_downloader/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import logging
import argparse

Expand All @@ -13,19 +14,14 @@
logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING)


def cli():
def parse_args(args):
if args[0].lower() == 'download':
args = args[1:]
raise DeprecationWarning("`download` argument is no longer used")

parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='action')
subparsers.required = True

###
# Download Library
###
parser_download = subparsers.add_parser(
'download',
help="Download content in your humble bundle library",
)
cookie = parser_download.add_mutually_exclusive_group(required=True)
cookie = parser.add_mutually_exclusive_group(required=True)
cookie.add_argument(
'-c', '--cookie-file', type=str,
help="Location of the cookies file",
Expand All @@ -34,32 +30,32 @@ def cli():
'-s', '--session-auth', type=str,
help="Value of the cookie _simpleauth_sess. WRAP IN QUOTES",
)
parser_download.add_argument(
parser.add_argument(
'-l', '--library-path', type=str,
help="Folder to download all content to",
required=True,
)
parser_download.add_argument(
parser.add_argument(
'-t', '--trove', action='store_true',
help="Only check and download Humble Trove content",
)
parser_download.add_argument(
parser.add_argument(
'-u', '--update', action='store_true',
help=("Check to see if products have been updated "
"(still get new products)"),
)
parser_download.add_argument(
parser.add_argument(
'-p', '--platform',
type=str, nargs='*',
help=("Only get content in a platform. Values can be seen in your "
"humble bundle's library dropdown. Ex: -p ebook video"),
)
parser_download.add_argument(
parser.add_argument(
'--progress',
action='store_true',
help="Display progress bar for downloads",
)
filter_ext = parser_download.add_mutually_exclusive_group()
filter_ext = parser.add_mutually_exclusive_group()
filter_ext.add_argument(
'-e', '--exclude',
type=str, nargs='*',
Expand All @@ -71,27 +67,29 @@ def cli():
type=str, nargs='*',
help="Only download files with these extensions. Ex: -i pdf mobi",
)
parser_download.add_argument(
parser.add_argument(
'-k', '--keys',
type=str, nargs='*',
help=("The purchase download key. Find in the url on the "
"products/bundle download page. Can set multiple"),
)

cli_args = parser.parse_args()
return parser.parse_args(args)


def cli():
cli_args = parse_args(sys.argv[1:])

if cli_args.action == 'download':
# Still keep the download action to keep compatibility
from .download_library import DownloadLibrary
DownloadLibrary(
cli_args.library_path,
cookie_path=cli_args.cookie_file,
cookie_auth=cli_args.session_auth,
progress_bar=cli_args.progress,
ext_include=cli_args.include,
ext_exclude=cli_args.exclude,
platform_include=cli_args.platform,
purchase_keys=cli_args.keys,
trove=cli_args.trove,
update=cli_args.update,
).start()
from .download_library import DownloadLibrary
DownloadLibrary(
cli_args.library_path,
cookie_path=cli_args.cookie_file,
cookie_auth=cli_args.session_auth,
progress_bar=cli_args.progress,
ext_include=cli_args.include,
ext_exclude=cli_args.exclude,
platform_include=cli_args.platform,
purchase_keys=cli_args.keys,
trove=cli_args.trove,
update=cli_args.update,
).start()
13 changes: 13 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
from humblebundle_downloader.cli import parse_args


def test_old_action_format():
with pytest.raises(DeprecationWarning):
_ = parse_args(['download', '-l', 'some_path', '-c', 'fake_cookie'])


def test_no_action():
args = parse_args(['-l', 'some_path', '-c', 'fake_cookie'])
assert args.library_path == 'some_path'
assert args.cookie_file == 'fake_cookie'

0 comments on commit 95302d8

Please sign in to comment.