JUNGU commited on
Commit
22a2604
β€’
1 Parent(s): 1a84c5a

Update youtube_worksheet.py

Browse files
Files changed (1) hide show
  1. youtube_worksheet.py +7 -2
youtube_worksheet.py CHANGED
@@ -19,10 +19,15 @@ class YouTubeWorksheet:
19
  if not video_id:
20
  return None
21
  try:
22
- transcript = YouTubeTranscriptApi.get_transcript(video_id)
23
- return ' '.join([entry['text'] for entry in transcript])
 
 
 
 
24
  except Exception as e:
25
  print(f"μžλ§‰ μΆ”μΆœ 였λ₯˜: {e}")
 
26
  return None
27
 
28
  def create_worksheet(self, transcript):
 
19
  if not video_id:
20
  return None
21
  try:
22
+ # μ‚¬μš© κ°€λŠ₯ν•œ λͺ¨λ“  μžλ§‰ λͺ©λ‘μ„ λ¨Όμ € 확인
23
+ transcript_list = YouTubeTranscriptApi.list_transcripts(video_id)
24
+
25
+ # μžλ™ μƒμ„±λœ μžλ§‰ ν¬ν•¨ν•˜μ—¬ μ‹œλ„
26
+ transcript = transcript_list.find_transcript(['en', 'ko'])
27
+ return ' '.join([entry['text'] for entry in transcript.fetch()])
28
  except Exception as e:
29
  print(f"μžλ§‰ μΆ”μΆœ 였λ₯˜: {e}")
30
+ print(f"λΉ„λ””μ˜€ ID: {video_id}")
31
  return None
32
 
33
  def create_worksheet(self, transcript):