Spaces:
Sleeping
Sleeping
transcript_text = download_blob_to_string(gcs_client, bucket_name, transcript_blob_name)
Browse files
app.py
CHANGED
@@ -438,13 +438,14 @@ def process_transcript_and_screenshots_on_gcs(video_id):
|
|
438 |
if not exists:
|
439 |
# 从YouTube获取逐字稿并上传
|
440 |
transcript = get_transcript(video_id)
|
441 |
-
if transcript:
|
442 |
-
print("成功獲取字幕")
|
443 |
-
else:
|
444 |
-
print("沒有找到字幕")
|
445 |
transcript_text = json.dumps(transcript, ensure_ascii=False, indent=2)
|
446 |
upload_file_to_gcs_with_json_string(gcs_client, bucket_name, transcript_blob_name, transcript_text)
|
447 |
print("逐字稿已上传到GCS")
|
|
|
|
|
|
|
|
|
|
|
448 |
|
449 |
for entry in transcript:
|
450 |
if 'img_file_id' not in entry:
|
|
|
438 |
if not exists:
|
439 |
# 从YouTube获取逐字稿并上传
|
440 |
transcript = get_transcript(video_id)
|
|
|
|
|
|
|
|
|
441 |
transcript_text = json.dumps(transcript, ensure_ascii=False, indent=2)
|
442 |
upload_file_to_gcs_with_json_string(gcs_client, bucket_name, transcript_blob_name, transcript_text)
|
443 |
print("逐字稿已上传到GCS")
|
444 |
+
else:
|
445 |
+
# 逐字稿已存在,下载逐字稿内容
|
446 |
+
print("逐字稿已存在于GCS中")
|
447 |
+
transcript_text = download_blob_to_string(gcs_client, bucket_name, transcript_blob_name)
|
448 |
+
transcript = json.loads(transcript_text)
|
449 |
|
450 |
for entry in transcript:
|
451 |
if 'img_file_id' not in entry:
|