dynamically grab video id (latest from particular playlist)
Browse filesThe playlist: https://www.youtube.com/playlist?list=PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import json
|
|
| 7 |
import secrets
|
| 8 |
from DB_utls import find_unused_wells, update_used_wells, save_result, get_student_quota, decrement_student_quota
|
| 9 |
import os
|
|
|
|
| 10 |
|
| 11 |
# NOTE: New global dict to store tasks keyed by (student_id, experiment_id)
|
| 12 |
tasks_dict = {}
|
|
@@ -33,6 +34,11 @@ OT2_STATUS_TOPIC = f"status/ot2/{OT2_SERIAL}/complete"
|
|
| 33 |
SENSOR_COMMAND_TOPIC = f"command/picow/{PICO_ID}/as7341/read"
|
| 34 |
SENSOR_DATA_TOPIC = f"color-mixing/picow/{PICO_ID}/as7341"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
def check_student_quota(student_id):
|
| 38 |
"""Check student's remaining experiment quota"""
|
|
@@ -435,11 +441,11 @@ with gr.Blocks(title="OT-2 Liquid Color Matching Experiment Queue") as demo:
|
|
| 435 |
update_status_btn = gr.Button("Refresh Queue Status")
|
| 436 |
gr.Markdown("### YouTube Livestream")
|
| 437 |
#src="https://www.youtube.com/embed/live_stream?channel=UCHBzCfYpGwoqygH9YNh9A6g"
|
| 438 |
-
iframe_html = '''
|
| 439 |
<div style="position: relative; width: 100%; padding-top: 56.25%;">
|
| 440 |
<iframe
|
| 441 |
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
|
| 442 |
-
src="https://www.youtube.com/embed/
|
| 443 |
title="OT-2 Livestream"
|
| 444 |
frameborder="0"
|
| 445 |
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
|
|
|
| 7 |
import secrets
|
| 8 |
from DB_utls import find_unused_wells, update_used_wells, save_result, get_student_quota, decrement_student_quota
|
| 9 |
import os
|
| 10 |
+
from yt_utils import get_latest_video_id
|
| 11 |
|
| 12 |
# NOTE: New global dict to store tasks keyed by (student_id, experiment_id)
|
| 13 |
tasks_dict = {}
|
|
|
|
| 34 |
SENSOR_COMMAND_TOPIC = f"command/picow/{PICO_ID}/as7341/read"
|
| 35 |
SENSOR_DATA_TOPIC = f"color-mixing/picow/{PICO_ID}/as7341"
|
| 36 |
|
| 37 |
+
channel_id = "UCHBzCfYpGwoqygH9YNh9A6g"
|
| 38 |
+
playlist_id = "PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD"
|
| 39 |
+
|
| 40 |
+
video_id = get_latest_video_id(channel_id, playlist_id = "PL8uZlc2CEpenUCAo9PeiOtbU04lFv48yD")
|
| 41 |
+
|
| 42 |
|
| 43 |
def check_student_quota(student_id):
|
| 44 |
"""Check student's remaining experiment quota"""
|
|
|
|
| 441 |
update_status_btn = gr.Button("Refresh Queue Status")
|
| 442 |
gr.Markdown("### YouTube Livestream")
|
| 443 |
#src="https://www.youtube.com/embed/live_stream?channel=UCHBzCfYpGwoqygH9YNh9A6g"
|
| 444 |
+
iframe_html = f'''
|
| 445 |
<div style="position: relative; width: 100%; padding-top: 56.25%;">
|
| 446 |
<iframe
|
| 447 |
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
|
| 448 |
+
src="https://www.youtube.com/embed/{video_id}"
|
| 449 |
title="OT-2 Livestream"
|
| 450 |
frameborder="0"
|
| 451 |
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|