File size: 688 Bytes
cfb3ce0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()