youngtsai commited on
Commit
07aa2aa
Β·
1 Parent(s): 9bc27e6

debug process_transcript_and_screenshots_on_gcs

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -372,6 +372,7 @@ def get_transcript_by_yt_api(video_id):
372
 
373
  def generate_transcription_by_gemini(video_id):
374
  """使用 Google Gemini η”Ÿζˆε½±η‰‡ι€ε­—η¨Ώ"""
 
375
  # ζΊ–ε‚™ YouTube 影片 URL
376
  video_url = f"https://www.youtube.com/watch?v={video_id}"
377
 
@@ -566,6 +567,7 @@ def process_transcript_and_screenshots_on_gcs(video_id):
566
  print("====process_transcript_and_screenshots_on_gcs====")
567
  transcript, exists = get_transcript_from_gcs(video_id)
568
  if not exists:
 
569
  try:
570
  transcript = generate_transcription_by_gemini(video_id)
571
  except Exception as e:
@@ -575,14 +577,15 @@ def process_transcript_and_screenshots_on_gcs(video_id):
575
  upload_transcript_to_gcs(video_id, transcript)
576
 
577
  # 處理ζˆͺεœ–
 
578
  is_new_transcript = False
579
  has_tried_download_video = False
580
  for entry in transcript:
581
  if 'img_file_id' not in entry:
582
  # ζͺ’ζŸ₯ OUTPUT_PATH 是否存在 video_id.mp4
583
  video_path = f'{OUTPUT_PATH}/{video_id}.mp4'
584
- # ζ²’ζœ‰ε½±η‰‡ζˆ–ζ˜―ζ²’ζœ‰δΈ‹θΌ‰ιŽ
585
- if not os.path.exists(video_path) or not has_tried_download_video:
586
  try:
587
  download_youtube_video(video_id)
588
  except Exception as e:
 
372
 
373
  def generate_transcription_by_gemini(video_id):
374
  """使用 Google Gemini η”Ÿζˆε½±η‰‡ι€ε­—η¨Ώ"""
375
+ print("====generate_transcription_by_gemini====")
376
  # ζΊ–ε‚™ YouTube 影片 URL
377
  video_url = f"https://www.youtube.com/watch?v={video_id}"
378
 
 
567
  print("====process_transcript_and_screenshots_on_gcs====")
568
  transcript, exists = get_transcript_from_gcs(video_id)
569
  if not exists:
570
+ print("==== video transcript is not exists ====")
571
  try:
572
  transcript = generate_transcription_by_gemini(video_id)
573
  except Exception as e:
 
577
  upload_transcript_to_gcs(video_id, transcript)
578
 
579
  # 處理ζˆͺεœ–
580
+ print("====處理ζˆͺεœ–====")
581
  is_new_transcript = False
582
  has_tried_download_video = False
583
  for entry in transcript:
584
  if 'img_file_id' not in entry:
585
  # ζͺ’ζŸ₯ OUTPUT_PATH 是否存在 video_id.mp4
586
  video_path = f'{OUTPUT_PATH}/{video_id}.mp4'
587
+ # ζ²’ζœ‰ε½±η‰‡δ»₯εŠζ²’ζœ‰δΈ‹θΌ‰ιŽ
588
+ if not os.path.exists(video_path) and not has_tried_download_video:
589
  try:
590
  download_youtube_video(video_id)
591
  except Exception as e: