精简接口

This commit is contained in:
Jerry Yan 2020-01-08 09:20:11 +08:00
parent fdd809fdc2
commit 0f71209fe8
2 changed files with 48 additions and 78 deletions

View File

@ -384,3 +384,29 @@ def encodeVideo(name):
return False
Common.modifyLastEncodeStatus("Encode >{}< Finished".format(name))
uploadQueue.put(_new_name)
def collectInfomation():
return {
"download": downloadStatus,
"encode": encodeStatus,
"encodeQueueSize": encodeQueue.qsize(),
"upload": uploadStatus,
"uploadQueueSize": uploadQueue.qsize(),
"error": errors,
"operation": operations,
"broadcast": {
"broadcaster": broadcaster.__str__(),
"isBroadcasting": isBroadcasting,
"streamUrl": streamUrl,
"updateTime": updateTime,
"delayTime": delay.strftime(dt_format)
},
"config": {
"forceNotBroadcasting": forceNotBroadcasting,
"forceNotDownload": forceNotDownload,
"forceNotUpload": forceNotUpload,
"forceNotEncode": forceNotEncode,
"downloadOnly": config['dlO'],
},
}

View File

@ -121,29 +121,7 @@ def finishUpload():
@app.route("/stats", methods=["GET"])
def getAllStats():
return jsonify({"message":"ok","code":200,"status":0,"data":{
"download":Common.downloadStatus,
"encode": Common.encodeStatus,
"encodeQueueSize": Common.encodeQueue.qsize(),
"upload": Common.uploadStatus,
"uploadQueueSize": Common.uploadQueue.qsize(),
"error": Common.errors,
"operation": Common.operations,
"broadcast": {
"broadcaster": Common.broadcaster.__str__(),
"isBroadcasting": Common.isBroadcasting,
"streamUrl": Common.streamUrl,
"updateTime": Common.updateTime,
"delayTime": Common.delay
},
"config": {
"forceNotBroadcasting": Common.forceNotBroadcasting,
"forceNotDownload": Common.forceNotDownload,
"forceNotUpload": Common.forceNotUpload,
"forceNotEncode": Common.forceNotEncode,
"downloadOnly": Common.config['dlO'],
},
}})
return jsonify({"message": "ok", "code": 200, "status": 0, "data": Common.collectInfomation()})
@app.route("/stats/device", methods=["GET"])
@ -153,19 +131,6 @@ def getDeviceStatus():
}})
@app.route("/stats/broadcast", methods=["GET"])
def getBroadcastStats():
return jsonify({"message":"ok","code":200,"status":0,"data":{
"broadcast": {
"broadcaster": Common.broadcaster.__str__(),
"isBroadcasting": Common.isBroadcasting,
"streamUrl": Common.streamUrl,
"updateTime": Common.updateTime,
"delayTime": Common.delay
}
}})
@app.route("/stats/config", methods=["GET"])
def getConfigStats():
return jsonify({"message": "ok", "code": 200, "status": 0, "data": {
@ -179,29 +144,6 @@ def getConfigStats():
}})
@app.route("/stats/download", methods=["GET"])
def getDownloadStats():
return jsonify({"message":"ok","code":200,"status":0,"data":{
"download":Common.downloadStatus,
}})
@app.route("/stats/encode", methods=["GET"])
def getEncodeStats():
return jsonify({"message":"ok","code":200,"status":0,"data":{
"encode": Common.encodeStatus,
"encodeQueueSize": Common.encodeQueue.qsize(),
}})
@app.route("/stats/upload", methods=["GET"])
def getUploadStats():
return jsonify({"message":"ok","code":200,"status":0,"data":{
"upload": Common.uploadStatus,
"uploadQueueSize": Common.uploadQueue.qsize(),
}})
@app.route("/account/reLogin", methods=["POST"])
def accountRelogin():
res = Common.loginBilibili(True)
@ -226,6 +168,7 @@ def fileDownload(path):
f.seek(offset)
for row in f:
yield row
if os.path.exists(path):
if "RANGE" in request.headers:
offset = int(request.headers["RANGE"].replace("=", "-").split("-")[1].strip())
@ -238,7 +181,8 @@ def fileDownload(path):
mimetype='application/octet-stream',
headers={
"Content-Length": os.path.getsize(path),
"Content-Range": "bytes {}-{}/{}".format(offset,os.path.getsize(path)-1,os.path.getsize(path)),
"Content-Range": "bytes {}-{}/{}".format(offset, os.path.getsize(path) - 1,
os.path.getsize(path)),
"Accept-Ranges": "bytes",
"Range": "bytes",
})