JUNGU commited on
Commit
2815236
·
verified ·
1 Parent(s): cf0c38d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -24,16 +24,15 @@ def extract_info(youtube_url):
24
 
25
  formats = info.get('formats', [])
26
 
27
- best_video_only = max((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') == 'none'),
28
- key=lambda x: x.get('height', 0), default=None)
29
 
30
- best_combined = max((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') != 'none'),
31
- key=lambda x: x.get('height', 0), default=None)
32
 
33
  metadata_str = "\n".join([f"{k}: {v}" for k, v in metadata.items()])
34
 
35
  video_only_link = f'<a href="{best_video_only["url"]}" target="_blank">비디오만 다운로드</a>' if best_video_only else ""
36
- combined_link = f'<a href="{best_combined["url"]}" target="_blank">비디오+오디오 다운로드</a>' if best_combined else ""
37
 
38
  download_links = f"{video_only_link}<br>{combined_link}" if video_only_link or combined_link else "다운로드 링크를 찾을 수 없습니다."
39
 
 
24
 
25
  formats = info.get('formats', [])
26
 
27
+ best_video_only = next((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') == 'none'), None)
 
28
 
29
+ # 간단히 비디오와 오디오가 모두 있는 번째 mp4 포맷을 선택
30
+ combined = next((f for f in formats if f['ext'] == 'mp4' and f.get('vcodec') != 'none' and f.get('acodec') != 'none'), None)
31
 
32
  metadata_str = "\n".join([f"{k}: {v}" for k, v in metadata.items()])
33
 
34
  video_only_link = f'<a href="{best_video_only["url"]}" target="_blank">비디오만 다운로드</a>' if best_video_only else ""
35
+ combined_link = f'<a href="{combined["url"]}" target="_blank">비디오+오디오 다운로드</a>' if combined else ""
36
 
37
  download_links = f"{video_only_link}<br>{combined_link}" if video_only_link or combined_link else "다운로드 링크를 찾을 수 없습니다."
38