| | 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(""" |
| | <div style='text-align:center; padding:30px; background:linear-gradient(45deg,#ff6b6b,#feca57,#48cae4); border-radius:20px; margin-bottom:30px;'> |
| | <h1 style='color:white; font-size:3em; margin:0; text-shadow:3px 3px 6px rgba(0,0,0,0.4); font-weight:800;'> |
| | π YouTube Analyzer Pro |
| | </h1> |
| | <p style='color:white; font-size:1.4em; margin:15px 0 0 0; text-shadow:2px 2px 4px rgba(0,0,0,0.3); font-weight:500;'> |
| | AI-Powered Specialized Content Analysis |
| | </p> |
| | <p style='color:rgba(255,255,255,0.9); font-size:1.1em; margin:10px 0 0 0; text-shadow:1px 1px 2px rgba(0,0,0,0.3);'> |
| | πΉ Deep Video Analysis β’ π¬ Shorts Intelligence β’ π¬ Comment Insights |
| | </p> |
| | </div> |
| | """) |
| | |
| | with gr.Tabs(): |
| | |
| | with gr.Tab("π Youtube Channel Specialized Analysis"): |
| | gr.HTML("<h2 style='text-align:center; color:#2C3E50; margin:20px 0;'>π Choose Your Analysis Type ~60s</h2>") |
| | |
| | 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" |
| | ) |
| | |
| | |
| | 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("<h3 style='text-align:center; margin:10px;'>π Analytics Dashboard</h3>") |
| | |
| | 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(""" |
| | <div style='text-align:center; margin-top:40px; padding:20px; background:rgba(0,0,0,0.05); border-radius:15px;'> |
| | <p style='color:#7F8C8D; font-size:0.9em; margin:0;'> |
| | π― Specialized Analysis β’ π¬ Real Comment Insights β’ π Trend Reasoning |
| | </p> |
| | </div> |
| | """) |
| |
|
| | if __name__ == "__main__": |
| | demo.launch(mcp_server=True) |