-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexe_launcher.py
More file actions
103 lines (87 loc) · 3.17 KB
/
exe_launcher.py
File metadata and controls
103 lines (87 loc) · 3.17 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
#!/usr/bin/env python3
"""
Video Transcriber EXE Launcher
This script is used to create a standalone executable for the Video Transcriber application.
"""
import sys
import os
import subprocess
import tempfile
import webbrowser
import time
def check_dependencies():
"""Check if required dependencies are available"""
try:
import flask
import moviepy
import openai
import requests
print("✓ All Python dependencies are available")
return True
except ImportError as e:
print(f"✗ Missing dependency: {e}")
return False
def install_dependencies():
"""Install required dependencies"""
print("Installing dependencies...")
try:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
print("✓ Dependencies installed successfully")
return True
except subprocess.CalledProcessError:
print("✗ Failed to install dependencies")
return False
def create_shortcut():
"""Create a desktop shortcut for Windows"""
if os.name == 'nt': # Windows
try:
import winshell
from win32com.client import Dispatch
desktop = winshell.desktop()
path = os.path.join(desktop, "Video Transcriber.lnk")
target = os.path.abspath(__file__)
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortcut(path)
shortcut.Targetpath = sys.executable
shortcut.Arguments = f'"{__file__}"'
shortcut.WorkingDirectory = os.path.dirname(os.path.abspath(__file__))
shortcut.IconLocation = sys.executable
shortcut.save()
print("✓ Desktop shortcut created")
except ImportError:
print("Note: winshell not available, skipping shortcut creation")
def main():
"""Main entry point"""
print("Video Transcriber EXE Launcher")
print("=" * 40)
# Change to script directory
script_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(script_dir)
# Check if requirements.txt exists
if os.path.exists('requirements.txt'):
# Check and install dependencies if needed
if not check_dependencies():
if not install_dependencies():
print("Failed to install dependencies. Please install manually:")
print("pip install -r requirements.txt")
return
# Import and run the main application
try:
print("Starting Video Transcriber...")
print("Web interface will be available at: http://localhost:5000")
# Auto-open browser after a short delay
def open_browser():
time.sleep(2)
webbrowser.open('http://localhost:5000')
browser_thread = threading.Thread(target=open_browser)
browser_thread.daemon = True
browser_thread.start()
# Import and run the main app
from app import main as app_main
app_main()
except Exception as e:
print(f"Error starting application: {e}")
print("Make sure all dependencies are installed and try again.")
if __name__ == '__main__':
import threading
main()