Ejemplo n.º 1
0
Archivo: main.py Proyecto: xxoxx/BGmi
def download_manager(ret):
    print_info(
        'Download status value: Not Downloaded: 0 / Downloading: 1 / Downloaded: 2\n',
        indicator=False)

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

    elif ret.action.download == DOWNLOAD_ACTION_MARK:
        download_id = ret.action.download.mark.id
        status = ret.action.download.mark.status
        if not download_id or not status:
            print_error('No id or status specified.')
        download_obj = Download(_id=download_id)
        download_obj.select_obj()
        if not download_obj:
            print_error('Download object does not exist.')
        print_info('Download Object <{0} - {1}>, Status: {2}'.format(
            download_obj.name, download_obj.episode, download_obj.status))
        download_obj.status = status
        download_obj.save()
        print_success('Download status has been marked as {0}'.format(
            DOWNLOAD_CHOICE_LIST_DICT.get(int(status))))
Ejemplo n.º 2
0
def download_manager(ret):
    if ret.id:
        download_id = ret.id
        status = ret.status
        if download_id is None or status is None:
            print_error('No id or status specified.')
        download_obj = Download(_id=download_id)
        download_obj.select_obj()
        if not download_obj:
            print_error('Download object does not exist.')
        print_info('Download Object <{0} - {1}>, Status: {2}'.format(
            download_obj.name, download_obj.episode, download_obj.status))
        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)