File size: 1,327 Bytes
24238f5
 
 
 
 
 
 
 
 
 
1a84c5a
24238f5
 
 
 
 
 
1a84c5a
24238f5
 
 
 
 
 
 
 
 
1a84c5a
 
 
 
 
 
 
 
 
 
24238f5
1a84c5a
 
 
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
41
from youtube_worksheet import YouTubeWorksheet
from dotenv import load_dotenv
import gradio as gr
import os

def process_video(url):
    # ν™˜κ²½λ³€μˆ˜μ—μ„œ API ν‚€ κ°€μ Έμ˜€κΈ°
    API_KEY = os.getenv('GEMINI_API_KEY')
    
    if not API_KEY:
        return "ERROR: GEMINI_API_KEYκ°€ μ„€μ •λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. .env νŒŒμΌμ„ ν™•μΈν•΄μ£Όμ„Έμš”."
    
    worksheet = YouTubeWorksheet(API_KEY)
    
    # μžλ§‰ μΆ”μΆœ
    transcript = worksheet.get_transcript(url)
    if not transcript:
        return "μžλ§‰μ„ μΆ”μΆœν•  수 μ—†μŠ΅λ‹ˆλ‹€."
    
    # μ›Œν¬μ‹œνŠΈ 생성
    content = worksheet.create_worksheet(transcript)
    
    # DOCX 파일둜 μ €μž₯
    output_file = worksheet.save_to_docx(content)
    
    return f"μ›Œν¬μ‹œνŠΈκ°€ μƒμ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 파일λͺ…: {output_file}", output_file

def main():
    # Gradio μΈν„°νŽ˜μ΄μŠ€ μ‹€ν–‰
    iface = gr.Interface(
        fn=process_video,
        inputs=[gr.Textbox(label="YouTube URL을 μž…λ ₯ν•˜μ„Έμš”")],
        outputs=[gr.Textbox(label="처리 κ²°κ³Ό"), gr.File(label="μƒμ„±λœ μ›Œν¬μ‹œνŠΈ")],
        title="YouTube ν•™μŠ΅ μ›Œν¬μ‹œνŠΈ 생성기",
        description="YouTube μ˜μƒμ˜ μžλ§‰μ„ μ΄μš©ν•˜μ—¬ ν•™μŠ΅ μ›Œν¬μ‹œνŠΈλ₯Ό μƒμ„±ν•©λ‹ˆλ‹€."
    )
    iface.launch(share=True)

if __name__ == '__main__':
    load_dotenv()
    main()