diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 37d5743..a8152cf 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,7 +7,7 @@ name: Docker on: push: - branches: [ "main" ] + branches: [ "main","dev"] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: diff --git a/actions.py b/actions.py index f228111..98a217a 100644 --- a/actions.py +++ b/actions.py @@ -109,7 +109,5 @@ def events_action_delete(ssafile: SSAFile, event: SSAEvent, **kwargs): ssafile.events.remove(event) -def events_misc_remove_miscellaneous_events( - ssafile: SSAFile, **kwargs -): +def events_misc_remove_miscellaneous_events(ssafile: SSAFile, **kwargs): ssafile.remove_miscellaneous_events() diff --git a/main.py b/main.py index 7e8cba0..e467d3f 100755 --- a/main.py +++ b/main.py @@ -19,13 +19,14 @@ def postprocess_subtitles(files, args, pp_args): postprocesser = postprocessing.SubtitleFormatter(pp_args.postprocessing) - run(args.threads, postprocesser.format, files, args.disable_progress_bar) + output = run(args.threads, postprocesser.format, files, args.disable_progress_bar) + output_files = list(chain.from_iterable(output)) if args.exclude_mode == "e+a" and pp_args.exclude_subtitles != None: with open(pp_args.exclude_subtitles, "a") as f: - f.write("\n".join(files)) + f.write("\n".join(output_files)) - return files + return output_files def extract_subtitles(files, args, vid_args): diff --git a/postprocess.yml b/postprocess.yml index 1a8a970..0b60dd2 100644 --- a/postprocess.yml +++ b/postprocess.yml @@ -1,3 +1,18 @@ +# DEFINING A TASK: +# Order of operation: +# 1) selectors: Select objects to be processed +# - func(ssafile, **kwargs) -> obj +# 2) filter: filter out object from selectors +# - func(ssafile, item, **kwargs) -> bool +# 3) actions: run actions for each item that was selected +# - func(ssafile, item, **kwargs) -> output +# 4) run misc function +# - func(ssafile,**kwargs) -> output +# +# defining id saves the output of an action to a dict: outputs +# the value can be accessed using: {{outputs['id'][0]['PlayResX']}} +# + ass: tasks: - selectors: diff --git a/postprocessing.py b/postprocessing.py index aafddbe..f28e327 100644 --- a/postprocessing.py +++ b/postprocessing.py @@ -141,8 +141,8 @@ def format(self, path, save=True): runner = SubtitleRunner(self.workflows[ext]) self.log.debug(f"Formatting subtitle: {path}") - return runner.format(path, save=save) + runner.format(path, save=save) + return path else: - logger.warning("Unsupported format, skipping...") - return None + raise ValueError(f"Unsupported format: {path}") diff --git a/requirements.txt b/requirements.txt index 70ded7f..b1f1e8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ babelfish==0.6.1 cachetools==5.3.3 pgsrip==0.1.11 -pysubs2==1.7.2 +pysubs2==1.6.1 PyYAML==6.0.1 tqdm_loggable==0.2 watchdog==4.0.1 \ No newline at end of file diff --git a/utils.py b/utils.py index 3f400b1..803db1b 100644 --- a/utils.py +++ b/utils.py @@ -8,6 +8,7 @@ import time import traceback from itertools import chain +import functools from tqdm_loggable.auto import tqdm from tqdm_loggable.tqdm_logging import tqdm_logging @@ -18,32 +19,37 @@ def run(threads, function, files, disable_progress_bar=False): with tqdm(total=len(files), unit="file", disable=disable_progress_bar) as pbar: - run_output = [] - def _run_callback(out): - nonlocal run_output + output = [] + + def _run_callback(result): nonlocal pbar + nonlocal output + pbar.update(1) - run_output.append(out) + output.append(result) - def _error_callback(e): - logger.critical( - f"An Error occurred in thread...: {''.join(traceback.format_exception(e))}" - ) + def _error_callback(error): + nonlocal pbar + nonlocal output - with multiprocessing.Pool(threads) as pool: + pbar.update(1) + logger.critical(f"An error occurred in thread....") + traceback.print_exception(type(error), error, error.__traceback__) - for i in range(pbar.total): + with multiprocessing.Pool(threads) as pool: + for fp in files: pool.apply_async( function, - args=(files[i],), + args=(fp,), callback=_run_callback, error_callback=_error_callback, ) + pool.close() pool.join() - return run_output + return output def get_filelist(path, regex, excluded_files=[]):