Started rewriting video service

This commit is contained in:
Jacob Stevens 2022-10-06 06:02:31 -05:00
parent 352a91d4ca
commit be4aee2b27
1 changed files with 61 additions and 0 deletions

61
Video/videoservice.py Normal file
View File

@ -0,0 +1,61 @@
import time
import default
from Universal import ioservice
from Universal import loggingservice
class VideoService:
def __init__(self):
self.logger = loggingservice.Output(True, False)
self.video_settings = default.VideoSettings()
self.video_settings.updateSettings()
def startNewProcess(self, num=1):
self.logger.debugReport("[Video] startNewProcess")
self.current_library = num
self.total_processed = 0
self.is_processing = True
self.video_settings.updateLibrary(self.current_library)
if self.video_settings.library["Server"].lower().find("none") == -1:
self.video_settings.updateServer(self.video_settings.library["Server"])
while self.is_processing:
self.processLibraries()
def processLibraries(self, refreshLib = True):
self.logger.debugReport("[Video] processLibraries")
tmp_library_time = time.time()
if self.video_settings.library is not None:
if self.video_settings.library["Input"] is not None:
if refreshLib:
self.total_processed = 0
self.logger.infoReport("[Video] Current Library: " + self.video_settings.library["Name"])
self.current_library_list = ioservice.listAllFiles(self.video_settings.library["Input"])
if self.current_library_list is not None:
self.current_library_list = sorted(self.current_library_list)
if self.current_library_list is not None:
if refreshLib:
self.srt_list = []
for item_search in self.current_library_list:
if item_search.lower().find(".srt") != -1:
self.srt_list.append(item_search)
if self.srt_list is not None:
for item_search in self.srt_list:
self.current_library_list.remove(item_search)
self.logger.infoReport("[Video] Found a total of " + str(len(self.current_library_list)) + " files")
for self.current_file in self.current_library_list:
if self.total_processed != 0:
self.logger.infoReport("[Video] Total file remaining: " + str(len(self.current_library_list) - self.total_processed))
self.processVideo()
else:
self.logger.infoReport("[Video] Folder is empty")
ioservice.deleteEmptyFolders(self.video_settings.library["Input"])
else:
self.is_processing = False
else:
self.is_processing = False
self.logger.infoReport("[Video] Current Library: " + self.video_settings.library["Name"] + " Time Elapsed: " + time.strftime("%H:%M:%S", time.gmtime(time.time() - tmp_library_time)))
self.current_library += 1
def processVideo(self):
self.logger.debugReport("[Video] processVideo")
self.logger.infoReport("[Video] Current File: " + self.current_file)