youngtsai commited on
Commit
ae88c8d
1 Parent(s): 5408edf

screenshot_path = f"https://drive.google.com/thumbnail?id={img_file_id}&sz=s4000"

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -241,16 +241,12 @@ def process_transcript_and_screenshots(video_id):
241
 
242
  # 处理逐字稿中的每个条目,检查并上传截图
243
  for entry in transcript:
244
- if 'img_src' not in entry:
245
  screenshot_path = screenshot_youtube_video(video_id, entry['start'])
246
  img_file_id = upload_img_directly(service, f"{video_id}_{entry['start']}.jpg", folder_id, screenshot_path)
247
  set_public_permission(service, img_file_id)
248
- # 2024/1/2 失效中
249
- # img_src = f"https://drive.google.com/uc?export=view&id={img_file_id}"
250
- # 替代方案
251
- img_src = f"https://drive.google.com/thumbnail?id={img_file_id}&sz=s4000"
252
- entry['img_src'] = img_src
253
- print(f"截图已上传到Google Drive: {img_src}")
254
 
255
  # 更新逐字稿文件
256
  updated_transcript_text = json.dumps(transcript, ensure_ascii=False, indent=2)
@@ -272,7 +268,8 @@ def process_youtube_link(link):
272
  start_time = format_seconds_to_time(entry['start'])
273
  end_time = format_seconds_to_time(entry['start'] + entry['duration'])
274
  embed_url = get_embedded_youtube_link(video_id, entry['start'])
275
- screenshot_path = entry['img_src']
 
276
  line = {
277
  "start_time": start_time,
278
  "end_time": end_time,
 
241
 
242
  # 处理逐字稿中的每个条目,检查并上传截图
243
  for entry in transcript:
244
+ if 'img_file_id' not in entry:
245
  screenshot_path = screenshot_youtube_video(video_id, entry['start'])
246
  img_file_id = upload_img_directly(service, f"{video_id}_{entry['start']}.jpg", folder_id, screenshot_path)
247
  set_public_permission(service, img_file_id)
248
+ entry['img_file_id'] = img_file_id
249
+ print(f"截图已上传到Google Drive: {img_file_id}")
 
 
 
 
250
 
251
  # 更新逐字稿文件
252
  updated_transcript_text = json.dumps(transcript, ensure_ascii=False, indent=2)
 
268
  start_time = format_seconds_to_time(entry['start'])
269
  end_time = format_seconds_to_time(entry['start'] + entry['duration'])
270
  embed_url = get_embedded_youtube_link(video_id, entry['start'])
271
+ img_file_id = entry['img_file_id']
272
+ screenshot_path = f"https://drive.google.com/thumbnail?id={img_file_id}&sz=s4000"
273
  line = {
274
  "start_time": start_time,
275
  "end_time": end_time,