File size: 7,765 Bytes
e7251ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc08a29
e7251ed
 
 
 
cc08a29
e7251ed
cc08a29
 
e7251ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af6c0c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e7251ed
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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"
                    )
            
            # 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("<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)