Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,16 +16,16 @@ def get_subtitle(url, lang='en'):
|
|
16 |
'subtitleslangs': [lang],
|
17 |
'skip_download': True,
|
18 |
}
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
return
|
29 |
|
30 |
def download_audio(video_url, quality: str = '128', speed: float = None):
|
31 |
ydl_opts = {
|
|
|
16 |
'subtitleslangs': [lang],
|
17 |
'skip_download': True,
|
18 |
}
|
19 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
20 |
+
info_dict = ydl.extract_info(url, download=True)
|
21 |
+
video_id = info_dict.get("id", None)
|
22 |
+
if video_id is None:
|
23 |
+
return None
|
24 |
+
subtitle_file = f"{video_id}.{lang}.vtt"
|
25 |
+
if os.path.exists(subtitle_file):
|
26 |
+
subtitle_text = subprocess.check_output(['webvtt-to-text', subtitle_file]).decode('utf-8')
|
27 |
+
return subtitle_text
|
28 |
+
return None
|
29 |
|
30 |
def download_audio(video_url, quality: str = '128', speed: float = None):
|
31 |
ydl_opts = {
|