上传前先登录
This commit is contained in:
parent
ef10d0bf0f
commit
3e1fae2183
2
app.py
2
app.py
@ -9,6 +9,7 @@ from controller.api.video_clip_blueprint import blueprint as api_video_clip_blue
|
||||
from controller.api.danmaku_clip_blueprint import blueprint as api_danmaku_clip_blueprint
|
||||
from controller.api.posting_blueprint import blueprint as api_posting_blueprint
|
||||
from controller.api.video_part_blueprint import blueprint as api_video_part_blueprint
|
||||
from controller.api.biliuploader_blueprint import blueprint as api_biliuploader_blueprint
|
||||
from model import db
|
||||
|
||||
app = Flask(__name__)
|
||||
@ -28,6 +29,7 @@ app.register_blueprint(api_video_clip_blueprint)
|
||||
app.register_blueprint(api_danmaku_clip_blueprint)
|
||||
app.register_blueprint(api_posting_blueprint)
|
||||
app.register_blueprint(api_video_part_blueprint)
|
||||
app.register_blueprint(api_biliuploader_blueprint)
|
||||
with app.app_context():
|
||||
# db.drop_all(app=app)
|
||||
db.create_all(app=app)
|
||||
|
@ -50,6 +50,7 @@ def auto_submit_task():
|
||||
_result = _f.result()
|
||||
if _result:
|
||||
# start uploading
|
||||
bilibili_instance.login()
|
||||
bilibili_instance.upload(parts=_result,
|
||||
title=bili_record_workflow_item.name,
|
||||
desc=VIDEO_DESC,
|
||||
|
19
controller/api/biliuploader_blueprint.py
Normal file
19
controller/api/biliuploader_blueprint.py
Normal file
@ -0,0 +1,19 @@
|
||||
from flask import Blueprint, jsonify
|
||||
from workflow.bilibili import INSTANCE as BILIBILI_INSTANCE
|
||||
|
||||
blueprint = Blueprint("api_biliuploader", __name__, url_prefix="/api/biliuploader")
|
||||
|
||||
|
||||
@blueprint.get("/")
|
||||
def get_login_info():
|
||||
return jsonify({
|
||||
"mid": BILIBILI_INSTANCE.user_id,
|
||||
"expires": BILIBILI_INSTANCE.expires,
|
||||
"login_at": BILIBILI_INSTANCE.login_time,
|
||||
})
|
||||
|
||||
|
||||
@blueprint.post("/")
|
||||
def do_login():
|
||||
BILIBILI_INSTANCE.login()
|
||||
return get_login_info()
|
@ -180,6 +180,40 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="upload-config">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">上传配置Alpha</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>视频标题Pattern</td>
|
||||
<td>{{ config.video.title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>视频描述</td>
|
||||
<td>{{ config.video.desc }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>视频分区</td>
|
||||
<td>{{ config.video.tid }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>视频标签</td>
|
||||
<td>{{ config.video.tags }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>上传人</td>
|
||||
<td><a :href="'https://space.bilibili.com/'+collector.uploader.mid">{{ collector.uploader.mid }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>登录时间</td>
|
||||
<td>{{ collector.upload.login_at }}(于{{ collector.upload.expires }}秒后过期)</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endraw %}
|
||||
</body>
|
||||
@ -225,6 +259,11 @@
|
||||
},
|
||||
living: false
|
||||
},
|
||||
uploader: {
|
||||
mid: 0,
|
||||
expires: 0,
|
||||
login_at: 0,
|
||||
},
|
||||
},
|
||||
config: {
|
||||
danmaku: {
|
||||
@ -265,6 +304,11 @@
|
||||
}).then((response) => {
|
||||
this.collector.basic = response.data;
|
||||
})
|
||||
axios({
|
||||
url: "/api/biliuploader/"
|
||||
}).then((response) => {
|
||||
this.collector.uploader = response.data;
|
||||
})
|
||||
axios({
|
||||
url: "/api/config/"
|
||||
}).then((response) => {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import threading
|
||||
from datetime import datetime
|
||||
|
||||
from . import LOGGER
|
||||
from .bilibiliupload import core, VideoPart
|
||||
@ -13,13 +14,16 @@ class Bilibili:
|
||||
self.access_token = ""
|
||||
self.session_id = ""
|
||||
self.user_id = ""
|
||||
self.expires = 0
|
||||
self.login_time = None
|
||||
self.parts = []
|
||||
|
||||
def login(self):
|
||||
with open("access_token", "r") as f:
|
||||
self.access_token = f.read(64).strip()
|
||||
self.session_id, self.user_id, expires = core.login_by_access_token(self.access_token)
|
||||
LOGGER.info("B站登录,UID【{}】,过期时间【{}】".format(self.user_id, expires))
|
||||
self.session_id, self.user_id, self.expires = core.login_by_access_token(self.access_token)
|
||||
self.login_time = datetime.now()
|
||||
LOGGER.info("B站登录,UID【{}】,过期时间【{}】".format(self.user_id, self.expires))
|
||||
|
||||
def upload(self,
|
||||
parts,
|
||||
|
Loading…
x
Reference in New Issue
Block a user