This commit is contained in:
2026-02-09 17:45:57 -08:00
parent 567472bca0
commit 2fd13a6b3f
6 changed files with 57 additions and 34 deletions

28
.luarc.json Normal file
View File

@@ -0,0 +1,28 @@
{
"runtime": {
"version": "LuaJIT",
"path": [
"?.lua",
"?/init.lua",
"MPV/portable_config/scripts/uosc/scripts/uosc/?.lua",
"MPV/portable_config/scripts/uosc/scripts/uosc/?/init.lua",
"MPV/LUA/?.lua",
"MPV/LUA/?/init.lua"
]
},
"workspace": {
"library": [
"MPV/portable_config/scripts/uosc/scripts/uosc",
"MPV/portable_config/scripts/uosc/scripts/uosc/lib",
"MPV/LUA"
],
"checkThirdParty": false
},
"diagnostics": {
"disable": [
"undefined-global",
"undefined-field",
"need-check-nil"
]
}
}

4
CLI.py
View File

@@ -41,7 +41,7 @@ import uuid
from copy import deepcopy from copy import deepcopy
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, cast, Callable from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, cast
import typer import typer
from prompt_toolkit import PromptSession from prompt_toolkit import PromptSession
@@ -98,7 +98,7 @@ from ProviderCore.registry import provider_inline_query_choices
# Selection parsing and REPL lexer moved to SYS.cli_parsing # Selection parsing and REPL lexer moved to SYS.cli_parsing
from SYS.cli_parsing import Lexer, DRIVE_RE, KEY_PREFIX_RE, TOKEN_PATTERN, SELECTION_RANGE_RE, SelectionSyntax, SelectionFilterSyntax, MedeiaLexer from SYS.cli_parsing import SelectionSyntax, SelectionFilterSyntax, MedeiaLexer
# SelectionFilterSyntax moved to SYS.cli_parsing (imported above) # SelectionFilterSyntax moved to SYS.cli_parsing (imported above)

View File

@@ -6,11 +6,8 @@ import json
import sqlite3 import sqlite3
import time import time
import os import os
import traceback
import datetime import datetime
import sys import sys
import getpass
import hashlib
import tempfile import tempfile
from copy import deepcopy from copy import deepcopy
from pathlib import Path from pathlib import Path
@@ -19,7 +16,7 @@ from SYS.logger import log
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
from SYS.utils import expand_path from SYS.utils import expand_path
from SYS.database import db, get_config_all, save_config_value, rows_to_config from SYS.database import db, get_config_all, rows_to_config
SCRIPT_DIR = Path(__file__).resolve().parent SCRIPT_DIR = Path(__file__).resolve().parent

View File

@@ -2,12 +2,15 @@
import sys import sys
import inspect import inspect
import logging
import threading import threading
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional
from SYS.rich_display import console_for from SYS.rich_display import console_for
logger = logging.getLogger(__name__)
# Global DB logger set later to avoid circular imports # Global DB logger set later to avoid circular imports
_DB_LOGGER = None _DB_LOGGER = None

View File

@@ -1,3 +1,4 @@
# pyright: reportUnusedFunction=false
from typing import Any, Dict, Sequence, List, Optional from typing import Any, Dict, Sequence, List, Optional
import os import os
import sys import sys
@@ -124,10 +125,12 @@ def _repo_log_dir() -> Path:
return d return d
# pyright: ignore[reportUnusedFunction]
def _helper_log_file() -> Path: def _helper_log_file() -> Path:
return _repo_log_dir() / "medeia-mpv-helper.log" return _repo_log_dir() / "medeia-mpv-helper.log"
# pyright: ignore[reportUnusedFunction]
def _lua_log_file() -> Path: def _lua_log_file() -> Path:
return _repo_log_dir() / "medeia-mpv-lua.log" return _repo_log_dir() / "medeia-mpv-lua.log"
@@ -2089,7 +2092,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
else: else:
print("MPV logs from database (mpv module, most recent first):") print("MPV logs from database (mpv module, most recent first):")
if mpv_logs: if mpv_logs:
for timestamp, level, module, message in mpv_logs: for timestamp, level, _module, message in mpv_logs:
ts = str(timestamp or "").strip() ts = str(timestamp or "").strip()
if ts: if ts:
print(f"[{ts}] [{level}] {message}") print(f"[{ts}] [{level}] {message}")
@@ -2248,7 +2251,7 @@ def _start_mpv(
except Exception as e: except Exception as e:
debug(f"Error starting MPV: {e}", file=sys.stderr) debug(f"Error starting MPV: {e}", file=sys.stderr)
# pyright: ignore[reportCallIssue]
CMDLET = Cmdlet( CMDLET = Cmdlet(
name=".mpv", name=".mpv",
alias=[".pipe", "pipe", "playlist", "queue", "ls-pipe"], alias=[".pipe", "pipe", "playlist", "queue", "ls-pipe"],

View File

@@ -1,3 +1,4 @@
# pyright: reportUnusedFunction=false
from __future__ import annotations from __future__ import annotations
import hashlib import hashlib
@@ -960,26 +961,20 @@ class YtDlpTool:
# Special handling for format keywords explicitly passed in via options # Special handling for format keywords explicitly passed in via options
if opts.ytdl_format == "audio": if opts.ytdl_format == "audio":
try: try:
opts = opts._replace(mode="audio", ytdl_format=None) import dataclasses as _dc
except Exception:
try:
import dataclasses as _dc
opts = _dc.replace(opts, mode="audio", ytdl_format=None) opts = _dc.replace(opts, mode="audio", ytdl_format=None)
except Exception: except Exception:
from SYS.logger import logger from SYS.logger import logger
logger.exception("Failed to set opts mode to audio via dataclasses.replace") logger.exception("Failed to set opts mode to audio via dataclasses.replace")
elif opts.ytdl_format == "video": elif opts.ytdl_format == "video":
try: try:
opts = opts._replace(mode="video", ytdl_format=None) import dataclasses as _dc
except Exception:
try:
import dataclasses as _dc
opts = _dc.replace(opts, mode="video", ytdl_format=None) opts = _dc.replace(opts, mode="video", ytdl_format=None)
except Exception: except Exception:
from SYS.logger import logger from SYS.logger import logger
logger.exception("Failed to set opts mode to video via dataclasses.replace") logger.exception("Failed to set opts mode to video via dataclasses.replace")
if opts.no_playlist: if opts.no_playlist:
base_options["noplaylist"] = True base_options["noplaylist"] = True
@@ -992,15 +987,12 @@ class YtDlpTool:
if configured_format.lower() == "audio": if configured_format.lower() == "audio":
# Default to audio-only downloads # Default to audio-only downloads
try: try:
opts = opts._replace(mode="audio") import dataclasses as _dc
except Exception:
try:
import dataclasses as _dc
opts = _dc.replace(opts, mode="audio") opts = _dc.replace(opts, mode="audio")
except Exception: except Exception:
from SYS.logger import logger from SYS.logger import logger
logger.exception("Failed to set opts mode to audio via dataclasses.replace (configured default)") logger.exception("Failed to set opts mode to audio via dataclasses.replace (configured default)")
ytdl_format = None ytdl_format = None
else: else:
# Leave ytdl_format None so that default_format(opts.mode) # Leave ytdl_format None so that default_format(opts.mode)
@@ -1854,7 +1846,7 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
info = None info = None
else: else:
with yt_dlp.YoutubeDL(ytdl_options) as ydl: # type: ignore[arg-type] with yt_dlp.YoutubeDL(ytdl_options) as ydl: # type: ignore[arg-type]
info = ydl.extract_info(opts.url, download=True) info = cast(Dict[str, Any], ydl.extract_info(opts.url, download=True))
except Exception as exc: except Exception as exc:
retry_attempted = False retry_attempted = False
if _is_http_403(exc) and not ytdl_options.get("download_sections"): if _is_http_403(exc) and not ytdl_options.get("download_sections"):
@@ -1879,7 +1871,7 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
fallback_options["extractor_args"] = extractor_args fallback_options["extractor_args"] = extractor_args
with yt_dlp.YoutubeDL(fallback_options) as ydl: # type: ignore[arg-type] with yt_dlp.YoutubeDL(fallback_options) as ydl: # type: ignore[arg-type]
info = ydl.extract_info(opts.url, download=True) info = cast(Dict[str, Any], ydl.extract_info(opts.url, download=True))
except Exception as exc2: except Exception as exc2:
log(f"yt-dlp failed: {exc2}", file=sys.stderr) log(f"yt-dlp failed: {exc2}", file=sys.stderr)
if debug_logger is not None: if debug_logger is not None: