Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import yt_dlp
|
3 |
|
4 |
-
def
|
5 |
ydl_opts = {'quiet': True}
|
6 |
try:
|
7 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
@@ -17,24 +17,26 @@ def extract_metadata(youtube_url):
|
|
17 |
"설명": info.get('description', 'N/A')[:500] + '...' # 설명 일부만 표시
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
return "\n".join([f"{k}: {v}" for k, v in metadata.items()])
|
21 |
except Exception as e:
|
22 |
return f"오류 발생: {str(e)}"
|
23 |
|
24 |
-
def check_yt_dlp_version():
|
25 |
-
return f"yt-dlp 버전: {yt_dlp.version.__version__}"
|
26 |
-
|
27 |
with gr.Blocks() as demo:
|
28 |
-
gr.Markdown("## YouTube 메타데이터 추출기")
|
29 |
-
gr.Markdown(
|
30 |
-
|
31 |
-
with gr.Row():
|
32 |
-
youtube_url_input = gr.Textbox(label="YouTube URL 입력")
|
33 |
-
extract_button = gr.Button("메타데이터 추출")
|
34 |
|
35 |
-
|
|
|
|
|
36 |
|
37 |
-
extract_button.click(fn=
|
38 |
|
39 |
if __name__ == "__main__":
|
40 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import yt_dlp
|
3 |
|
4 |
+
def extract_info(youtube_url):
|
5 |
ydl_opts = {'quiet': True}
|
6 |
try:
|
7 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
|
|
17 |
"설명": info.get('description', 'N/A')[:500] + '...' # 설명 일부만 표시
|
18 |
}
|
19 |
|
20 |
+
# 최고 품질의 mp4 형식 찾기
|
21 |
+
best_mp4 = next((f for f in info['formats'] if f['ext'] == 'mp4' and f.get('quality') == 1), None)
|
22 |
+
if best_mp4:
|
23 |
+
metadata["다운로드 URL"] = best_mp4['url']
|
24 |
+
else:
|
25 |
+
metadata["다운로드 URL"] = "적절한 형식을 찾을 수 없습니다."
|
26 |
+
|
27 |
return "\n".join([f"{k}: {v}" for k, v in metadata.items()])
|
28 |
except Exception as e:
|
29 |
return f"오류 발생: {str(e)}"
|
30 |
|
|
|
|
|
|
|
31 |
with gr.Blocks() as demo:
|
32 |
+
gr.Markdown("## YouTube 메타데이터 및 다운로드 링크 추출기")
|
33 |
+
gr.Markdown("주의: 이 도구를 사용하여 저작권이 있는 콘텐츠를 무단으로 다운로드하는 것은 불법입니다.")
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
youtube_url_input = gr.Textbox(label="YouTube URL 입력")
|
36 |
+
extract_button = gr.Button("정보 추출")
|
37 |
+
output = gr.Textbox(label="추출된 정보", lines=10)
|
38 |
|
39 |
+
extract_button.click(fn=extract_info, inputs=youtube_url_input, outputs=output)
|
40 |
|
41 |
if __name__ == "__main__":
|
42 |
demo.launch()
|