62 lines
3.1 KiB
Python
62 lines
3.1 KiB
Python
|
|
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)
|