mdnestor's picture
Create new file
cfb3ce0
import gradio as gr
import os
def fetch(url, name, ext):
opts = {
"mp3": "-f \"ba\" -x --audio-format mp3",
"mp4": "-f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"",
}[ext]
filename = f"{name}.{ext}"
os.system(f"yt-dlp {opts} {url} -o {filename}")
return filename
gr.Interface(
fetch,
[gr.Textbox(label="Media link", placeholder="URL goes here..."),
gr.Textbox(label="File name", placeholder="best-vid"),
gr.Dropdown(["mp3", "mp4"], value="mp4", label="File type")],
gr.outputs.File(label="Download!"),
description="Download web media! Works on most sites like YouTube, Reddit, Twitter, Instagram, etc.",
enable_queue=True
).launch()