def _instantiate_task(api, kwargs):
    file_id = kwargs['file_id']
    kwargs['file_id'] = file_id if str(file_id).strip() else None
    kwargs['cid'] = kwargs['file_id'] or None
    kwargs['rate_download'] = kwargs['rateDownload']
    kwargs['percent_done'] = kwargs['percentDone']
    kwargs['add_time'] = get_utcdatetime(kwargs['add_time'])
    kwargs['last_update'] = get_utcdatetime(kwargs['last_update'])
    is_transferred = (kwargs['status'] == 2 and kwargs['move'] == 1)
    if is_transferred:
        kwargs['pid'] = api.downloads_directory.cid
    else:
        kwargs['pid'] = None
    del kwargs['rateDownload']
    del kwargs['percentDone']
    if 'url' in kwargs:
        if not kwargs['url']:
            kwargs['url'] = None
    else:
        kwargs['url'] = None
    task = Task(api, **kwargs)
    if is_transferred:
        task._parent = api.downloads_directory
    return task
Create a Task object from raw kwargs
dataset/ETHPy150Open shichao-an/115wangpan/u115/api.py/_instantiate_task