不要打那么多日志了
This commit is contained in:
parent
880b129e63
commit
739cc87131
@ -69,15 +69,12 @@ class Bilibili:
|
|||||||
if not isinstance(parts, list):
|
if not isinstance(parts, list):
|
||||||
parts = [parts]
|
parts = [parts]
|
||||||
|
|
||||||
def log_status(video_part, chunks_index: int, chunks_num: int):
|
|
||||||
LOGGER.debug("Uploading >{}< @ {:.2f}%".format(video_part.path, 100.0 * chunks_index / chunks_num))
|
|
||||||
|
|
||||||
IS_UPLOADING.set()
|
IS_UPLOADING.set()
|
||||||
for part in parts:
|
for part in parts:
|
||||||
if isinstance(part, str):
|
if isinstance(part, str):
|
||||||
part = VideoPart(part)
|
part = VideoPart(part)
|
||||||
LOGGER.info("Start Uploading >{}<".format(part.path))
|
LOGGER.info("Start Uploading >{}<".format(part.path))
|
||||||
status = core.upload_video_part(self.access_token, self.session_id, self.user_id, part, max_retry, cb=log_status)
|
status = core.upload_video_part(self.access_token, self.session_id, self.user_id, part, max_retry)
|
||||||
if status:
|
if status:
|
||||||
# 上传完毕
|
# 上传完毕
|
||||||
LOGGER.info("Upload >{}< Finished;【{}】".format(part.path, part.server_file_name))
|
LOGGER.info("Upload >{}< Finished;【{}】".format(part.path, part.server_file_name))
|
||||||
|
@ -248,7 +248,7 @@ def upload_chunk(upload_url, server_file_name, local_file_name, chunk_data, chun
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def upload_video_part(access_token, sid, mid, video_part: VideoPart, max_retry=5, cb=None):
|
def upload_video_part(access_token, sid, mid, video_part: VideoPart, max_retry=5):
|
||||||
"""
|
"""
|
||||||
upload a video file.
|
upload a video file.
|
||||||
Args:
|
Args:
|
||||||
@ -297,7 +297,6 @@ def upload_video_part(access_token, sid, mid, video_part: VideoPart, max_retry=5
|
|||||||
with open(local_file_name, 'rb') as f:
|
with open(local_file_name, 'rb') as f:
|
||||||
for chunk_id in range(0, chunk_total_num):
|
for chunk_id in range(0, chunk_total_num):
|
||||||
chunk_data = f.read(CHUNK_SIZE)
|
chunk_data = f.read(CHUNK_SIZE)
|
||||||
cb(video_part, chunk_id, chunk_total_num)
|
|
||||||
status = Retry(max_retry=max_retry, success_return_value=True).run(
|
status = Retry(max_retry=max_retry, success_return_value=True).run(
|
||||||
upload_chunk,
|
upload_chunk,
|
||||||
upload_url,
|
upload_url,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user