30 lines
904 B
Python
30 lines
904 B
Python
import os
|
|
from typing import TYPE_CHECKING
|
|
|
|
from . import db
|
|
|
|
if TYPE_CHECKING:
|
|
from .VideoClip import VideoClip
|
|
|
|
|
|
class DanmakuClip(db.Model):
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
base_path = db.Column(db.String(255))
|
|
file = db.Column(db.String(255))
|
|
offset = db.Column(db.Float, nullable=False, default=0)
|
|
video_clip_id = db.Column(db.Integer, db.ForeignKey('video_clip.id'))
|
|
video_clip: "VideoClip" = db.relationship("VideoClip", uselist=False, backref=db.backref("danmaku_clips", lazy="subquery"))
|
|
|
|
@property
|
|
def full_path(self):
|
|
return os.path.abspath(os.path.join(self.base_path, self.file))
|
|
|
|
def to_json(self):
|
|
return {
|
|
"id": self.id,
|
|
"base_path": self.base_path,
|
|
"file": self.file,
|
|
"offset": self.offset,
|
|
"video_clip_id": self.video_clip_id,
|
|
}
|