Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
-
|
2 |
-
import gradio as gr
|
3 |
import yt_dlp
|
4 |
-
import
|
5 |
-
|
6 |
|
7 |
-
def download_youtube_wav(url, custom_name):
|
8 |
ydl_opts = {
|
9 |
'format': 'bestaudio/best',
|
10 |
'postprocessors': [{
|
@@ -12,20 +9,21 @@ def download_youtube_wav(url, custom_name):
|
|
12 |
'preferredcodec': 'wav',
|
13 |
'preferredquality': '192',
|
14 |
}],
|
15 |
-
'outtmpl': custom_name
|
16 |
}
|
17 |
|
18 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
19 |
ydl.download([url])
|
20 |
-
|
21 |
-
return f'File
|
22 |
|
23 |
iface = gr.Interface(
|
24 |
fn=download_youtube_wav,
|
25 |
-
inputs=['text', 'text'],
|
26 |
-
outputs='
|
27 |
-
title='YouTube
|
28 |
-
description='Enter the YouTube URL and
|
29 |
)
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
1 |
import yt_dlp
|
2 |
+
import gradio as gr
|
|
|
3 |
|
4 |
+
def download_youtube_wav(url, custom_name, custom_directory):
|
5 |
ydl_opts = {
|
6 |
'format': 'bestaudio/best',
|
7 |
'postprocessors': [{
|
|
|
9 |
'preferredcodec': 'wav',
|
10 |
'preferredquality': '192',
|
11 |
}],
|
12 |
+
'outtmpl': f'{custom_directory}/{custom_name}.%(ext)s',
|
13 |
}
|
14 |
|
15 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
16 |
ydl.download([url])
|
17 |
+
|
18 |
+
return f'Download complete! File saved as {custom_name}.wav in {custom_directory}'
|
19 |
|
20 |
iface = gr.Interface(
|
21 |
fn=download_youtube_wav,
|
22 |
+
inputs=['text', 'text', 'text'],
|
23 |
+
outputs='Audio',
|
24 |
+
title='YouTube WAV Downloader',
|
25 |
+
description='Enter the YouTube URL, custom filename, and directory to download the video as a WAV file.'
|
26 |
)
|
27 |
|
28 |
+
if __name__ == "__main__":
|
29 |
+
iface.launch()
|