补充西瓜弹幕自动化
This commit is contained in:
parent
7d8721217d
commit
7f287986dc
@ -5,7 +5,7 @@ from glob import glob
|
|||||||
from flask import Blueprint, jsonify, request, current_app
|
from flask import Blueprint, jsonify, request, current_app
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from config import BILILIVE_RECORDER_DIRECTORY, VIDEO_TITLE
|
from config import BILILIVE_RECORDER_DIRECTORY, VIDEO_TITLE, XIGUALIVE_RECORDER_DIRECTORY
|
||||||
from model import db
|
from model import db
|
||||||
from model.DanmakuClip import DanmakuClip
|
from model.DanmakuClip import DanmakuClip
|
||||||
from model.VideoClip import VideoClip
|
from model.VideoClip import VideoClip
|
||||||
@ -81,22 +81,33 @@ def collect_danmaku_files(workflow: Optional[Workflow]):
|
|||||||
pre_file_name = os.path.splitext(full_path)[0]
|
pre_file_name = os.path.splitext(full_path)[0]
|
||||||
# 理论上也只有一个结果
|
# 理论上也只有一个结果
|
||||||
for danmaku_file in glob("{}*xml".format(pre_file_name)):
|
for danmaku_file in glob("{}*xml".format(pre_file_name)):
|
||||||
if os.path.exists(danmaku_file):
|
relpath = os.path.relpath(danmaku_file, BILILIVE_RECORDER_DIRECTORY)
|
||||||
relpath = os.path.relpath(danmaku_file, BILILIVE_RECORDER_DIRECTORY)
|
danmaku = DanmakuClip.query.filter(
|
||||||
# 确认是否已经添加
|
DanmakuClip.file == relpath,
|
||||||
already_add = False
|
DanmakuClip.base_path == BILILIVE_RECORDER_DIRECTORY
|
||||||
for danmaku_clip in workflow.danmaku_clips:
|
).first()
|
||||||
if danmaku_clip.file == relpath and danmaku_clip.base_path == BILILIVE_RECORDER_DIRECTORY:
|
if danmaku is None:
|
||||||
already_add = True
|
danmaku = DanmakuClip()
|
||||||
break
|
danmaku.file = relpath
|
||||||
if not already_add:
|
danmaku.base_path = BILILIVE_RECORDER_DIRECTORY
|
||||||
danmaku = DanmakuClip()
|
danmaku.offset = 0
|
||||||
danmaku.file = relpath
|
danmaku.workflow = workflow
|
||||||
danmaku.base_path = BILILIVE_RECORDER_DIRECTORY
|
db.session.add(danmaku)
|
||||||
danmaku.offset = 0
|
workflow.danmaku_clips.append(danmaku)
|
||||||
danmaku.workflow = workflow
|
for danmaku_file in glob(os.path.join(XIGUALIVE_RECORDER_DIRECTORY, "*.xml")):
|
||||||
db.session.add(danmaku)
|
relpath = os.path.relpath(danmaku_file, XIGUALIVE_RECORDER_DIRECTORY)
|
||||||
workflow.danmaku_clips.append(danmaku)
|
danmaku = DanmakuClip.query.filter(
|
||||||
|
DanmakuClip.file == relpath,
|
||||||
|
DanmakuClip.base_path == XIGUALIVE_RECORDER_DIRECTORY
|
||||||
|
).first()
|
||||||
|
if danmaku is None:
|
||||||
|
danmaku = DanmakuClip()
|
||||||
|
danmaku.file = relpath
|
||||||
|
danmaku.base_path = XIGUALIVE_RECORDER_DIRECTORY
|
||||||
|
danmaku.offset = 0
|
||||||
|
danmaku.workflow = workflow
|
||||||
|
db.session.add(danmaku)
|
||||||
|
workflow.danmaku_clips.append(danmaku)
|
||||||
commit_item()
|
commit_item()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user