删除Bypy,b站账号Common化,通过接口控制账号
This commit is contained in:
parent
586ef37874
commit
6536acb10e
28
Common.py
28
Common.py
@ -7,15 +7,16 @@ import psutil
|
|||||||
from api import XiGuaLiveApi
|
from api import XiGuaLiveApi
|
||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
from bypy import ByPy
|
from bilibili import *
|
||||||
|
|
||||||
_config_fp = open("config.json", "r", encoding="utf8")
|
_config_fp = open("config.json", "r", encoding="utf8")
|
||||||
config = json.load(_config_fp)
|
config = json.load(_config_fp)
|
||||||
_config_fp.close()
|
_config_fp.close()
|
||||||
bypy = ByPy()
|
|
||||||
doCleanTime = datetime.now()
|
doCleanTime = datetime.now()
|
||||||
_clean_flag = None
|
_clean_flag = None
|
||||||
|
|
||||||
|
b = Bilibili()
|
||||||
|
|
||||||
network = [{
|
network = [{
|
||||||
"currentTime": datetime.now(),
|
"currentTime": datetime.now(),
|
||||||
"out": {
|
"out": {
|
||||||
@ -35,6 +36,11 @@ network = [{
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
|
def loginBilibili():
|
||||||
|
res = b.login(config["b_u"], config["b_p"])
|
||||||
|
appendOperation("登陆账号,结果为:["+res+"]")
|
||||||
|
|
||||||
|
|
||||||
def updateNetwork():
|
def updateNetwork():
|
||||||
global network
|
global network
|
||||||
network.append({
|
network.append({
|
||||||
@ -67,12 +73,7 @@ def _doClean(_force=False):
|
|||||||
doCleanTime = datetime.now()
|
doCleanTime = datetime.now()
|
||||||
if (datetime.now() - datetime.utcfromtimestamp(os.path.getmtime(_i))).days >= config["exp"]:
|
if (datetime.now() - datetime.utcfromtimestamp(os.path.getmtime(_i))).days >= config["exp"]:
|
||||||
_clean_flag = True
|
_clean_flag = True
|
||||||
if config["dow"] == "bypy":
|
os.system(config["dow"])
|
||||||
_res = bypy.upload(_i)
|
|
||||||
if _res == 0:
|
|
||||||
os.remove(_i)
|
|
||||||
else:
|
|
||||||
os.system(config["dow"])
|
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
doCleanTime = datetime.now()
|
doCleanTime = datetime.now()
|
||||||
@ -146,6 +147,7 @@ downloadStatus = []
|
|||||||
encodeStatus = []
|
encodeStatus = []
|
||||||
errors = []
|
errors = []
|
||||||
operations = []
|
operations = []
|
||||||
|
loginBilibili()
|
||||||
|
|
||||||
|
|
||||||
def appendOperation(obj):
|
def appendOperation(obj):
|
||||||
@ -324,3 +326,13 @@ api = downloader(config["l_u"])
|
|||||||
def refreshDownloader():
|
def refreshDownloader():
|
||||||
global api
|
global api
|
||||||
api = downloader(config["l_u"])
|
api = downloader(config["l_u"])
|
||||||
|
|
||||||
|
|
||||||
|
def uploadVideo(name):
|
||||||
|
b.preUpload(VideoPart(name, os.path.basename(name)))
|
||||||
|
|
||||||
|
|
||||||
|
def publishVideo(date):
|
||||||
|
b.finishUpload(config["t_t"].format(date), 17, config["tag"], config["des"],
|
||||||
|
source=config["src"], no_reprint=0)
|
||||||
|
b.clear()
|
@ -198,6 +198,12 @@ def getUploadStats():
|
|||||||
}})
|
}})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/account/reLogin", methods=["GET"])
|
||||||
|
def accountRelogin():
|
||||||
|
Common.loginBilibili()
|
||||||
|
return jsonify({"message":"ok","code":200,"status":0,"data":{}})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/files/", methods=["GET"])
|
@app.route("/files/", methods=["GET"])
|
||||||
def fileIndex():
|
def fileIndex():
|
||||||
a = []
|
a = []
|
||||||
|
@ -3,7 +3,6 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import threading
|
import threading
|
||||||
from bilibili import *
|
|
||||||
import Common
|
import Common
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
@ -93,15 +92,13 @@ def upload():
|
|||||||
else:
|
else:
|
||||||
if isinstance(i, bool):
|
if isinstance(i, bool):
|
||||||
if i is True:
|
if i is True:
|
||||||
b.finishUpload(Common.config["t_t"].format(date), 17, Common.config["tag"], Common.config["des"],
|
Common.publishVideo(date)
|
||||||
source=Common.config["src"], no_reprint=0)
|
|
||||||
b.clear()
|
|
||||||
break
|
break
|
||||||
if not os.path.exists(i):
|
if not os.path.exists(i):
|
||||||
Common.appendError("Upload File Not Exist {}".format(i))
|
Common.appendError("Upload File Not Exist {}".format(i))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
b.preUpload(VideoPart(i, os.path.basename(i)))
|
Common.uploadVideo(i)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Common.appendError(e.__str__())
|
Common.appendError(e.__str__())
|
||||||
continue
|
continue
|
||||||
@ -111,8 +108,6 @@ def upload():
|
|||||||
Common.appendUploadStatus("Upload Daemon Quiting")
|
Common.appendUploadStatus("Upload Daemon Quiting")
|
||||||
|
|
||||||
|
|
||||||
b = Bilibili()
|
|
||||||
b.login(Common.config["b_u"], Common.config["b_p"])
|
|
||||||
t = threading.Thread(target=download, args=())
|
t = threading.Thread(target=download, args=())
|
||||||
ut = threading.Thread(target=upload, args=())
|
ut = threading.Thread(target=upload, args=())
|
||||||
et = threading.Thread(target=encode, args=())
|
et = threading.Thread(target=encode, args=())
|
||||||
|
Reference in New Issue
Block a user