Spaces:
Running
Running
File size: 498 Bytes
c17ec65 6c1c7e4 c17ec65 6c1c7e4 1d351ad 6c1c7e4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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() |