Fix: fixes for windows native

This commit is contained in:
arabcoders 2025-12-27 23:58:36 +03:00
parent 633f192c8f
commit ac4ce99b01
5 changed files with 17 additions and 7 deletions

View file

@ -643,7 +643,7 @@ def arg_converter(
# important to ignore external config files. # important to ignore external config files.
args = "--ignore-config " + args args = "--ignore-config " + args
opts = yt_dlp.parse_options(shlex.split(args)).ydl_opts opts = yt_dlp.parse_options(shlex.split(args, posix=os.name != "nt")).ydl_opts
diff = {k: v for k, v in opts.items() if default_opts[k] != v} if not keep_defaults else opts.items() diff = {k: v for k, v in opts.items() if default_opts[k] != v} if not keep_defaults else opts.items()
if "postprocessors" in diff: if "postprocessors" in diff:
diff["postprocessors"] = [pp for pp in diff["postprocessors"] if pp not in default_opts["postprocessors"]] diff["postprocessors"] = [pp for pp in diff["postprocessors"] if pp not in default_opts["postprocessors"]]

View file

@ -117,13 +117,13 @@ class Config(metaclass=Singleton):
extract_info_timeout: int = 70 extract_info_timeout: int = 70
"""The timeout to use for extracting video information.""" """The timeout to use for extracting video information."""
db_file: str = "{config_path}/ytptube.db" db_file: str = "{config_path}{os_sep}ytptube.db"
"""The path to the database file.""" """The path to the database file."""
archive_file: str = "{config_path}/archive.log" archive_file: str = "{config_path}{os_sep}archive.log"
"""The path to the download archive file.""" """The path to the download archive file."""
apprise_config: str = "{config_path}/apprise.yml" apprise_config: str = "{config_path}{os_sep}apprise.yml"
"""The path to the Apprise configuration file.""" """The path to the Apprise configuration file."""
ui_update_title: bool = True ui_update_title: bool = True
@ -295,6 +295,9 @@ class Config(metaclass=Singleton):
_manager: SyncManager | None = None _manager: SyncManager | None = None
"The manager instance." "The manager instance."
os_sep: str = os.path.sep
"The system path separator."
@staticmethod @staticmethod
def get_instance(is_native: bool = False) -> "Config": def get_instance(is_native: bool = False) -> "Config":
cls = Config(is_native) cls = Config(is_native)
@ -528,7 +531,7 @@ class Config(metaclass=Singleton):
dict[str, str]: The replacer variables. dict[str, str]: The replacer variables.
""" """
keys: tuple[str] = ("download_path", "temp_path", "config_path", "archive_file") keys: tuple[str] = ("os_sep", "download_path", "temp_path", "config_path", "archive_file")
return {k: getattr(self, k) for k in keys} return {k: getattr(self, k) for k in keys}
@staticmethod @staticmethod

View file

@ -69,6 +69,8 @@ def open_browser_when_ready(url: str, timeout: float = 5.0) -> None:
def app_start(host: str, port: int) -> None: def app_start(host: str, port: int) -> None:
import asyncio import asyncio
from aiohttp.web_runner import GracefulExit
from app.main import Main from app.main import Main
try: try:
@ -77,7 +79,10 @@ def app_start(host: str, port: int) -> None:
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) asyncio.set_event_loop(loop)
Main(is_native=True).start(host, port) try:
Main(is_native=True).start(host, port)
except GracefulExit:
sys.exit(0)
def update_env_file(env_file: pathlib.Path, port: int) -> None: def update_env_file(env_file: pathlib.Path, port: int) -> None:

View file

@ -4,6 +4,7 @@ import time
from aiohttp import web from aiohttp import web
from aiohttp.web import Request, Response from aiohttp.web import Request, Response
from aiohttp.web_runner import GracefulExit
from app.library.config import Config from app.library.config import Config
from app.library.DownloadQueue import DownloadQueue from app.library.DownloadQueue import DownloadQueue
@ -117,6 +118,7 @@ async def shutdown_system(request: Request, config: Config, encoder: Encoder, no
await asyncio.sleep(0.5) await asyncio.sleep(0.5)
await app.shutdown() await app.shutdown()
await app.cleanup() await app.cleanup()
raise GracefulExit
# Schedule shutdown after response # Schedule shutdown after response
asyncio.create_task(do_shutdown()) asyncio.create_task(do_shutdown())

View file

@ -38,7 +38,7 @@ async def cli_post(config: Config, notify: EventBus, sid: str, data: str):
try: try:
LOG.info(f"Cli command from client '{sid}'. '{data}'") LOG.info(f"Cli command from client '{sid}'. '{data}'")
args: list[str] = ["yt-dlp", *shlex.split(data)] args: list[str] = ["yt-dlp", *shlex.split(data, posix=os.name != "nt")]
_env: dict[str, str] = os.environ.copy() _env: dict[str, str] = os.environ.copy()
_env.update( _env.update(
{ {