随便更改了下,希望不要老是投多个稿件
This commit is contained in:
parent
79a49de4d5
commit
0b01f1d77d
@ -13,7 +13,7 @@ from model import db
|
||||
from model.DanmakuClip import DanmakuClip
|
||||
from model.VideoClip import VideoClip
|
||||
from model.Workflow import Workflow
|
||||
from workflow.bilibili import IS_LIVING, IS_UPLOADING, INSTANCE as bilibili_instance
|
||||
from workflow.bilibili import IS_LIVING, IS_UPLOADING, INSTANCE as bilibili_instance, IS_ENCODING
|
||||
from workflow.bilibili import VideoPart
|
||||
from workflow.danmaku import get_file_start
|
||||
from workflow.video import get_video_real_duration, duration_str_to_float
|
||||
@ -35,6 +35,7 @@ def auto_submit_task():
|
||||
if len(bili_record_workflow_item.video_clips) == 0:
|
||||
print("[!]Auto Submit Fail: No Video Clips")
|
||||
return
|
||||
if VIDEO_ENABLED:
|
||||
bilibili_instance.login()
|
||||
video_title = bili_record_workflow_item.name
|
||||
_future = None
|
||||
@ -42,6 +43,7 @@ def auto_submit_task():
|
||||
if len(video_clip.danmaku_clips) > 0:
|
||||
print("[+]Workflow:", bili_record_workflow_item.id, "; Video:", video_clip.full_path)
|
||||
_started = True
|
||||
IS_ENCODING.set()
|
||||
_future = pool.submit(
|
||||
do_workflow,
|
||||
video_clip.full_path,
|
||||
@ -51,6 +53,7 @@ def auto_submit_task():
|
||||
clear_item()
|
||||
if VIDEO_ENABLED:
|
||||
def _encode_finish_callback(_f: "Future"):
|
||||
IS_ENCODING.clear()
|
||||
_result = _f.result()
|
||||
if _result:
|
||||
# start uploading
|
||||
@ -63,9 +66,9 @@ def auto_submit_task():
|
||||
_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:
|
||||
if VIDEO_ENABLED and _future is not None:
|
||||
def _on_upload_finish(_f: "Future"):
|
||||
if IS_UPLOADING.is_set() or IS_LIVING.is_set():
|
||||
if IS_UPLOADING.is_set() or IS_LIVING.is_set() or IS_ENCODING.is_set():
|
||||
return
|
||||
bilibili_instance.finish_upload(
|
||||
title=video_title,
|
||||
@ -73,7 +76,6 @@ def auto_submit_task():
|
||||
tid=VIDEO_TID,
|
||||
tag=VIDEO_TAGS,
|
||||
no_reprint=0)
|
||||
bilibili_instance.clear()
|
||||
_future.add_done_callback(_on_upload_finish)
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ from flask import Blueprint, jsonify
|
||||
|
||||
from config import DANMAKU_EXEC, FFMPEG_EXEC, BILILIVE_RECORDER_DIRECTORY, XIGUALIVE_RECORDER_DIRECTORY, VIDEO_OUTPUT_DIR
|
||||
from util.system import check_exec
|
||||
from workflow.bilibili import IS_LIVING, IS_UPLOADING
|
||||
from workflow.bilibili import IS_LIVING, IS_UPLOADING, IS_ENCODING
|
||||
|
||||
blueprint = Blueprint("api_collector", __name__, url_prefix="/api/collector")
|
||||
|
||||
@ -66,5 +66,6 @@ def collect_basic_status():
|
||||
'os': platform.system(),
|
||||
},
|
||||
'living': IS_LIVING.is_set(),
|
||||
'encoding': IS_ENCODING.is_set(),
|
||||
'uploading': IS_UPLOADING.is_set(),
|
||||
})
|
||||
|
@ -58,6 +58,10 @@
|
||||
<td>当前录制状态</td>
|
||||
<td :class="collector.basic.living ? 'success' : 'warning'"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>当前压制状态</td>
|
||||
<td :class="collector.basic.encoding ? 'success' : 'warning'"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>当前上传状态</td>
|
||||
<td :class="collector.basic.uploading ? 'success' : 'warning'"></td>
|
||||
@ -286,7 +290,9 @@
|
||||
total: ""
|
||||
}
|
||||
},
|
||||
living: false
|
||||
living: false,
|
||||
encoding: false,
|
||||
uploading: false,
|
||||
},
|
||||
uploader: {
|
||||
mid: 0,
|
||||
|
@ -6,6 +6,7 @@ from .bilibiliupload import core, VideoPart
|
||||
|
||||
|
||||
IS_LIVING = threading.Event()
|
||||
IS_ENCODING = threading.Event()
|
||||
IS_UPLOADING = threading.Event()
|
||||
|
||||
|
||||
@ -112,6 +113,15 @@ class Bilibili:
|
||||
"""
|
||||
if len(self.parts) == 0:
|
||||
return
|
||||
if IS_ENCODING.is_set():
|
||||
LOGGER.info("[{}]仍在压制,取消发布".format(title))
|
||||
return
|
||||
if IS_LIVING.is_set():
|
||||
LOGGER.info("[{}]仍在直播,取消发布".format(title))
|
||||
return
|
||||
if IS_UPLOADING.is_set():
|
||||
LOGGER.info("[{}]仍在上传,取消发布".format(title))
|
||||
return
|
||||
LOGGER.info("[{}]投稿中,请稍后".format(title))
|
||||
copyright = 2 if source else 1
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user