Simplify no-tkinter file dialog fallback
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
```
|
```
|
||||||
5. In der UI Quelle auswaehlen, analysieren und Encoding starten.
|
5. In der UI Quelle auswaehlen, analysieren und Encoding starten.
|
||||||
|
|
||||||
Wenn die installierte Python-Version kein Tkinter mitbringt, oeffnet das Tool automatisch Windows-Dateidialoge fuer Quelle und Ausgabeordner und zeigt die Analyse sowie das Encoding-Log in der Konsole.
|
Wenn die installierte Python-Version kein Tkinter mitbringt, oeffnet das Tool automatisch einen Windows-Dateidialog fuer die Quelle, verwendet `H:\VOD` als Ausgabeordner und zeigt die Analyse sowie das Encoding-Log in der Konsole.
|
||||||
|
|
||||||
Fuer automatisierte CLI-Laeufe kann das Encoding direkt gestartet werden:
|
Fuer automatisierte CLI-Laeufe kann das Encoding direkt gestartet werden:
|
||||||
|
|
||||||
|
|||||||
+9
-13
@@ -726,28 +726,24 @@ def run_no_tk_fallback() -> int:
|
|||||||
print("Tkinter ist nicht verfuegbar. Starte Drag-and-Drop-Datei direkt im CLI-Modus.")
|
print("Tkinter ist nicht verfuegbar. Starte Drag-and-Drop-Datei direkt im CLI-Modus.")
|
||||||
return run_cli(sys.argv[1], OUTPUT_BASE_DIR)
|
return run_cli(sys.argv[1], OUTPUT_BASE_DIR)
|
||||||
|
|
||||||
print("Tkinter ist nicht verfuegbar. Oeffne Windows-Dateidialoge als Fallback.")
|
print("Tkinter ist nicht verfuegbar. Oeffne Windows-Dateidialog als Fallback.")
|
||||||
selected = choose_paths_with_powershell()
|
input_file = choose_input_with_powershell()
|
||||||
if selected is None:
|
if input_file is None:
|
||||||
print("Keine Quelle ausgewaehlt.")
|
print("Keine Quelle ausgewaehlt.")
|
||||||
return 1
|
return 1
|
||||||
input_file, output_dir = selected
|
print(f"Quelle: {input_file}")
|
||||||
return run_cli(input_file, output_dir)
|
print(f"Ausgabe: {OUTPUT_BASE_DIR}")
|
||||||
|
return run_cli(input_file, OUTPUT_BASE_DIR)
|
||||||
|
|
||||||
|
|
||||||
def choose_paths_with_powershell() -> tuple[str, str] | None:
|
def choose_input_with_powershell() -> str | None:
|
||||||
script = r"""
|
script = r"""
|
||||||
Add-Type -AssemblyName System.Windows.Forms
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
$open = New-Object System.Windows.Forms.OpenFileDialog
|
$open = New-Object System.Windows.Forms.OpenFileDialog
|
||||||
$open.Title = 'Basis-Video auswaehlen'
|
$open.Title = 'Basis-Video auswaehlen'
|
||||||
$open.Filter = 'Video-Dateien (*.mov;*.mxf;*.mp4;*.mkv;*.ts;*.m2ts;*.vob)|*.mov;*.mxf;*.mp4;*.mkv;*.ts;*.m2ts;*.vob|Alle Dateien (*.*)|*.*'
|
$open.Filter = 'Video-Dateien (*.mov;*.mxf;*.mp4;*.mkv;*.ts;*.m2ts;*.vob)|*.mov;*.mxf;*.mp4;*.mkv;*.ts;*.m2ts;*.vob|Alle Dateien (*.*)|*.*'
|
||||||
if ($open.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) { exit 2 }
|
if ($open.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) { exit 2 }
|
||||||
$folder = New-Object System.Windows.Forms.FolderBrowserDialog
|
|
||||||
$folder.Description = 'Ausgabeordner auswaehlen'
|
|
||||||
$folder.SelectedPath = 'H:\VOD'
|
|
||||||
if ($folder.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) { exit 2 }
|
|
||||||
Write-Output $open.FileName
|
Write-Output $open.FileName
|
||||||
Write-Output $folder.SelectedPath
|
|
||||||
"""
|
"""
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["powershell", "-NoProfile", "-STA", "-Command", script],
|
["powershell", "-NoProfile", "-STA", "-Command", script],
|
||||||
@@ -758,9 +754,9 @@ Write-Output $folder.SelectedPath
|
|||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
return None
|
return None
|
||||||
lines = [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
lines = [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
||||||
if len(lines) < 2:
|
if not lines:
|
||||||
return None
|
return None
|
||||||
return lines[0], lines[1]
|
return lines[0]
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
|
|||||||
Reference in New Issue
Block a user