Spaces:
Running
Running
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
def fetch(url, name, ext):
|
5 |
+
opts = {
|
6 |
+
"mp3": "-f \"ba\" -x --audio-format mp3",
|
7 |
+
"mp4": "-f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"",
|
8 |
+
}[ext]
|
9 |
+
filename = f"{name}.{ext}"
|
10 |
+
os.system(f"yt-dlp {opts} {url} -o {filename}")
|
11 |
+
return filename
|
12 |
+
|
13 |
+
gr.Interface(
|
14 |
+
fetch,
|
15 |
+
[gr.Textbox(label="Media link", placeholder="URL goes here..."),
|
16 |
+
gr.Textbox(label="File name", placeholder="best-vid"),
|
17 |
+
gr.Dropdown(["mp3", "mp4"], value="mp4", label="File type")],
|
18 |
+
gr.outputs.File(label="Download!"),
|
19 |
+
description="Download web media! Works on most sites like YouTube, Reddit, Twitter, Instagram, etc.",
|
20 |
+
enable_queue=True
|
21 |
+
).launch()
|