Spaces:
Runtime error
Runtime error
Next
commited on
Commit
β’
6c6fcb3
1
Parent(s):
1b0583a
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,39 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
-
def download_url(url, name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
opts = {
|
6 |
-
"mp3": '-f "ba" -x --audio-format mp3',
|
7 |
"mp4": '-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"',
|
8 |
-
}[
|
9 |
-
filename = f"{name}.
|
10 |
os.system(f"yt-dlp {opts} {url} -o {filename}")
|
11 |
return filename
|
12 |
|
13 |
with gr.Blocks(theme="Nex432/green") as demo:
|
14 |
-
|
|
|
15 |
url = gr.Textbox(label="Media URL")
|
16 |
name_file = gr.Textbox(label="Media Name")
|
17 |
-
format = gr.Dropdown(label="Format File", choices=["mp3", "mp4"])
|
18 |
download = gr.Button("Download")
|
19 |
-
audio_output = gr.Audio(
|
20 |
-
|
21 |
-
|
22 |
-
def download_media(url, name_file, format):
|
23 |
-
filename = download_url(url, name_file, format)
|
24 |
-
if format == "mp3":
|
25 |
-
return filename, None # Return filename for audio, None for video
|
26 |
-
else:
|
27 |
-
return None, filename # Return None for audio, filename for video
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
with gr.Tab("credits"):
|
32 |
gr.Markdown(
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
+
def download_url(url, name):
|
5 |
+
opts = {
|
6 |
+
"mp3": "-f \"ba\" -x --audio-format mp3",
|
7 |
+
}
|
8 |
+
filename = f"{name}.mp3"
|
9 |
+
os.system(f"yt-dlp {opts} {url} -o {filename}")
|
10 |
+
return filename
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
def download_url_vid(url, name):
|
15 |
opts = {
|
|
|
16 |
"mp4": '-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"',
|
17 |
+
}[
|
18 |
+
filename = f"{name}.mp4"
|
19 |
os.system(f"yt-dlp {opts} {url} -o {filename}")
|
20 |
return filename
|
21 |
|
22 |
with gr.Blocks(theme="Nex432/green") as demo:
|
23 |
+
gr.Markdown(f"# MEDIA downloader | Easy `DOWNLOAD media LINK` YT, IG ETC")
|
24 |
+
with gr.Tab("audio downloader"):
|
25 |
url = gr.Textbox(label="Media URL")
|
26 |
name_file = gr.Textbox(label="Media Name")
|
|
|
27 |
download = gr.Button("Download")
|
28 |
+
audio_output = gr.Audio(label="Audo Output")
|
29 |
+
download.click(download_media, inputs=[url, name_file], outputs=[audio_output])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
with gr.Tab("video downloader"):
|
32 |
+
url = gr.Textbox(label="Media URL")
|
33 |
+
name_file = gr.Textbox(label="Media Name")
|
34 |
+
download = gr.Button("Download")
|
35 |
+
video_output = gr.Video(label="Video Output")
|
36 |
+
download.click(download_url_vid, inputs=[url, name_file,], outputs=[video_output])
|
37 |
|
38 |
with gr.Tab("credits"):
|
39 |
gr.Markdown(
|