import gradio as gr from datetime import datetime import json # Load video links and news data with open('assets/game_video_link.json', 'r') as f: VIDEO_LINKS = json.load(f) with open('assets/news.json', 'r') as f: NEWS_DATA = json.load(f) def create_video_gallery(): """Create a custom HTML/JS component for video gallery""" # Extract video IDs mario_id = VIDEO_LINKS["super_mario"].split("?v=")[1] sokoban_id = VIDEO_LINKS["sokoban"].split("?v=")[1] game_2048_id = VIDEO_LINKS["2048"].split("?v=")[1] candy_id = VIDEO_LINKS["candy"].split("?v=")[1] ace_attorney_id = VIDEO_LINKS["ace_attorney"].split("?v=")[1] # Get the latest video from news data latest_news = NEWS_DATA["news"][0] # First item is the latest latest_video_id = latest_news["video_link"].split("?v=")[1] latest_date = datetime.strptime(latest_news["date"], "%Y-%m-%d") formatted_latest_date = latest_date.strftime("%B %d, %Y") # Generate news HTML news_items = [] for item in NEWS_DATA["news"]: video_id = item["video_link"].split("?v=")[1] date_obj = datetime.strptime(item["date"], "%Y-%m-%d") formatted_date = date_obj.strftime("%B %d, %Y") news_items.append(f'''
''') news_html = '\n'.join(news_items) gallery_html = f''' ''' return gr.HTML(gallery_html) def create_gallery_tab(): """Create and return the gallery tab component""" with gr.Tab("🎥 Gallery") as gallery_tab: video_gallery = create_video_gallery() return gallery_tab