From c6535f0ce159003720daf76ec0b05ad380859c1f Mon Sep 17 00:00:00 2001 From: arabcoders Date: Fri, 1 Aug 2025 17:31:18 +0300 Subject: [PATCH 1/3] Update the pyinstaller build to include version number. --- .gitignore | 1 + app.spec | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d276d02e..beaaf587 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ __pycache__ .idea dist build +version.txt diff --git a/app.spec b/app.spec index 149a3c00..9d8ad836 100644 --- a/app.spec +++ b/app.spec @@ -1,8 +1,24 @@ +import importlib.util import os import platform import sys import tomllib +spec = importlib.util.spec_from_file_location("version", "./app/library/version.py") +ver = importlib.util.module_from_spec(spec) +spec.loader.exec_module(ver) + +with open("version.txt", "w") as f: + f.write(f"""# UTF-8 +# FileVersion: "{ver.APP_VERSION}" +# ProductVersion: "{ver.APP_VERSION}" +# FileDescription: "YTPTube build {ver.APP_COMMIT_SHA}" +# ProductName: "YTPTube" +# OriginalFilename: "ytptube.exe" +# InternalName: "YTPTube" +# Comments: "Built from {ver.APP_BRANCH} at {ver.APP_BUILD_DATE}" +""") + block_cipher = None machine = platform.machine().lower() @@ -31,7 +47,7 @@ hidden = [ "engineio", "engineio.async_drivers.aiohttp", "socketio.async_drivers.aiohttp", - "app" + "app", ] hidden = [f.replace("-", "_") for f in hidden] @@ -63,7 +79,8 @@ exe = EXE( # type: ignore # noqa: F821 debug=False, strip=False, upx=True, - console=False, # Turn on to True if you want a console window for debugging. + version="version.txt", + console=False, # Turn on to True if you want a console window for debugging. icon="ui/public/favicon.ico", onefile=True, ) From 92a6101bbe159a5b47f827b38dbd14488d0a7593 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Fri, 1 Aug 2025 17:37:46 +0300 Subject: [PATCH 2/3] Add exception catch for sub download task --- app/library/DownloadQueue.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index 6521d2ca..e7b5f3c2 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -963,6 +963,9 @@ class DownloadQueue(metaclass=Singleton): if entry.info.status not in ("finished", "skip"): entry.info.status = "error" + except Exception as e: + entry.info.status = "error" + entry.info.error = str(e) finally: if entry.info._id in self._active: self._active.pop(entry.info._id, None) From bac1a51a4a00177f363ad95dba7eb9cfe4637c83 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Fri, 1 Aug 2025 18:07:28 +0300 Subject: [PATCH 3/3] Do not register signals in non posix OS --- app/library/Download.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/library/Download.py b/app/library/Download.py index 39de81d2..7cdc29d6 100644 --- a/app/library/Download.py +++ b/app/library/Download.py @@ -280,12 +280,14 @@ class Download: self.started_time = int(time.time()) - def mark_cancelled(*_): - cls._interrupted = True - cls.to_screen("[info] Interrupt received, exiting cleanly...") - raise SystemExit(130) # noqa: TRY301 + if "posix" == os.name: - signal.signal(signal.SIGUSR1, mark_cancelled) + def mark_cancelled(*_) -> None: + cls._interrupted = True + cls.to_screen("[info] Interrupt received, exiting cleanly...") + raise SystemExit(130) # noqa: TRY301 + + signal.signal(signal.SIGUSR1, mark_cancelled) if isinstance(self.info_dict, dict) and len(self.info_dict) > 1: self.logger.debug(f"Downloading '{self.info.url}' using pre-info.")