divython commited on
Commit
86d9868
·
verified ·
1 Parent(s): 5b69f95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -4,7 +4,7 @@ import whisper
4
  import tempfile
5
 
6
  import os
7
- import yt_dlp
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
- with yt_dlp.YoutubeDL(ydl_opts) as ydl:
21
- ydl.download([url])
 
 
 
 
 
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