关联关系

This commit is contained in:
Jerry Yan 2022-04-15 14:49:39 +08:00
parent e72eeb1f0e
commit 900b1bd614
3 changed files with 6 additions and 18 deletions

4
app.py
View File

@ -1,5 +1,5 @@
from flask import Flask
from config import load_config, WEB_HOST, WEB_PORT
from config import load_config
from controller.view.main_blueprint import blueprint as view_main_blueprint
from controller.api.config_blueprint import blueprint as api_config_blueprint
from controller.api.collector_blueprint import blueprint as api_collector_blueprint
@ -27,4 +27,4 @@ with app.app_context():
db.create_all(app=app)
if __name__ == '__main__':
app.run(WEB_HOST, WEB_PORT)
app.run()

View File

@ -30,12 +30,6 @@ VIDEO_CLIP_OVERFLOW_SEC = 5
BILILIVE_RECORDER_DIRECTORY = "./"
# xigua_dir
XIGUALIVE_RECORDER_DIRECTORY = "./"
# [web]
# host
WEB_HOST = "0.0.0.0"
# port
WEB_PORT = 5000
def load_config():
if not os.path.exists("config.ini"):
@ -69,11 +63,6 @@ def load_config():
section = config['recorder']
BILILIVE_RECORDER_DIRECTORY = section.get('bili_dir', BILILIVE_RECORDER_DIRECTORY)
XIGUALIVE_RECORDER_DIRECTORY = section.get('xigua_dir', XIGUALIVE_RECORDER_DIRECTORY)
if config.has_section("web"):
global WEB_HOST, WEB_PORT
section = config['web']
WEB_HOST = section.get('host', WEB_HOST)
WEB_PORT = section.getint('port', WEB_PORT)
return True
@ -101,10 +90,6 @@ def get_config():
'bili_dir': BILILIVE_RECORDER_DIRECTORY,
'xigua_dir': XIGUALIVE_RECORDER_DIRECTORY,
},
'web': {
'host': WEB_HOST,
'port': WEB_PORT,
}
}
return config

View File

@ -1,6 +1,9 @@
import os
from typing import TYPE_CHECKING
from . import db
if TYPE_CHECKING:
from .Workflow import Workflow
class DanmakuClip(db.Model):
@ -9,7 +12,7 @@ class DanmakuClip(db.Model):
file = db.Column(db.String(255))
offset = db.Column(db.Float, nullable=False, default=0)
workflow_id = db.Column(db.Integer, db.ForeignKey('workflow.id'))
workflow = db.relationship("Workflow", backref=db.backref("danmaku_clips", lazy="dynamic"))
workflow: "Workflow" = db.relationship("Workflow", uselist=False, backref=db.backref("danmaku_clips"))
@property
def full_path(self):