fix: file size as double check. #80

This commit is contained in:
Terry Geng 2020-02-27 21:20:50 +08:00
parent b640ff4721
commit 2312b4da20

View File

@ -463,8 +463,12 @@ class MumbleBot:
logging.info("bot: download attempts %d / %d" % (i+1, attempts)) logging.info("bot: download attempts %d / %d" % (i+1, attempts))
try: try:
ydl.extract_info(url) ydl.extract_info(url)
if os.path.exists(mp3) and os.stat(mp3).st_size > 0:
music['ready'] = "yes" music['ready'] = "yes"
download_succeed = True download_succeed = True
break
else:
logging.error("bot: download failed: file not existed or file size is 0.")
except: except:
error_traceback = traceback.format_exc() error_traceback = traceback.format_exc()
logging.error("bot: download failed with error:\n %s" % error_traceback) logging.error("bot: download failed with error:\n %s" % error_traceback)