File size: 3,924 Bytes
e6c3477
 
 
 
 
 
 
 
223dc78
e6c3477
 
223dc78
 
e6c3477
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c70811d
e6c3477
 
 
223dc78
e6c3477
 
 
c70811d
e6c3477
 
 
 
 
 
 
 
 
 
 
 
 
 
c70811d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6c3477
c70811d
e6c3477
c70811d
e6c3477
 
 
 
 
223dc78
e6c3477
 
 
 
 
 
 
 
c70811d
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
import gradio as gr
import requests
import os
from pytrends.request import TrendReq

YT_API_KEY = os.getenv("YT_API_KEY", "AIzaSyCy8ROvJzi5DrBV-7PbwWq7QQ4w0e_F8rU")

def get_video_id(url):
    """यह फंक्शन अब दोनों तरह के लिंक को सपोर्ट करेगा"""
    if "v=" in url:
        return url.split("v=")[1].split("&")[0]
    elif "youtu.be/" in url:
        return url.split("youtu.be/")[1].split("?")[0]
    return None

def get_video_stats(video_id):
    url = f"https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&id={video_id}&key={YT_API_KEY}"
    response = requests.get(url)
    data = response.json()
    if "items" in data and data["items"]:
        return data["items"][0]
    return None

def get_trending_trends(niche):
    try:
        pytrends = TrendReq(hl='en-US', tz=360)
        pytrends.build_payload(kw_list=[niche], timeframe='now 7-d')
        trends = pytrends.interest_over_time()
        top_keywords = trends.sort_values(by=niche, ascending=False).head(3).index.tolist()
        return top_keywords
    except:
        return ["AI Trends 2026", "Tech", "Gadgets"]

def boost_video(video_url):
    if not video_url:
        return "❌ कृपया वैलिड YouTube लिंक डालें!"
    
    video_id = get_video_id(video_url)
    if not video_id:
        return "❌ अमान्य YouTube लिंक! (कृपया सही लिंक डालें)"
    
    data = get_video_stats(video_id)
    if not data:
        return "❌ वीडियो नहीं मिला! वीडियो पब्लिक है और API Key सही है चेक करें।"
    
    snippet = data["snippet"]
    stats = data["statistics"]
    title = snippet["title"]
    channel = snippet["channelTitle"]
    views = int(stats.get("viewCount", 0))
    likes = int(stats.get("likeCount", 0))
    comments = int(stats.get("commentCount", 0))
    
    niche = title.split()[0] if title else "General"
    trends = get_trending_trends(niche)
    ctr_pred = round(len(title) * 0.5 + 5, 1)
    
    report = f"""
🚀 **यूट्यूब बूस्ट रिपोर्ट**

📺 **टाइटल:** {title}  
🎥 **चैनल:** {channel}  
👁️ **व्यूज़:** {views:,}  
👍 **लाइक्स:** {likes:,}  
💬 **कमेंट्स:** {comments:,}  
📈 **CTR प्रेडिक्शन:** {ctr_pred}%  
🔥 **ट्रेंडिंग टॉपिक्स:** {", ".join(trends)}  

🛠️ **बूस्ट प्लान:**  
1. टाइटल में "{trends[0] if trends else 'Trending'}" जोड़ें  
2. थंबनेल को लाल/हाइ-कंट्रास्ट बनाएँ  
3. रिटेंशन बढ़ाने के लिए बीच में प्रश्न डालें  
4. रात 8:30–10:00 PM (IST) पर अपलोड करें  
5. पहले 2 घंटे में 5-6 रियल कमेंट करें  
"""
    
    return report

with gr.Blocks() as demo:
    gr.Markdown("## 🚀 YouTube वीडियो बूस्ट टूल (Gradio)")
    gr.Markdown("नीचे अपना YouTube लिंक डालें और 'बूस्ट करें' पर क्लिक करें।")
    
    with gr.Row():
        with gr.Column(scale=3):
            video_url = gr.Textbox(label="YouTube लिंक", placeholder="https://www.youtube.com/watch?v=... या https://youtu.be/...")
        with gr.Column(scale=1):
            btn = gr.Button("🚀 बूस्ट करें", variant="primary")
    
    output = gr.Markdown(label="बूस्ट रिपोर्ट")
    
    btn.click(fn=boost_video, inputs=video_url, outputs=output)

if __name__ == "__main__":
    demo.launch(theme=gr.themes.Soft())