删除Bypy,b站账号Common化,通过接口控制账号

This commit is contained in:
Jerry Yan 2019-10-18 22:34:24 +08:00
parent 586ef37874
commit 6536acb10e
3 changed files with 28 additions and 15 deletions

View File

@ -7,15 +7,16 @@ import psutil
from api import XiGuaLiveApi
import json
import threading
from bypy import ByPy
from bilibili import *
_config_fp = open("config.json", "r", encoding="utf8")
config = json.load(_config_fp)
_config_fp.close()
bypy = ByPy()
doCleanTime = datetime.now()
_clean_flag = None
b = Bilibili()
network = [{
"currentTime": datetime.now(),
"out": {
@ -35,6 +36,11 @@ network = [{
}]
def loginBilibili():
res = b.login(config["b_u"], config["b_p"])
appendOperation("登陆账号,结果为:["+res+"]")
def updateNetwork():
global network
network.append({
@ -67,12 +73,7 @@ def _doClean(_force=False):
doCleanTime = datetime.now()
if (datetime.now() - datetime.utcfromtimestamp(os.path.getmtime(_i))).days >= config["exp"]:
_clean_flag = True
if config["dow"] == "bypy":
_res = bypy.upload(_i)
if _res == 0:
os.remove(_i)
else:
os.system(config["dow"])
os.system(config["dow"])
else:
break
doCleanTime = datetime.now()
@ -146,6 +147,7 @@ downloadStatus = []
encodeStatus = []
errors = []
operations = []
loginBilibili()
def appendOperation(obj):
@ -324,3 +326,13 @@ api = downloader(config["l_u"])
def refreshDownloader():
global api
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()

View File

@ -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"])
def fileIndex():
a = []

View File

@ -3,7 +3,6 @@ import sys
import time
from datetime import datetime
import threading
from bilibili import *
import Common
import os
import requests
@ -93,15 +92,13 @@ def upload():
else:
if isinstance(i, bool):
if i is True:
b.finishUpload(Common.config["t_t"].format(date), 17, Common.config["tag"], Common.config["des"],
source=Common.config["src"], no_reprint=0)
b.clear()
Common.publishVideo(date)
break
if not os.path.exists(i):
Common.appendError("Upload File Not Exist {}".format(i))
else:
try:
b.preUpload(VideoPart(i, os.path.basename(i)))
Common.uploadVideo(i)
except Exception as e:
Common.appendError(e.__str__())
continue
@ -111,8 +108,6 @@ def upload():
Common.appendUploadStatus("Upload Daemon Quiting")
b = Bilibili()
b.login(Common.config["b_u"], Common.config["b_p"])
t = threading.Thread(target=download, args=())
ut = threading.Thread(target=upload, args=())
et = threading.Thread(target=encode, args=())