上传前先登录
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.danmaku_clip_blueprint import blueprint as api_danmaku_clip_blueprint
|
||||||
from controller.api.posting_blueprint import blueprint as api_posting_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.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
|
from model import db
|
||||||
|
|
||||||
app = Flask(__name__)
|
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_danmaku_clip_blueprint)
|
||||||
app.register_blueprint(api_posting_blueprint)
|
app.register_blueprint(api_posting_blueprint)
|
||||||
app.register_blueprint(api_video_part_blueprint)
|
app.register_blueprint(api_video_part_blueprint)
|
||||||
|
app.register_blueprint(api_biliuploader_blueprint)
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
# db.drop_all(app=app)
|
# db.drop_all(app=app)
|
||||||
db.create_all(app=app)
|
db.create_all(app=app)
|
||||||
|
@ -50,6 +50,7 @@ def auto_submit_task():
|
|||||||
_result = _f.result()
|
_result = _f.result()
|
||||||
if _result:
|
if _result:
|
||||||
# start uploading
|
# start uploading
|
||||||
|
bilibili_instance.login()
|
||||||
bilibili_instance.upload(parts=_result,
|
bilibili_instance.upload(parts=_result,
|
||||||
title=bili_record_workflow_item.name,
|
title=bili_record_workflow_item.name,
|
||||||
desc=VIDEO_DESC,
|
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>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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>
|
</div>
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
</body>
|
</body>
|
||||||
@ -225,6 +259,11 @@
|
|||||||
},
|
},
|
||||||
living: false
|
living: false
|
||||||
},
|
},
|
||||||
|
uploader: {
|
||||||
|
mid: 0,
|
||||||
|
expires: 0,
|
||||||
|
login_at: 0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
danmaku: {
|
danmaku: {
|
||||||
@ -265,6 +304,11 @@
|
|||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
this.collector.basic = response.data;
|
this.collector.basic = response.data;
|
||||||
})
|
})
|
||||||
|
axios({
|
||||||
|
url: "/api/biliuploader/"
|
||||||
|
}).then((response) => {
|
||||||
|
this.collector.uploader = response.data;
|
||||||
|
})
|
||||||
axios({
|
axios({
|
||||||
url: "/api/config/"
|
url: "/api/config/"
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import threading
|
import threading
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from . import LOGGER
|
from . import LOGGER
|
||||||
from .bilibiliupload import core, VideoPart
|
from .bilibiliupload import core, VideoPart
|
||||||
@ -13,13 +14,16 @@ class Bilibili:
|
|||||||
self.access_token = ""
|
self.access_token = ""
|
||||||
self.session_id = ""
|
self.session_id = ""
|
||||||
self.user_id = ""
|
self.user_id = ""
|
||||||
|
self.expires = 0
|
||||||
|
self.login_time = None
|
||||||
self.parts = []
|
self.parts = []
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
with open("access_token", "r") as f:
|
with open("access_token", "r") as f:
|
||||||
self.access_token = f.read(64).strip()
|
self.access_token = f.read(64).strip()
|
||||||
self.session_id, self.user_id, expires = core.login_by_access_token(self.access_token)
|
self.session_id, self.user_id, self.expires = core.login_by_access_token(self.access_token)
|
||||||
LOGGER.info("B站登录,UID【{}】,过期时间【{}】".format(self.user_id, expires))
|
self.login_time = datetime.now()
|
||||||
|
LOGGER.info("B站登录,UID【{}】,过期时间【{}】".format(self.user_id, self.expires))
|
||||||
|
|
||||||
def upload(self,
|
def upload(self,
|
||||||
parts,
|
parts,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user