diff --git a/video2x/decoder.py b/video2x/decoder.py index 1e8a3ad..809de73 100755 --- a/video2x/decoder.py +++ b/video2x/decoder.py @@ -156,18 +156,18 @@ class VideoDecoder(threading.Thread): frame_index += 1 # most likely "not enough image data" - except ValueError as e: - self.exception = e + except ValueError as error: + self.exception = error # ignore queue closed - if "is closed" not in str(e): - logger.exception(e) + if "is closed" not in str(error): + logger.exception(error) break # send exceptions into the client connection pipe - except Exception as e: - self.exception = e - logger.exception(e) + except Exception as error: + self.exception = error + logger.exception(error) break else: logger.debug("Decoding queue depleted") diff --git a/video2x/encoder.py b/video2x/encoder.py index 4b77c01..509a2fe 100755 --- a/video2x/encoder.py +++ b/video2x/encoder.py @@ -165,9 +165,9 @@ class VideoEncoder(threading.Thread): frame_index += 1 # send exceptions into the client connection pipe - except Exception as e: - self.exception = e - logger.exception(e) + except Exception as error: + self.exception = error + logger.exception(error) break else: logger.debug("Encoding queue depleted") diff --git a/video2x/interpolator.py b/video2x/interpolator.py index 44e0f7a..92514ce 100755 --- a/video2x/interpolator.py +++ b/video2x/interpolator.py @@ -112,8 +112,8 @@ class Interpolator(multiprocessing.Process): except (SystemExit, KeyboardInterrupt): break - except Exception as e: - logger.exception(e) + except Exception as error: + logger.exception(error) break logger.opt(colors=True).info( diff --git a/video2x/upscaler.py b/video2x/upscaler.py index 40ba0c5..8e84eac 100755 --- a/video2x/upscaler.py +++ b/video2x/upscaler.py @@ -194,8 +194,8 @@ class Upscaler(multiprocessing.Process): except (SystemExit, KeyboardInterrupt): break - except Exception as e: - logger.exception(e) + except Exception as error: + logger.exception(error) break logger.opt(colors=True).info( diff --git a/video2x/video2x.py b/video2x/video2x.py index 979bc4e..3c165fd 100755 --- a/video2x/video2x.py +++ b/video2x/video2x.py @@ -27,7 +27,7 @@ __ __ _ _ ___ __ __ Name: Video2X Creator: K4YT3X Date Created: February 24, 2018 -Last Modified: March 21, 2022 +Last Modified: April 5, 2022 Editor: BrianPetkovsek Last Modified: June 17, 2019 @@ -49,10 +49,10 @@ import signal import sys import time -import cv2 import ffmpeg +from cv2 import cv2 from loguru import logger -from rich import print +from rich import print as rich_print from rich.console import Console from rich.file_proxy import FileProxy from rich.progress import ( @@ -80,13 +80,11 @@ except ImportError: else: ENABLE_HOTKEY = True -LEGAL_INFO = """Video2X\t\t{} +LEGAL_INFO = f"""Video2X\t\t{__version__} Author:\t\tK4YT3X License:\tGNU AGPL v3 Github Page:\thttps://github.com/k4yt3x/video2x -Contact:\ti@k4yt3x.com""".format( - __version__ -) +Contact:\ti@k4yt3x.com""" # algorithms available for upscaling tasks UPSCALING_ALGORITHMS = [ @@ -133,7 +131,8 @@ class Video2X: def __init__(self) -> None: self.version = __version__ - def _get_video_info(self, path: pathlib.Path) -> tuple: + @staticmethod + def _get_video_info(path: pathlib.Path) -> tuple: """ get video file information with FFmpeg @@ -329,17 +328,16 @@ class Video2X: logger.info("Processing has completed") # if SIGTERM is received or ^C is pressed - # TODO: pause and continue here - except (SystemExit, KeyboardInterrupt) as e: + except (SystemExit, KeyboardInterrupt) as error: self.progress.stop() logger.warning("Exit signal received, exiting gracefully") logger.warning("Press ^C again to force terminate") - exception.append(e) + exception.append(error) - except Exception as e: + except Exception as error: self.progress.stop() - logger.exception(e) - exception.append(e) + logger.exception(error) + exception.append(error) finally: @@ -575,7 +573,7 @@ def main() -> int: try: # display version and lawful informaition if "--version" in sys.argv: - print(LEGAL_INFO) + rich_print(LEGAL_INFO) return 0 # parse command line arguments @@ -585,7 +583,7 @@ def main() -> int: if not args.input.exists(): logger.critical(f"Cannot find input file: {args.input}") return 1 - elif not args.input.is_file(): + if not args.input.is_file(): logger.critical("Input path is not a file") return 1 @@ -633,8 +631,8 @@ def main() -> int: except KeyboardInterrupt: return 2 - except Exception as e: - logger.exception(e) + except Exception as error: + logger.exception(error) return 1 # if no exceptions were produced