import gradio as gr from utils import * from youtube_api_test import * from prompt import * from final_channal_analyzer import * from final_video_analyzer import * css = """ .gradio-container { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } .main { background: rgba(255, 255, 255, 0.98); border-radius: 25px; margin: 20px; padding: 40px; box-shadow: 0 25px 80px rgba(0,0,0,0.15); backdrop-filter: blur(10px); } .analysis-button { background: linear-gradient(45deg, #4facfe, #00f2fe) !important; border: none !important; color: white !important; font-weight: bold !important; border-radius: 15px !important; padding: 15px 30px !important; margin: 10px !important; transition: all 0.3s ease !important; box-shadow: 0 6px 20px rgba(79, 172, 254, 0.3) !important; } .analysis-button:hover { transform: translateY(-3px) !important; box-shadow: 0 10px 30px rgba(79, 172, 254, 0.4) !important; } .shorts-button { background: linear-gradient(45deg, #ff6b6b, #feca57) !important; box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3) !important; } .shorts-button:hover { box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4) !important; } """ with gr.Blocks(css=css, title="YouTube Analyzer Pro - Specialized Analysis") as demo: gr.HTML("""

šŸ† YouTube Analyzer Pro

AI-Powered Specialized Content Analysis

šŸ“¹ Deep Video Analysis • šŸŽ¬ Shorts Intelligence • šŸ’¬ Comment Insights

""") with gr.Tabs(): with gr.Tab("šŸ“Š Youtube Channel Specialized Analysis"): gr.HTML("

šŸ” Choose Your Analysis Type ~60s

") with gr.Row(): with gr.Column(scale=2): channel_input = gr.Textbox( label="šŸŽÆ YouTube Channel Name", value="MrBeast", placeholder="Enter YouTube channel Name for specialized analysis...", info="šŸ“ Extract channel name from URL - if URL is https://www.youtube.com/@MrBeast, enter 'MrBeast'", lines=1 ) with gr.Column(scale=1): max_videos_slider = gr.Slider( minimum=2, maximum=10, value=5, step=1, label="šŸ“Š Max Videos/Shorts to Analyze", info="šŸŽÆ Select 2-10 content pieces for analysis" ) # Two specialized analysis buttons with gr.Row(): with gr.Column(): videos_btn = gr.Button( "šŸ“¹ Analyze Videos", variant="primary", size="large", elem_classes=["analysis-button"] ) with gr.Column(): shorts_btn = gr.Button( "šŸŽ¬ Analyze Shorts", variant="secondary", size="large", elem_classes=["analysis-button", "shorts-button"] ) with gr.Row(): analysis_result = gr.Markdown( label="šŸŽÆ AI Intelligence Report", elem_classes=["analysis-report"] ) dashboard_plot = gr.Plot( label="šŸ“Š Interactive Analytics Dashboard", elem_classes=["dashboard-plot"] ) videos_btn.click( fn=lambda channel_input, max_videos: analyze_content_batch(channel_input, "videos", max_videos), inputs=[channel_input, max_videos_slider], outputs=[analysis_result, dashboard_plot], show_progress=True ) shorts_btn.click( fn=lambda channel_input, max_videos: analyze_content_batch(channel_input, "shorts", max_videos), inputs=[channel_input, max_videos_slider], outputs=[analysis_result, dashboard_plot], show_progress=True ) with gr.Tab("šŸŽÆ Youtube Single Video Analysis"): with gr.Tabs(): with gr.TabItem("YouTube Channel: Single Video"): with gr.Row(): with gr.Column(scale=2): video_id = gr.Textbox( label="YouTube Video ID", value="hTSaweR8qMI", placeholder="Enter video ID...", info="šŸ’” The video ID is the part after 'v=' in a YouTube URL\nšŸ“ŗ Example: youtube.com/watch?v=dQw4w9WgXcQ → Enter: dQw4w9WgXcQ" ) with gr.Column(scale=1): comment_limit_slider = gr.Slider( minimum=10, maximum=50, value=25, step=5, label="šŸ“Š Major Comments to Analyze", info="šŸŽÆ Select 10-50 comments for analysis" ) video_btn = gr.Button("šŸš€ Analyze Video In Depth :) ~40s", variant="primary") with gr.Row(): with gr.Column(scale=2): video_result = gr.Markdown(label="šŸ“Š Comprehensive Analysis Report") with gr.Column(scale=1): gr.HTML("

šŸ† Analytics Dashboard

") video_info_display = gr.Markdown(label="šŸ“¹ Video Information") sentiment_chart = gr.Image(label="šŸ’¬ Sentiment Analysis Dashboard", type="pil") opinion_chart = gr.Image(label="šŸ‘„ Public Opinion Analysis", type="pil") video_btn.click( fn=lambda video_id, comment_limit: comment_analyzer(video_id, comment_limit), inputs=[video_id, comment_limit_slider], outputs=[video_result, video_info_display, sentiment_chart, opinion_chart], show_progress=True ) gr.HTML("""

šŸŽÆ Specialized Analysis • šŸ’¬ Real Comment Insights • šŸ“ˆ Trend Reasoning

""") if __name__ == "__main__": demo.launch(mcp_server=True)