删除无用内容
This commit is contained in:
parent
7dd287cdab
commit
314e7aff54
@ -1,5 +0,0 @@
|
|||||||
from entity.File import File
|
|
||||||
|
|
||||||
|
|
||||||
class DanmakuFile(File):
|
|
||||||
...
|
|
@ -1,25 +0,0 @@
|
|||||||
import os
|
|
||||||
from os import PathLike
|
|
||||||
from typing import Union, Optional
|
|
||||||
|
|
||||||
|
|
||||||
class File(object):
|
|
||||||
base_path: Optional[Union[os.PathLike[str], str]]
|
|
||||||
file: Union[PathLike[str], str]
|
|
||||||
|
|
||||||
def __init__(self, file: Union[os.PathLike[str], str], base_path: Optional[Union[os.PathLike[str], str]] = None):
|
|
||||||
self.file = file
|
|
||||||
self.base_path = base_path
|
|
||||||
|
|
||||||
@property
|
|
||||||
def full_path(self) -> str:
|
|
||||||
if self.base_path is None or len(self.base_path.strip()) == 0:
|
|
||||||
return self.file
|
|
||||||
else:
|
|
||||||
return os.path.join(self.base_path, self.file)
|
|
||||||
|
|
||||||
def abs_path(self) -> str:
|
|
||||||
return os.path.abspath(self.full_path)
|
|
||||||
|
|
||||||
def exist(self) -> bool:
|
|
||||||
return os.path.exists(self.full_path)
|
|
@ -1,18 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from entity.File import File
|
|
||||||
|
|
||||||
|
|
||||||
class VideoClip(File):
|
|
||||||
duration: Optional[float]
|
|
||||||
|
|
||||||
def __init__(self, file, base_path):
|
|
||||||
super(VideoClip, self).__init__(file, base_path)
|
|
||||||
self.duration = None
|
|
||||||
|
|
||||||
def set_duration(self, duration: Optional[float]):
|
|
||||||
self.duration = duration
|
|
||||||
|
|
||||||
def evaluate_duration(self):
|
|
||||||
if self.duration is None or self.duration < 0:
|
|
||||||
...
|
|
@ -1,5 +0,0 @@
|
|||||||
from entity.File import File
|
|
||||||
|
|
||||||
|
|
||||||
class VideoPart(File):
|
|
||||||
...
|
|
@ -1,118 +0,0 @@
|
|||||||
import os
|
|
||||||
from datetime import datetime
|
|
||||||
from hashlib import md5
|
|
||||||
from typing import Union, Optional
|
|
||||||
|
|
||||||
from config import VIDEO_TITLE
|
|
||||||
from entity.DanmakuFile import DanmakuFile
|
|
||||||
from entity.VideoClip import VideoClip
|
|
||||||
from entity.VideoPart import VideoPart
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowItem(object):
|
|
||||||
automatic: bool
|
|
||||||
finished: bool
|
|
||||||
conflict: bool
|
|
||||||
editing: bool
|
|
||||||
error: bool
|
|
||||||
delay_time: int
|
|
||||||
mode: int
|
|
||||||
videoParts: list[VideoPart]
|
|
||||||
videos: list[VideoClip]
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.automatic = False
|
|
||||||
self.finished = False
|
|
||||||
self.conflict = False
|
|
||||||
self.editing = False
|
|
||||||
self.error = False
|
|
||||||
self.title = VIDEO_TITLE
|
|
||||||
self.create_time = datetime.now()
|
|
||||||
self.delay_time = 0
|
|
||||||
self.mode = WorkflowModeEnum.MANUAL
|
|
||||||
self.danmakus = []
|
|
||||||
self.subtitleFiles = []
|
|
||||||
self.videos = []
|
|
||||||
self.videoParts = []
|
|
||||||
|
|
||||||
@property
|
|
||||||
def id(self):
|
|
||||||
return md5(self.name.encode("utf-8")).hexdigest()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
return self.title.format(self.create_time.strftime("%Y%m%d"))
|
|
||||||
|
|
||||||
def mode_set(self, mode: int):
|
|
||||||
self.mode = mode
|
|
||||||
|
|
||||||
def mode_add(self, mode: int):
|
|
||||||
self.mode = self.mode | mode
|
|
||||||
|
|
||||||
def mode_del(self, mode: int):
|
|
||||||
self.mode = self.mode ^ mode
|
|
||||||
|
|
||||||
def mode_has(self, mode: int) -> bool:
|
|
||||||
return self.mode & mode == mode
|
|
||||||
|
|
||||||
def mode_add_merge(self):
|
|
||||||
return self.mode_add(WorkflowModeEnum.MERGE)
|
|
||||||
|
|
||||||
def mode_del_merge(self):
|
|
||||||
return self.mode_del(WorkflowModeEnum.MERGE)
|
|
||||||
|
|
||||||
def mode_has_merge(self) -> bool:
|
|
||||||
return self.mode_has(WorkflowModeEnum.MERGE)
|
|
||||||
|
|
||||||
def mode_add_danmaku(self):
|
|
||||||
return self.mode_add(WorkflowModeEnum.DANMAKU)
|
|
||||||
|
|
||||||
def mode_del_danmaku(self):
|
|
||||||
return self.mode_del(WorkflowModeEnum.DANMAKU)
|
|
||||||
|
|
||||||
def mode_has_danmaku(self) -> bool:
|
|
||||||
return self.mode_has(WorkflowModeEnum.DANMAKU)
|
|
||||||
|
|
||||||
def mode_add_encode(self):
|
|
||||||
return self.mode_add(WorkflowModeEnum.ENCODE)
|
|
||||||
|
|
||||||
def mode_del_encode(self):
|
|
||||||
return self.mode_del(WorkflowModeEnum.ENCODE)
|
|
||||||
|
|
||||||
def mode_has_encode(self) -> bool:
|
|
||||||
return self.mode_has(WorkflowModeEnum.ENCODE)
|
|
||||||
|
|
||||||
def mode_add_split(self):
|
|
||||||
return self.mode_add(WorkflowModeEnum.SPLIT)
|
|
||||||
|
|
||||||
def mode_del_split(self):
|
|
||||||
return self.mode_del(WorkflowModeEnum.SPLIT)
|
|
||||||
|
|
||||||
def mode_has_split(self) -> bool:
|
|
||||||
return self.mode_has(WorkflowModeEnum.SPLIT)
|
|
||||||
|
|
||||||
def add_video(self, video_file: Union[VideoClip, os.PathLike[str], str], base_path: Optional[Union[os.PathLike[str], str]] = None) -> VideoClip:
|
|
||||||
if isinstance(video_file, VideoClip):
|
|
||||||
self.videos.append(video_file)
|
|
||||||
else:
|
|
||||||
video_file = VideoClip(video_file, base_path)
|
|
||||||
self.videos.append(video_file)
|
|
||||||
return video_file
|
|
||||||
|
|
||||||
def add_danmaku(self, danmaku_file: Union[DanmakuFile, os.PathLike[str], str], base_path: Optional[Union[os.PathLike[str], str]] = None) -> DanmakuFile:
|
|
||||||
if isinstance(danmaku_file, DanmakuFile):
|
|
||||||
self.danmakus.append(danmaku_file)
|
|
||||||
else:
|
|
||||||
danmaku_file = DanmakuFile(danmaku_file, base_path)
|
|
||||||
self.danmakus.append(danmaku_file)
|
|
||||||
return danmaku_file
|
|
||||||
|
|
||||||
|
|
||||||
class WorkflowModeEnum:
|
|
||||||
MERGE = 1 << 4
|
|
||||||
DANMAKU = 1 << 3
|
|
||||||
ENCODE = 1 << 2
|
|
||||||
SPLIT = 1 << 1
|
|
||||||
DANMAKU_DUAL = DANMAKU | ENCODE | SPLIT
|
|
||||||
DANMAKU_SINGLE = DANMAKU | ENCODE | SPLIT
|
|
||||||
MANUAL = 0
|
|
Loading…
x
Reference in New Issue
Block a user