Next
Update app.py
eaef3cc verified
raw
history blame
1.45 kB
import gradio as gr
import os
def download_url(url, name):
opts = {
"mp3": "-f \"ba\" -x --audio-format mp3",
}
filename = f"{name}.mp3"
os.system(f"yt-dlp {opts} {url} -o {filename}")
return filename
def download_url_vid(url, name):
opts = {
"mp4": '-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"',
}
filename = f"{name}.mp4"
os.system(f"yt-dlp {opts} {url} -o {filename}")
return filename
with gr.Blocks(theme="Nex432/green") as demo:
gr.Markdown(f"# MEDIA downloader | Easy `DOWNLOAD media LINK` YT, IG ETC")
with gr.Tab("audio downloader"):
url = gr.Textbox(label="Media URL")
name_file = gr.Textbox(label="Media Name")
download = gr.Button("Download")
audio_output = gr.Audio(label="Audo Output")
download.click(download_url, inputs=[url, name_file], outputs=[audio_output])
with gr.Tab("video downloader"):
url = gr.Textbox(label="Media URL")
name_file = gr.Textbox(label="Media Name")
download = gr.Button("Download")
video_output = gr.Video(label="Video Output")
download.click(download_url_vid, inputs=[url, name_file,], outputs=[video_output])
with gr.Tab("credits"):
gr.Markdown(
"""
Code by [Nex432](https://huggingface.co/Nex432)<br> with [ChatGPT's](https://chatgpt.com) help
"""
)
demo.launch()