File size: 1,472 Bytes
bc39353 99baa8d bc39353 99baa8d 20a7e87 99baa8d 20a7e87 99baa8d 20a7e87 99baa8d 20a7e87 99baa8d bc39353 2e18f1a 99baa8d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
from yt_dlp import YoutubeDL
def extract_metadata(youtube_url):
ydl_opts = {'quiet': True}
try:
with YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(youtube_url, download=False)
metadata = {
"제목": info.get('title', 'N/A'),
"채널": info.get('channel', 'N/A'),
"업로드 날짜": info.get('upload_date', 'N/A'),
"조회수": info.get('view_count', 'N/A'),
"좋아요 수": info.get('like_count', 'N/A'),
"길이 (초)": info.get('duration', 'N/A'),
"설명": info.get('description', 'N/A')[:500] + '...' # 설명 일부만 표시
}
return "\n".join([f"{k}: {v}" for k, v in metadata.items()])
except Exception as e:
return f"오류 발생: {str(e)}"
def check_yt_dlp_version():
return f"yt-dlp 버전: {YoutubeDL.version.__version__}"
with gr.Blocks() as demo:
gr.Markdown("## YouTube 메타데이터 추출기")
gr.Markdown(check_yt_dlp_version())
with gr.Row():
youtube_url_input = gr.Textbox(label="YouTube URL 입력")
extract_button = gr.Button("메타데이터 추출")
output = gr.Textbox(label="추출된 메타데이터", lines=10)
extract_button.click(fn=extract_metadata, inputs=youtube_url_input, outputs=output)
if __name__ == "__main__":
demo.launch() |