支持控制自动投递

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

View File

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

View File

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