Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Commit

Permalink
download: optimization of command parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
RicterZ committed May 30, 2017
1 parent 3bd057f commit 59b863f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 6 additions & 9 deletions bgmi/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,7 @@ def cal(ret):


def download_manager(ret):
print_info('Download status value: Not Downloaded: 0 / Downloading: 1 / Downloaded: 2\n', indicator=False)

if ret.list:
status = ret.status
status = int(status) if status is not None else None
delegate = get_download_class(instance=False)
delegate.download_status(status=status)

elif ret.id:
if ret.id:
download_id = ret.id
status = ret.status
if download_id is None or status is None:
Expand All @@ -216,6 +208,11 @@ def download_manager(ret):
download_obj.status = status
download_obj.save()
print_success('Download status has been marked as {0}'.format(DOWNLOAD_CHOICE_LIST_DICT.get(int(status))))
else:
status = ret.status
status = int(status) if status is not None else None
delegate = get_download_class(instance=False)
delegate.download_status(status=status)


def mark(ret):
Expand Down
4 changes: 3 additions & 1 deletion bgmi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def main():
sub_parser_download = sub_parser.add_parser(ACTION_DOWNLOAD, help='Download manager.')
sub_parser_download.add_argument('--list', help='List download queue.', action='store_true')
sub_parser_download.add_argument('--mark', help='Mark download status with a specific id.', dest='id', type=int)
sub_parser_download.add_argument('--status', type=int, help='Download items status (0, 1, 2).', choices=[0, 1, 2])
sub_parser_download.add_argument('--status', type=int, help='Download items status (0: not download, 1: '
'downloading, 2: alrealy downloaded).',
choices=[0, 1, 2])

sub_parser_fetch = sub_parser.add_parser(ACTION_FETCH, help='Fetch bangumi.')
sub_parser_fetch.add_argument('name', help='Bangumi name', type=unicode_)
Expand Down

0 comments on commit 59b863f

Please sign in to comment.