Update app.py
Browse files
app.py
CHANGED
|
@@ -52,10 +52,10 @@ def read_image(file_path):
|
|
| 52 |
def youtube_captions(self, url):
|
| 53 |
try:
|
| 54 |
ydl_opts = {"skip_download": True, "writesubtitles": True, "writeautomaticsub": True}
|
| 55 |
-
|
| 56 |
-
|
| 57 |
# Return first available captions
|
| 58 |
-
|
| 59 |
except Exception as e:
|
| 60 |
return f"YouTube error: {e}"
|
| 61 |
|
|
|
|
| 52 |
def youtube_captions(self, url):
|
| 53 |
try:
|
| 54 |
ydl_opts = {"skip_download": True, "writesubtitles": True, "writeautomaticsub": True}
|
| 55 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 56 |
+
info = ydl.extract_info(url, download=False)
|
| 57 |
# Return first available captions
|
| 58 |
+
return str(info.get("subtitles") or info.get("automatic_captions"))[:5000]
|
| 59 |
except Exception as e:
|
| 60 |
return f"YouTube error: {e}"
|
| 61 |
|