支持控制自动投递

This commit is contained in:
Jerry Yan 2022-08-31 14:53:45 +08:00
parent 0d2f9e2a28
commit 9f443dfae2
3 changed files with 23 additions and 11 deletions

View File

@ -27,6 +27,8 @@ VIDEO_BITRATE = "2.5M"
# crf
VIDEO_CRF = 28
# [video]
# enabled
VIDEO_ENABLED = False
# title
VIDEO_TITLE = "【永恒de草薙直播录播】直播于 {}"
# desc
@ -70,7 +72,8 @@ def load_config():
VIDEO_RESOLUTION = section.get('resolution', VIDEO_RESOLUTION)
if config.has_section("video"):
section = config['video']
global VIDEO_TITLE, VIDEO_DESC, VIDEO_TID, VIDEO_TAGS
global VIDEO_ENABLED, VIDEO_TITLE, VIDEO_DESC, VIDEO_TID, VIDEO_TAGS
VIDEO_ENABLED = section.getboolean('enabled', VIDEO_ENABLED)
VIDEO_TITLE = section.get('title', VIDEO_TITLE)
VIDEO_DESC = section.get('desc', VIDEO_DESC)
VIDEO_TID = section.getint('tid', VIDEO_TID)
@ -108,6 +111,7 @@ def get_config():
'resolution': VIDEO_RESOLUTION,
},
'video': {
'enabled': VIDEO_ENABLED,
'title': VIDEO_TITLE,
'desc': VIDEO_DESC,
'tid': VIDEO_TID,

View File

@ -7,7 +7,7 @@ from typing import Optional
from flask import Blueprint, jsonify, request, current_app
from config import BILILIVE_RECORDER_DIRECTORY, VIDEO_TITLE, XIGUALIVE_RECORDER_DIRECTORY, VIDEO_DESC, \
VIDEO_TAGS, VIDEO_TID
VIDEO_TAGS, VIDEO_TID, VIDEO_ENABLED
from exception.danmaku import DanmakuException
from model import db
from model.DanmakuClip import DanmakuClip
@ -49,14 +49,17 @@ def auto_submit_task():
*[clip.full_path for clip in video_clip.danmaku_clips[1:]]
)
clear_item()
def _encode_finish_callback(_f: "Future"):
_result = _f.result()
if _result:
# start uploading
bilibili_instance.pre_upload(
parts=[VideoPart(os.path.join(_item['base_path'], _item['file']), _item['file']) for _item in
_result])
_future.add_done_callback(_encode_finish_callback)
if VIDEO_ENABLED:
def _encode_finish_callback(_f: "Future"):
_result = _f.result()
if _result:
# start uploading
bilibili_instance.pre_upload(
parts=[VideoPart(os.path.join(_item['base_path'], _item['file']), _item['file']) for _item
in
_result])
_future.add_done_callback(_encode_finish_callback)
else:
print("[-]Workflow:", bili_record_workflow_item.id, "; Video:", video_clip.full_path, "; No Danmaku")
if _future is not None:

View File

@ -187,10 +187,14 @@
<table class="upload-config">
<thead>
<tr>
<td colspan="2">上传配置Alpha</td>
<td colspan="2">上传配置<sup>Beta</sup></td>
</tr>
</thead>
<tbody>
<tr>
<td>是否开启</td>
<td :class="{warning: !config.video.enabled, success: config.video.enabled}"></td>
</tr>
<tr>
<td>视频标题Pattern</td>
<td>{{ config.video.title }}</td>
@ -278,6 +282,7 @@
resolution: "",
},
video: {
enabled: false,
title: "",
desc: "",
tid: 0,