TEST3
This commit is contained in:
parent
44b026f5ae
commit
9d7939061c
@ -26,7 +26,12 @@ config = {
|
|||||||
"l_c": 5,
|
"l_c": 5,
|
||||||
# 错误Log条数
|
# 错误Log条数
|
||||||
"elc": 10,
|
"elc": 10,
|
||||||
|
# 每一chunk大小
|
||||||
|
"c_s": 16 * 1024,
|
||||||
|
# 每一块视频大小
|
||||||
"p_s": 2141000000,
|
"p_s": 2141000000,
|
||||||
|
# 忽略的大小
|
||||||
|
"i_s": 2048000,
|
||||||
"max": 75,
|
"max": 75,
|
||||||
"exp": 1,
|
"exp": 1,
|
||||||
"dow": "echo 'clean'",
|
"dow": "echo 'clean'",
|
||||||
@ -79,7 +84,7 @@ def resetDelay():
|
|||||||
|
|
||||||
def doDelay():
|
def doDelay():
|
||||||
global delay
|
global delay
|
||||||
if -120 < getTimeDelta(datetime.now(), delay) < 60:
|
if -60 < getTimeDelta(datetime.now(), delay) < 60:
|
||||||
delay = datetime.fromtimestamp(0)
|
delay = datetime.fromtimestamp(0)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -15,36 +15,33 @@ def download():
|
|||||||
path = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.flv")
|
path = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.flv")
|
||||||
try:
|
try:
|
||||||
p = session.get(Common.streamUrl, stream=True, timeout=3)
|
p = session.get(Common.streamUrl, stream=True, timeout=3)
|
||||||
|
p.raise_for_status()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Common.appendError("Download >{}< with Exception [{}]".format(path,e.__str__()))
|
Common.appendError("Download >{}< with Exception [{}]".format(path,e.__str__()))
|
||||||
break
|
break
|
||||||
if p.status_code != 200:
|
|
||||||
Common.appendDownloadStatus("Download with Response {}".format(p.status_code))
|
|
||||||
break
|
|
||||||
Common.appendDownloadStatus("Download >{}< Start".format(path))
|
Common.appendDownloadStatus("Download >{}< Start".format(path))
|
||||||
f = open(path, "wb")
|
f = open(path, "wb")
|
||||||
_size = 0
|
_size = 0
|
||||||
try:
|
try:
|
||||||
for T in p.iter_content(chunk_size=64 * 1024):
|
for T in p.iter_content(chunk_size=Common.config["c_s"]):
|
||||||
if Common.forceNotDownload:
|
if Common.forceNotDownload:
|
||||||
Common.modifyLastDownloadStatus("Force Stop Download".format(path))
|
Common.modifyLastDownloadStatus("Force Stop Download".format(path))
|
||||||
break
|
return
|
||||||
f.write(T)
|
f.write(T)
|
||||||
_size += len(T)
|
_size += len(T)
|
||||||
Common.modifyLastDownloadStatus(
|
Common.modifyLastDownloadStatus(
|
||||||
"Downloading >{}< @ {:.2f}%".format(path, 100.0 * _size / Common.config["p_s"]))
|
"Downloading >{}< @ {:.2f}%".format(path, 100.0 * _size / Common.config["p_s"]))
|
||||||
if _size > Common.config["p_s"]:
|
if _size > Common.config["p_s"]:
|
||||||
Common.modifyLastDownloadStatus("Download >{}< Exceed MaxSize".format(path))
|
Common.modifyLastDownloadStatus("Download >{}< Exceed MaxSize".format(path))
|
||||||
break
|
|
||||||
Common.modifyLastDownloadStatus("Download >{}< Finished".format(path))
|
Common.modifyLastDownloadStatus("Download >{}< Finished".format(path))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Common.appendError("Download >{}< With Exception {}".format(path, e.__str__()))
|
Common.appendError("Download >{}< With Exception {}".format(path, e.__str__()))
|
||||||
Common.api.updRoomInfo(True)
|
Common.api.updRoomInfo(True)
|
||||||
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
if os.path.getsize(path) < 1024 * 1024:
|
if os.path.getsize(path) < Common.config["i_s"]:
|
||||||
Common.modifyLastDownloadStatus("Downloaded File >{}< is too small, will ignore it".format(path))
|
Common.modifyLastDownloadStatus("Downloaded File >{}< is too small, will ignore it".format(path))
|
||||||
os.remove(path)
|
else:
|
||||||
continue
|
|
||||||
Common.encodeQueue.put(path)
|
Common.encodeQueue.put(path)
|
||||||
Common.api.updRoomInfo(True)
|
Common.api.updRoomInfo(True)
|
||||||
|
|
||||||
@ -68,8 +65,9 @@ def upload():
|
|||||||
Common.uploadVideo(i)
|
Common.uploadVideo(i)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Common.appendError(e.__str__())
|
Common.appendError(e.__str__())
|
||||||
time.sleep(120)
|
|
||||||
continue
|
continue
|
||||||
|
finally:
|
||||||
|
time.sleep(120)
|
||||||
i = Common.uploadQueue.get()
|
i = Common.uploadQueue.get()
|
||||||
Common.appendUploadStatus("Upload Daemon Quiting")
|
Common.appendUploadStatus("Upload Daemon Quiting")
|
||||||
|
|
||||||
@ -127,9 +125,8 @@ def run():
|
|||||||
Common.api.updRoomInfo()
|
Common.api.updRoomInfo()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Common.appendError(e.__str__())
|
Common.appendError(e.__str__())
|
||||||
time.sleep(2)
|
finally:
|
||||||
continue
|
time.sleep(1)
|
||||||
time.sleep(0.5)
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
Common.api.updRoomInfo()
|
Common.api.updRoomInfo()
|
||||||
|
Reference in New Issue
Block a user