seawolf2357 commited on
Commit
951f374
Β·
verified Β·
1 Parent(s): f2ef6a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -95,17 +95,22 @@ async def get_best_available_transcript(video_id):
95
  YouTube λΉ„λ””μ˜€μ˜ μžλ§‰μ„ κ°€μ Έμ˜΅λ‹ˆλ‹€.
96
  """
97
  try:
98
- # μ˜μ–΄ μžλ§‰ μ‹œλ„
99
- transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['en'])
100
  except Exception as e:
101
- logging.warning(f'Error fetching English transcript: {e}')
102
  try:
103
- # μ˜μ–΄ μžλ§‰μ΄ μ—†μœΌλ©΄ λ‹€λ₯Έ μ–Έμ–΄ μžλ§‰μ„ μ‹œλ„
104
- transcripts = YouTubeTranscriptApi.list_transcripts(video_id)
105
- transcript = transcripts.find_manually_created_transcript(['ko', 'ja', 'zh-Hans', 'zh-Hant']).fetch()
106
  except Exception as e:
107
- logging.error(f'Error fetching alternative transcript: {e}')
108
- return None
 
 
 
 
 
 
109
 
110
  # μžλ§‰ ν¬λ§·νŒ…
111
  formatter = TextFormatter()
 
95
  YouTube λΉ„λ””μ˜€μ˜ μžλ§‰μ„ κ°€μ Έμ˜΅λ‹ˆλ‹€.
96
  """
97
  try:
98
+ # ν•œκ΅­μ–΄ μžλ§‰ μ‹œλ„
99
+ transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['ko'])
100
  except Exception as e:
101
+ logging.warning(f'Error fetching Korean transcript: {e}')
102
  try:
103
+ # ν•œκ΅­μ–΄ μžλ§‰μ΄ μ—†μœΌλ©΄ μ˜μ–΄ μžλ§‰ μ‹œλ„
104
+ transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['en'])
 
105
  except Exception as e:
106
+ logging.warning(f'Error fetching English transcript: {e}')
107
+ try:
108
+ # μ˜μ–΄ μžλ§‰λ„ μ—†μœΌλ©΄ λ‹€λ₯Έ μ–Έμ–΄ μžλ§‰ μ‹œλ„
109
+ transcripts = YouTubeTranscriptApi.list_transcripts(video_id)
110
+ transcript = transcripts.find_manually_created_transcript().fetch()
111
+ except Exception as e:
112
+ logging.error(f'Error fetching alternative transcript: {e}')
113
+ return None
114
 
115
  # μžλ§‰ ν¬λ§·νŒ…
116
  formatter = TextFormatter()