-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
119 lines (102 loc) Β· 3.96 KB
/
main.py
File metadata and controls
119 lines (102 loc) Β· 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python3
"""
UCLV Downloader - Main launcher
Allows choosing between CLI and GUI interfaces
"""
import sys
import argparse
from pathlib import Path
def main():
"""Main launcher that chooses between CLI and GUI"""
# Parse command line arguments
parser = argparse.ArgumentParser(
description="π¬ UCLV Downloader - Descargador de Videos y SubtΓtulos",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Ejemplos:
python main.py # Lanzar GUI por defecto
python main.py --cli # Usar interfaz de lΓnea de comandos
python main.py --gui # Usar interfaz grΓ‘fica (explΓcito)
python main.py --help # Mostrar esta ayuda
"""
)
interface_group = parser.add_mutually_exclusive_group()
interface_group.add_argument(
'--cli',
action='store_true',
help='Usar interfaz de lΓnea de comandos'
)
interface_group.add_argument(
'--gui',
action='store_true',
help='Usar interfaz grΓ‘fica (por defecto)'
)
parser.add_argument(
'--version',
action='version',
version='UCLV Downloader v1.4.0'
)
args = parser.parse_args()
# Determine which interface to use
use_gui = not args.cli # Default to GUI unless CLI is explicitly requested
try:
if use_gui:
print("π Iniciando interfaz grΓ‘fica...")
try:
from gui import GUIInterface
gui = GUIInterface()
gui.run()
except ImportError as e:
print(f"β Error importando GUI: {e}")
print("π Cambiando a interfaz CLI...")
launch_cli()
except Exception as e:
print(f"β Error en GUI: {e}")
print("π Cambiando a interfaz CLI...")
launch_cli()
else:
launch_cli()
except KeyboardInterrupt:
print("\n\nπ Programa terminado por el usuario")
except Exception as e:
print(f"\nβ Error inesperado: {e}")
import traceback
traceback.print_exc()
def launch_cli():
"""Launch CLI interface"""
print("π Iniciando interfaz de lΓnea de comandos...")
try:
from cli import CLIInterface
cli = CLIInterface()
cli.run()
except ImportError as e:
print(f"β Error importando CLI: {e}")
print("π‘ AsegΓΊrate de que todas las dependencias estΓ©n instaladas:")
print(" uv sync")
sys.exit(1)
except Exception as e:
print(f"β Error en CLI: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
def show_banner():
"""Show application banner"""
banner = """
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π¬ UCLV Downloader v1.0 β
β Descargador de Videos y SubtΓtulos β
β β
β Un descargador modular para visuales.ucv.cu β
β β
β π₯οΈ Interfaz grΓ‘fica disponible β
β π» Interfaz de lΓnea de comandos β
β βοΈ ConfiguraciΓ³n flexible β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"""
print(banner)
if __name__ == "__main__":
# Only show banner if no arguments or help is not being shown
if len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] in ['--gui']):
show_banner()
main()