establish config defaults

This commit is contained in:
2026-05-16 16:22:24 +03:00
parent 5d4cba3df3
commit 8e3a7e3920
6 changed files with 38 additions and 13 deletions
+11 -4
View File
@@ -1,16 +1,23 @@
from __future__ import annotations
import json
import os
from pathlib import Path
from typing import Any, Dict, List, Optional
def _default_ffmpeg_path() -> str:
if os.name == "nt":
return "./bin/ffmpeg.exe"
return "./bin/ffmpeg"
DEFAULT_CONFIG: Dict[str, Any] = {
"playlists": [],
"download_mode": "audio",
"download_mode": "video",
"max_download_quality": "1080p",
"save_path": "./downloads",
"ffmpeg_path": "ffmpeg",
"ffmpeg_path": _default_ffmpeg_path(),
}
@@ -40,12 +47,12 @@ class Settings:
"playlists": [
{
"url": "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID",
"download_mode": "audio",
"download_mode": "video",
"max_download_quality": "1080p",
"save_path": "./downloads",
}
],
"ffmpeg_path": "ffmpeg",
"ffmpeg_path": _default_ffmpeg_path(),
}
path.write_text(json.dumps(default_payload, indent=2) + "\n", encoding="utf-8")
+6 -2
View File
@@ -19,12 +19,16 @@ class Downloader:
def build_format(max_download_quality) -> str:
def parse_height_cap(value) -> int | None:
if value is None:
return None
return 1080
if isinstance(value, int):
return value if value > 0 else None
s = str(value).strip().lower()
if not s or s in {"best", "max", "auto", "none", "null"}:
if not s:
return 1080
if s in {"best", "max", "auto"}:
return None
if s in {"none", "null"}:
return 1080
digits = "".join(ch for ch in s if ch.isdigit())
if not digits:
return None