Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,9 @@ from selenium.common.exceptions import TimeoutException, WebDriverException
|
|
| 11 |
import time
|
| 12 |
import logging
|
| 13 |
import os
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
app = FastAPI()
|
| 16 |
|
|
@@ -161,51 +164,22 @@ async def get_transcript(request: VideoRequest):
|
|
| 161 |
if driver:
|
| 162 |
driver.quit()
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
@app.get("/health")
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
"chromedriver": ["/usr/bin/chromedriver"]
|
| 169 |
-
}
|
| 170 |
-
exists = {
|
| 171 |
-
"chrome": any(os.path.exists(path) for path in paths["chrome"]),
|
| 172 |
-
"chromedriver": any(os.path.exists(path) for path in paths["chromedriver"])
|
| 173 |
-
}
|
| 174 |
-
found_paths = {
|
| 175 |
-
"chrome": [path for path in paths["chrome"] if os.path.exists(path)],
|
| 176 |
-
"chromedriver": [path for path in paths["chromedriver"] if os.path.exists(path)]
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
chrome_version = "Not found"
|
| 180 |
-
chromedriver_version = "Not found"
|
| 181 |
-
|
| 182 |
-
if exists["chrome"]:
|
| 183 |
-
for path in paths["chrome"]:
|
| 184 |
-
try:
|
| 185 |
-
chrome_version = os.popen(f"{path} --version").read().strip()
|
| 186 |
-
if chrome_version:
|
| 187 |
-
break
|
| 188 |
-
except Exception as e:
|
| 189 |
-
logger.error(f"Failed to get Chrome version for {path}: {str(e)}")
|
| 190 |
-
|
| 191 |
-
if exists["chromedriver"]:
|
| 192 |
-
try:
|
| 193 |
-
chromedriver_version = os.popen("/usr/bin/chromedriver --version").read().strip()
|
| 194 |
-
except Exception as e:
|
| 195 |
-
logger.error(f"Failed to get ChromeDriver version: {str(e)}")
|
| 196 |
-
|
| 197 |
-
status = "OK" if all(exists.values()) else "ERROR"
|
| 198 |
-
logger.info(f"Health check: Chrome={chrome_version}, ChromeDriver={chromedriver_version}, Paths={found_paths}, Exists={exists}")
|
| 199 |
-
|
| 200 |
return {
|
| 201 |
-
"
|
| 202 |
-
"
|
| 203 |
-
"
|
| 204 |
-
"
|
| 205 |
-
"chromedriver_version": chromedriver_version,
|
| 206 |
-
"working": all(exists.values())
|
| 207 |
}
|
| 208 |
|
|
|
|
| 209 |
@app.get("/")
|
| 210 |
async def root():
|
| 211 |
return {"message": "Welcome to YouTube Transcript API"}
|
|
|
|
| 11 |
import time
|
| 12 |
import logging
|
| 13 |
import os
|
| 14 |
+
import shutil
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
|
| 17 |
|
| 18 |
app = FastAPI()
|
| 19 |
|
|
|
|
| 164 |
if driver:
|
| 165 |
driver.quit()
|
| 166 |
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
app = FastAPI()
|
| 170 |
+
|
| 171 |
@app.get("/health")
|
| 172 |
+
def health_check():
|
| 173 |
+
chrome_path = shutil.which("google-chrome")
|
| 174 |
+
chromedriver_path = shutil.which("chromedriver")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
return {
|
| 176 |
+
"ChromePath": chrome_path,
|
| 177 |
+
"ChromeDriverPath": chromedriver_path,
|
| 178 |
+
"ChromeExists": Path(chrome_path or "").exists(),
|
| 179 |
+
"ChromeDriverExists": Path(chromedriver_path or "").exists()
|
|
|
|
|
|
|
| 180 |
}
|
| 181 |
|
| 182 |
+
|
| 183 |
@app.get("/")
|
| 184 |
async def root():
|
| 185 |
return {"message": "Welcome to YouTube Transcript API"}
|