Yt-down / app.py
JUNGU's picture
Update app.py
0c15909
raw
history blame contribute delete
978 Bytes
import gradio as gr
from yt_dlp import YoutubeDL
# yt-dlp의 μ˜΅μ…˜ μ„€μ •
ydl_opts = {
'format': 'bestvideo+bestaudio/best',
'outtmpl': '%(id)s.%(ext)s', # λ‹€μš΄λ‘œλ“œλœ 파일의 이름 ν˜•μ‹μ„ μ§€μ •
'postprocessors': [{ # λΉ„λ””μ˜€μ™€ μ˜€λ””μ˜€λ₯Ό ν•©μΉ˜λŠ” μž‘μ—…
'key': 'FFmpegMerger',
'preferredcodec': 'mp4',
}],
'noplaylist': True, # ν”Œλ ˆμ΄λ¦¬μŠ€νŠΈμ˜ 첫 λΉ„λ””μ˜€λ§Œ λ‹€μš΄λ‘œλ“œ
}
def download_video(url):
with YoutubeDL(ydl_opts) as ydl:
info_dict = ydl.extract_info(url, download=False)
ydl.download([url])
filename = ydl.prepare_filename(info_dict)
return filename
# Gradio μΈν„°νŽ˜μ΄μŠ€ μ„€μ •
iface = gr.Interface(
fn=download_video,
inputs=gr.Textbox(placeholder="Enter YouTube URL here..."),
outputs='text',
title="YouTube Video Downloader",
description="Enter a YouTube URL to download it as an MP4 file."
)
if __name__ == "__main__":
iface.launch()