Spaces:
Running
Running
import os | |
import re | |
import subprocess | |
import gradio as gr | |
pattern = r"(?:v=|\/)([0-9A-Za-z_-]{11})" | |
def fetch_video(yt_url): | |
_id = re.search(pattern, yt_url).group(1) | |
path = os.path.join(f"{_id}.mp4") | |
if os.path.exists(path): | |
return path | |
subprocess.run(f'yt-dlp -o {path} "{yt_url}"', shell=True) | |
return path | |
interface = gr.Interface(fetch_video, gr.Text(label="YouTube Video Link"), gr.File(label="Output video"), title="YouTube Video Downloader") | |
interface.launch() |