Neil-YL commited on
Commit
7b3704e
·
verified ·
1 Parent(s): 6dcf96c

update refresh button

Browse files
Files changed (1) hide show
  1. app.py +41 -15
app.py CHANGED
@@ -42,6 +42,25 @@ playlist_id = "PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD"
42
  video_id = get_latest_video_id(channel_id, playlist_id = "PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD")
43
  print(f"[DEBUG]video id: {video_id}")
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  start_prefect_worker()
46
  print("[TEST]Prefect worker initialized")
47
 
@@ -444,22 +463,29 @@ with gr.Blocks(title="OT-2 Liquid Color Matching Experiment Queue") as demo:
444
  gr.Markdown("### Queue Status")
445
  queue_status = gr.Markdown("Loading queue status...")
446
  update_status_btn = gr.Button("Refresh Queue Status")
 
447
  gr.Markdown("### YouTube Livestream")
448
- #src="https://www.youtube.com/embed/live_stream?channel=UCHBzCfYpGwoqygH9YNh9A6g"
449
- iframe_html = f'''
450
- <div style="position: relative; width: 100%; padding-top: 56.25%;">
451
- <iframe
452
- style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
453
- src="https://www.youtube.com/embed/{video_id}"
454
- title="OT-2 Livestream"
455
- frameborder="0"
456
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
457
- referrerpolicy="strict-origin-when-cross-origin"
458
- allowfullscreen>
459
- </iframe>
460
- </div>
461
- '''
462
- gr.HTML(iframe_html)
 
 
 
 
 
 
463
 
464
  verify_id_btn.click(
465
  verify_student_id,
 
42
  video_id = get_latest_video_id(channel_id, playlist_id = "PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD")
43
  print(f"[DEBUG]video id: {video_id}")
44
 
45
+ def refresh_video():
46
+ video_id = get_latest_video_id(channel_id, playlist_id = "PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD")
47
+ print(f"[DEBUG]video id: {video_id}")
48
+ iframe_html = f'''
49
+ <div style="position: relative; width: 100%; padding-top: 56.25%;">
50
+ <iframe
51
+ style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
52
+ src="https://www.youtube.com/embed/{video_id}"
53
+ title="OT-2 Livestream"
54
+ frameborder="0"
55
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
56
+ referrerpolicy="strict-origin-when-cross-origin"
57
+ allowfullscreen>
58
+ </iframe>
59
+ </div>
60
+ '''
61
+ return iframe_html
62
+
63
+
64
  start_prefect_worker()
65
  print("[TEST]Prefect worker initialized")
66
 
 
463
  gr.Markdown("### Queue Status")
464
  queue_status = gr.Markdown("Loading queue status...")
465
  update_status_btn = gr.Button("Refresh Queue Status")
466
+
467
  gr.Markdown("### YouTube Livestream")
468
+
469
+ def refresh_iframe():
470
+ video_id = get_latest_video_id(channel_id, playlist_id="PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD")
471
+ print(f"[DEBUG]video id: {video_id}")
472
+ return f'''
473
+ <div style="position: relative; width: 100%; padding-top: 56.25%;">
474
+ <iframe
475
+ style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
476
+ src="https://www.youtube.com/embed/{video_id}"
477
+ title="OT-2 Livestream"
478
+ frameborder="0"
479
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
480
+ referrerpolicy="strict-origin-when-cross-origin"
481
+ allowfullscreen>
482
+ </iframe>
483
+ </div>
484
+ '''
485
+
486
+ iframe_component = gr.HTML(refresh_iframe())
487
+ refresh_video_btn = gr.Button("Refresh Livestream")
488
+ refresh_video_btn.click(fn=refresh_iframe, outputs=iframe_component)
489
 
490
  verify_id_btn.click(
491
  verify_student_id,