Spiltte main.py
This commit is contained in:
63
config.py
Normal file
63
config.py
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env -S uv run --script
|
||||
"""
|
||||
Konfiguration und Konstanten für den Video Download Helper
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Hilfsfunktionen für den Ressourcenpfad
|
||||
def get_base_path():
|
||||
"""Gibt den Basispfad für Ressourcen zurück, funktioniert sowohl für PyInstaller als auch für reguläre Ausführung."""
|
||||
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
|
||||
# PyInstaller-Bundled-Modus
|
||||
return sys._MEIPASS
|
||||
else:
|
||||
# Regulärer Modus
|
||||
return os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def get_user_data_dir():
|
||||
if getattr(sys, 'frozen', False):
|
||||
return os.path.dirname(sys.executable)
|
||||
else:
|
||||
return os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def get_temp_dir():
|
||||
"""Gibt den Pfad zum temporären Verzeichnis zurück und erstellt es bei Bedarf."""
|
||||
base_dir = get_base_path()
|
||||
temp_dir = os.path.join(base_dir, "temp")
|
||||
if not os.path.exists(temp_dir):
|
||||
os.makedirs(temp_dir, exist_ok=True)
|
||||
return temp_dir
|
||||
|
||||
def get_user_presets_dir():
|
||||
# Presets-Ordner neben der EXE (bzw. Script)
|
||||
base = get_user_data_dir()
|
||||
path = os.path.join(base, "presets")
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path, exist_ok=True)
|
||||
return path
|
||||
|
||||
# Konfigurationspfade
|
||||
CONFIG_FILE = os.path.join(get_user_data_dir(), "config.json")
|
||||
PRESETS_DIR = os.path.join(get_base_path(), "presets") # Nur für Lesezugriff auf mitgelieferte Presets
|
||||
|
||||
# Standardkonfiguration
|
||||
DEFAULT_CONFIG = {
|
||||
"output_dir": "",
|
||||
"use_local_ytdlp": True,
|
||||
"last_preset": "",
|
||||
"presets": [],
|
||||
"ytdlp_flags": {
|
||||
"ignore_config": False,
|
||||
"remux_mkv": False,
|
||||
"embed_metadata": False,
|
||||
"use_ffmpeg_location": False
|
||||
},
|
||||
"hide_default_presets": False,
|
||||
"enable_adn_tab": False,
|
||||
"mkvmerge_path": "C:\\Program Files\\MKVToolNix\\mkvmerge.exe",
|
||||
"ffmpeg_path": "C:\\ffmpeg\\bin\\ffmpeg.exe"
|
||||
}
|
||||
|
||||
# Template-Variablen für Serien
|
||||
SERIES_TEMPLATE = "{series} S{season}E{episode}{extension}"
|
Reference in New Issue
Block a user