Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import whisper
|
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
import os
|
| 7 |
-
|
| 8 |
|
| 9 |
def download_audio(url, cookies_path=None):
|
| 10 |
ydl_opts = {
|
|
@@ -14,11 +14,15 @@ def download_audio(url, cookies_path=None):
|
|
| 14 |
'key': 'FFmpegExtractAudio',
|
| 15 |
'preferredcodec': 'wav',
|
| 16 |
'preferredquality': '192',
|
| 17 |
-
}]
|
| 18 |
-
'cookiefile': cookies_path if cookies_path else 'cookies.txt'
|
| 19 |
}
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
|
|
|
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
import os
|
| 7 |
+
|
| 8 |
|
| 9 |
def download_audio(url, cookies_path=None):
|
| 10 |
ydl_opts = {
|
|
|
|
| 14 |
'key': 'FFmpegExtractAudio',
|
| 15 |
'preferredcodec': 'wav',
|
| 16 |
'preferredquality': '192',
|
| 17 |
+
}]
|
|
|
|
| 18 |
}
|
| 19 |
+
if cookies_path:
|
| 20 |
+
ydl_opts['cookiefile'] = cookies_path
|
| 21 |
+
try:
|
| 22 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 23 |
+
ydl.download([url])
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print("Error downloading:", e)
|
| 26 |
|
| 27 |
|
| 28 |
|