减少无用内容输出,添加重试延迟,添加重试次数
This commit is contained in:
parent
86448ccc93
commit
79a49de4d5
@ -55,9 +55,10 @@ def auto_submit_task():
|
||||
if _result:
|
||||
# start uploading
|
||||
bilibili_instance.pre_upload(
|
||||
parts=[VideoPart(os.path.join(_item['base_path'], _item['file']), _item['file']) for _item
|
||||
in
|
||||
_result])
|
||||
parts=[VideoPart(os.path.join(_item['base_path'], _item['file']), _item['file'])
|
||||
for _item in _result],
|
||||
max_retry=10
|
||||
)
|
||||
|
||||
_future.add_done_callback(_encode_finish_callback)
|
||||
else:
|
||||
@ -96,13 +97,12 @@ def safe_create_item():
|
||||
global bili_record_workflow_item
|
||||
if bili_record_workflow_item is None:
|
||||
bili_record_workflow_item = Workflow()
|
||||
else:
|
||||
if bili_record_workflow_item is not None and bili_record_workflow_item.id is not None:
|
||||
elif bili_record_workflow_item.id is not None:
|
||||
bili_record_workflow_item.editing = False
|
||||
commit_item()
|
||||
auto_submit_task()
|
||||
bili_record_workflow_item = Workflow()
|
||||
if bili_record_workflow_item.id is None:
|
||||
else:
|
||||
bili_record_workflow_item.name = VIDEO_TITLE.format(datetime.utcnow().strftime("%Y%m%d"))
|
||||
bili_record_workflow_item.automatic = True
|
||||
bili_record_workflow_item.editing = True
|
||||
|
@ -221,8 +221,7 @@ def upload_chunk(upload_url, server_file_name, local_file_name, chunk_data, chun
|
||||
True: upload chunk success.
|
||||
False: upload chunk fail.
|
||||
"""
|
||||
print("chunk{}/{}".format(chunk_id, chunk_total_num))
|
||||
print("filename: {}".format(local_file_name))
|
||||
print("filename: {}".format(local_file_name), "chunk{}/{}".format(chunk_id, chunk_total_num))
|
||||
files = {
|
||||
'version': (None, '2.0.0.1054'),
|
||||
'filesize': (None, chunk_size),
|
||||
@ -239,12 +238,12 @@ def upload_chunk(upload_url, server_file_name, local_file_name, chunk_data, chun
|
||||
'PHPSESSID': server_file_name
|
||||
},
|
||||
)
|
||||
print(r.status_code)
|
||||
print(r.content)
|
||||
r.raise_for_status()
|
||||
if r.status_code == 200 and r.json().get("OK", 0) == 1:
|
||||
return True
|
||||
else:
|
||||
print(r.status_code)
|
||||
print(r.content)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
from time import sleep
|
||||
|
||||
|
||||
class Retry:
|
||||
def __init__(self, max_retry, success_return_value):
|
||||
def __init__(self, max_retry, success_return_value, sleep_sec = 60):
|
||||
self.max_retry = max_retry
|
||||
self.success_return_value = success_return_value
|
||||
self.sleep_sec = 60
|
||||
|
||||
def run(self, func, *args, **kwargs):
|
||||
status = False
|
||||
@ -11,6 +13,7 @@ class Retry:
|
||||
try:
|
||||
return_value = func(*args, **kwargs)
|
||||
except Exception:
|
||||
sleep(self.sleep_sec)
|
||||
continue
|
||||
if return_value == self.success_return_value:
|
||||
status = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user