Update app.py
Browse files
app.py
CHANGED
@@ -10,19 +10,24 @@ ELEVENLABS_API_KEY = os.environ.get("ELEVENLABS_API_KEY", None)
|
|
10 |
|
11 |
def download_video_from_url(url):
|
12 |
try:
|
|
|
13 |
filename = f"downloaded_video_{uuid.uuid4().hex[:8]}.mp4"
|
14 |
|
|
|
15 |
ydl_opts = {
|
16 |
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4',
|
17 |
'outtmpl': filename,
|
18 |
'quiet': True,
|
19 |
'no_warnings': True,
|
20 |
'ignoreerrors': True,
|
21 |
-
'cookiesfrombrowser': ('chrome',),
|
22 |
'nocheckcertificate': True,
|
23 |
-
'
|
|
|
|
|
|
|
24 |
}
|
25 |
|
|
|
26 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
27 |
ydl.download([url])
|
28 |
|
|
|
10 |
|
11 |
def download_video_from_url(url):
|
12 |
try:
|
13 |
+
# Generate a unique filename
|
14 |
filename = f"downloaded_video_{uuid.uuid4().hex[:8]}.mp4"
|
15 |
|
16 |
+
# Configure yt-dlp options without browser cookies
|
17 |
ydl_opts = {
|
18 |
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4',
|
19 |
'outtmpl': filename,
|
20 |
'quiet': True,
|
21 |
'no_warnings': True,
|
22 |
'ignoreerrors': True,
|
|
|
23 |
'nocheckcertificate': True,
|
24 |
+
'extractor_args': {'youtube': {'skip': ['webpage']}}, # Skip webpage verification
|
25 |
+
'extractor_retries': 3,
|
26 |
+
# Add more formats as fallbacks
|
27 |
+
'merge_output_format': 'mp4',
|
28 |
}
|
29 |
|
30 |
+
# Download the video
|
31 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
32 |
ydl.download([url])
|
33 |
|