update refactoring and add new features

This commit is contained in:
2026-07-24 20:55:58 -07:00
parent 7f12bc7f40
commit 03fbbbcf28
69 changed files with 16332 additions and 17600 deletions
+12 -8
View File
@@ -14,11 +14,6 @@ def _repo_root() -> Path:
return package_dir.parent
REPO_ROOT = _repo_root()
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))
def main(argv: list[str] | None = None) -> int:
args = list(sys.argv[1:] if argv is None else argv)
if not args:
@@ -35,10 +30,19 @@ def main(argv: list[str] | None = None) -> int:
url = str(args[0] or "").strip()
captured_stdout = io.StringIO()
captured_stderr = io.StringIO()
with contextlib.redirect_stdout(captured_stdout), contextlib.redirect_stderr(captured_stderr):
from plugins.mpv.pipeline_helper import _run_op
payload = _run_op("ytdlp-formats", {"url": url})
_root_str = str(_repo_root())
_path_added = _root_str not in sys.path
if _path_added:
sys.path.insert(0, _root_str)
try:
with contextlib.redirect_stdout(captured_stdout), contextlib.redirect_stderr(captured_stderr):
from plugins.mpv.pipeline_helper import _run_op
payload = _run_op("ytdlp-formats", {"url": url})
finally:
if _path_added:
sys.path.remove(_root_str)
noisy_stdout = captured_stdout.getvalue().strip()
noisy_stderr = captured_stderr.getvalue().strip()