File size: 8,188 Bytes
37649a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
from fastapi import FastAPI, BackgroundTasks, HTTPException, Form
from fastapi.responses import PlainTextResponse, HTMLResponse
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel
import requests
from requests.exceptions import ProxyError, ConnectTimeout
from faker import Faker
import re
from concurrent.futures import ThreadPoolExecutor
import urllib.parse
import time
import gradio as gr

app = FastAPI()
fake = Faker()

class Proxy(BaseModel):
    ip: str
    port: str

class VisitRequest(BaseModel):
    url: str
    platform: str
    count: int
    delay: int
    parallel_processes: int

app.mount("/static", StaticFiles(directory="static"), name="static")

def get_random_proxy():
    pubproxy_url = "http://pubproxy.com/api/proxy?limit=1"
    response = requests.get(pubproxy_url, verify=False)
    data = response.json()
    if data['data']:
        proxy_data = data['data'][0]
        return f"{proxy_data['ip']}:{proxy_data['port']}"
    return None

@app.get("/get_proxies", response_class=PlainTextResponse)
def get_proxies():
    try:
        proxies = []
        pubproxy_url = "http://pubproxy.com/api/proxy?limit=5"
        response = requests.get(pubproxy_url, verify=False)
        data = response.json()

        for proxy_data in data['data']:
            ip, port = proxy_data['ipPort'].split(":")
            proxy = f"{ip}:{port}"
            proxies.append(proxy)
        
        return "\n".join(proxies)
    except Exception as e:
        return PlainTextResponse(str(e), status_code=500)

@app.get("/rotate_ip", response_class=PlainTextResponse)
def rotate_ip():
    try:
        random_ip = fake.ipv4()

        headers = {
            "X-Forwarded-For": random_ip,
            "Client-IP": random_ip,
            "X-Real-IP": random_ip
        }

        test_url = "http://pubproxy.com/api/proxy?limit=1&type=http&https=true&speed=60"
        response = requests.get(test_url, headers=headers, verify=False)
        data = response.json()

        proxies = []
        for proxy_data in data['data']:
            ip, port = proxy_data['ipPort'].split(":")
            proxy = f"{ip}:{port}"
            proxies.append(proxy)

        return "\n".join(proxies)
    except ProxyError as e:
        return PlainTextResponse(f"ProxyError: {str(e)}", status_code=500)
    except ConnectTimeout as e:
        return PlainTextResponse(f"ConnectTimeoutError: {str(e)}", status_code=500)
    except Exception as e:
        return PlainTextResponse(str(e), status_code=500)

def extract_video_id(url: str, platform: str) -> str:
    url = urllib.parse.unquote(url)  # Decode the URL
    if platform == "instagram":
        match = re.search(r"instagram\.com/reel/([^/?]+)", url)
    elif platform == "tiktok":
        match = re.search(r"tiktok\.com/@[^/]+/video/(\d+)", url)
    elif platform == "youtube":
        match = re.search(r"youtube\.com/watch\?v=([^&]+)", url)
    elif platform == "facebook":
        match = re.search(r"facebook\.com/.*/videos/(\d+)", url)
    elif platform == "twitch":
        match = re.search(r"twitch\.tv/videos/(\d+)", url)
    elif platform == "spotify":
        match = re.search(r"spotify\.com/track/([^/?]+)", url)
    else:
        match = None

    if match:
        return match.group(1)
    else:
        raise ValueError("Invalid URL format")

def simulate_view(video_id: str, platform: str, proxy: str, delay: int):
    proxies = {
        "http": f"http://{proxy}",
        "https": f"http://{proxy}"
    }
    fake_ipv4 = fake.ipv4()
    headers = {
        "User-Agent": fake.user_agent(),
        "X-Forwarded-For": fake_ipv4,
        "Client-IP": fake_ipv4,
        "X-Real-IP": fake_ipv4
    }
    try:
        if platform == "instagram":
            view_url = f"http://www.instagram.com/p/{video_id}?autoplay=true"
        elif platform == "tiktok":
            view_url = f"http://www.tiktok.com/@{video_id}?autoplay=true"
        elif platform == "youtube":
            view_url = f"http://www.youtube.com/watch?v={video_id}&autoplay=1"
        elif platform == "facebook":
            view_url = f"http://www.facebook.com/watch/?v={video_id}&autoplay=1"
        elif platform == "twitch":
            view_url = f"http://www.twitch.tv/videos/{video_id}?autoplay=true"
        elif platform == "spotify":
            view_url = f"http://open.spotify.com/track/{video_id}?autoplay=true"
        else:
            raise ValueError("Invalid platform")

        response = requests.get(view_url, headers=headers, proxies=proxies, timeout=10)
        time.sleep(delay)
    except Exception as e:
        print(f"Error in simulate_view: {e}")

def perform_views(url: str, platform: str, count: int, delay: int, parallel_processes: int):
    video_id = extract_video_id(url, platform)

    def task():
        try:
            proxy_response = requests.get("http://0.0.0.0:8000/rotate_ip")
            if proxy_response.status_code == 200:
                proxy = proxy_response.text.strip()
                if proxy:
                    simulate_view(video_id, platform, proxy, delay)
        except Exception as e:
            print(f"Error in perform_views: {e}")

    with ThreadPoolExecutor(max_workers=parallel_processes) as executor:
        for _ in range(count):
            executor.submit(task)

@app.post("/increase_views", response_class=PlainTextResponse)
def increase_views(
    url: str = Form(...),
    platform: str = Form(...),
    count: int = Form(...),
    delay: int = Form(...),
    parallel_processes: int = Form(...),
    background_tasks: BackgroundTasks = BackgroundTasks()
):
    if platform not in ["instagram", "tiktok", "youtube", "facebook", "twitch", "spotify"]:
        raise HTTPException(status_code=400, detail="Invalid platform. Choose 'instagram', 'tiktok', 'youtube', 'facebook', 'twitch', or 'spotify'.")

    background_tasks.add_task(perform_views, url, platform, count, delay, parallel_processes)
    return PlainTextResponse(f"Started {count} view tasks for {platform} at {url} with {delay} seconds delay and {parallel_processes} parallel processes.")

def increase_views_gradio(url, platform, count, delay, parallel_processes):
    return increase_views(url, platform, count, delay, parallel_processes, background_tasks=BackgroundTasks())

iface = gr.Interface(
    fn=increase_views_gradio,
    inputs=[
        gr.Textbox(label="URL"),
        gr.Dropdown(["instagram", "tiktok", "youtube", "facebook", "twitch", "spotify"], label="Platform"),
        gr.Number(label="View Count", minimum=1),
        gr.Number(label="Delay (seconds)", minimum=1),
        gr.Number(label="Parallel Processes", minimum=1),
    ],
    outputs="text",
    title="Increase Views",
    description="Increase views on your favorite social media platforms.",
)

@app.get("/form", response_class=HTMLResponse)
def form():
    return iface.render()

@app.get("/", response_class=HTMLResponse)
def read_root():
    html_content = """
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>Main Page</title>
            <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
            <style>
                body {
                    background-color: #f8f9fa;
                }
                .container {
                    margin-top: 50px;
                    text-align: center;
                }
                h1 {
                    color: #343a40;
                }
                .btn {
                    margin: 10px;
                }
            </style>
        </head>
        <body>
            <div class="container">
                <h1>Welcome</h1>
                <p>Choose an action:</p>
                <a href="/rotate_ip"><button class="btn btn-primary">Rotate IP</button></a>
                <a href="/form"><button class="btn btn-primary">Increase Views</button></a>
            </div>
        </body>
    </html>
    """
    return HTMLResponse(content=html_content)

if __name__ == "__main__":
    import uvicorn
    iface.launch(share=True)