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))))
def save_to_bangumi_download_queue(data): queue = [] for i in data: download = Download(status=STATUS_NOT_DOWNLOAD, name=i['name'], title=i['title'], episode=i['episode'], download=i['download']) download.save() queue.append(download) return queue
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)
def save_to_bangumi_download_queue(data): """ list[dict] dict:{ name;str, keyword you use when search title:str, title of episode episode:int, episode of bangumi download:str, link to download } :param data: :return: """ queue = [] for i in data: download = Download(status=STATUS_NOT_DOWNLOAD, name=i['name'], title=i['title'], episode=i['episode'], download=i['download']) download.save() queue.append(download) return queue