Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,25 @@
|
|
| 1 |
import requests
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
-
from fastapi import FastAPI, Form
|
| 4 |
from fastapi.responses import PlainTextResponse, HTMLResponse
|
| 5 |
from fastapi.staticfiles import StaticFiles
|
| 6 |
from pydantic import BaseModel
|
| 7 |
import re
|
|
|
|
| 8 |
import urllib.parse
|
|
|
|
| 9 |
import fake_useragent as fake
|
| 10 |
import random
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
import os
|
| 13 |
from tqdm import tqdm
|
| 14 |
from faker import Faker
|
| 15 |
-
import
|
| 16 |
-
import time
|
| 17 |
-
import threading
|
| 18 |
|
| 19 |
load_dotenv()
|
| 20 |
|
| 21 |
app = FastAPI()
|
| 22 |
|
| 23 |
-
|
| 24 |
class Proxy(BaseModel):
|
| 25 |
ip: str
|
| 26 |
port: str
|
|
@@ -30,28 +29,24 @@ class VisitRequest(BaseModel):
|
|
| 30 |
platform: str
|
| 31 |
count: int
|
| 32 |
delay: int
|
| 33 |
-
parallel_processes: int
|
| 34 |
|
| 35 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 36 |
|
| 37 |
def get_random_proxy():
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
return None
|
| 46 |
-
except Exception as e:
|
| 47 |
-
print(f"Error getting proxy: {e}")
|
| 48 |
-
return None
|
| 49 |
|
| 50 |
@app.get("/get_proxies", response_class=PlainTextResponse)
|
| 51 |
def get_proxies():
|
| 52 |
try:
|
| 53 |
proxies = []
|
| 54 |
-
pubproxy_url = "http://pubproxy.com/api/proxy?limit=5
|
| 55 |
response = requests.get(pubproxy_url, verify=False)
|
| 56 |
data = response.json()
|
| 57 |
|
|
@@ -67,8 +62,7 @@ def get_proxies():
|
|
| 67 |
@app.get("/rotate_ip", response_class=PlainTextResponse)
|
| 68 |
def rotate_ip():
|
| 69 |
try:
|
| 70 |
-
|
| 71 |
-
random_ip = fake.ipv4()
|
| 72 |
|
| 73 |
headers = {
|
| 74 |
"X-Forwarded-For": random_ip,
|
|
@@ -76,7 +70,7 @@ def rotate_ip():
|
|
| 76 |
"X-Real-IP": random_ip
|
| 77 |
}
|
| 78 |
|
| 79 |
-
test_url = "http://pubproxy.com/api/proxy?limit=1&type=http&https=true"
|
| 80 |
response = requests.get(test_url, headers=headers, verify=False)
|
| 81 |
data = response.json()
|
| 82 |
|
|
@@ -94,14 +88,10 @@ def extract_video_id(url: str, platform: str) -> str:
|
|
| 94 |
url = urllib.parse.unquote(url)
|
| 95 |
if platform == "instagram":
|
| 96 |
match = re.search(r"instagram\.com/reel/([^/?]+)", url)
|
| 97 |
-
if not match:
|
| 98 |
-
match = re.search(r"instagram\.com/p/([^/?]+)", url)
|
| 99 |
elif platform == "tiktok":
|
| 100 |
match = re.search(r"tiktok\.com/@[^/]+/video/(\d+)", url)
|
| 101 |
elif platform == "youtube":
|
| 102 |
match = re.search(r"youtube\.com/watch\?v=([^&]+)", url)
|
| 103 |
-
if not match:
|
| 104 |
-
match = re.search(r"youtu\.be/([^/?]+)", url)
|
| 105 |
elif platform == "facebook":
|
| 106 |
match = re.search(r"facebook\.com/.*/videos/(\d+)", url)
|
| 107 |
elif platform == "twitch":
|
|
@@ -143,65 +133,212 @@ def instagram_login(username: str, password: str):
|
|
| 143 |
raise HTTPException(status_code=401, detail="Authentication failed")
|
| 144 |
|
| 145 |
def tiktok_login(username: str, password: str):
|
|
|
|
| 146 |
session = requests.Session()
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
def youtube_login(username: str, password: str):
|
|
|
|
| 150 |
session = requests.Session()
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
def facebook_login(username: str, password: str):
|
|
|
|
| 154 |
session = requests.Session()
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
def twitch_login(username: str, password: str):
|
|
|
|
| 158 |
session = requests.Session()
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
def spotify_login(username: str, password: str):
|
|
|
|
| 162 |
session = requests.Session()
|
| 163 |
-
return session
|
| 164 |
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
proxies = {
|
| 167 |
-
"http": f"http://{proxy}"
|
|
|
|
| 168 |
}
|
| 169 |
-
|
| 170 |
-
fake_ipv4 = fake.ipv4()
|
| 171 |
headers = {
|
| 172 |
"User-Agent": fake.user_agent(),
|
| 173 |
"X-Forwarded-For": fake_ipv4,
|
| 174 |
"Client-IP": fake_ipv4,
|
| 175 |
"X-Real-IP": fake_ipv4
|
| 176 |
}
|
| 177 |
-
|
| 178 |
try:
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
view_url = f"https://www.facebook.com/{video_id}"
|
| 187 |
-
elif platform == "twitch":
|
| 188 |
-
view_url = f"https://www.twitch.tv/videos/{video_id}"
|
| 189 |
-
elif platform == "spotify":
|
| 190 |
-
view_url = f"https://open.spotify.com/track/{video_id}"
|
| 191 |
-
else:
|
| 192 |
-
print(f"Unsupported platform: {platform}")
|
| 193 |
-
return
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
response = session.get(view_url, headers=headers, proxies=proxies)
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
except Exception as e:
|
| 202 |
-
print(f"Error in
|
| 203 |
|
| 204 |
-
|
| 205 |
video_id = extract_video_id(url, platform)
|
| 206 |
proxy = get_random_proxy()
|
| 207 |
|
|
@@ -209,20 +346,31 @@ async def simulate_views(url: str, platform: str, count: int, delay: int, sessio
|
|
| 209 |
print("No proxy available.")
|
| 210 |
return
|
| 211 |
|
| 212 |
-
for _ in tqdm(range(count), desc=f"Simulating views for {url}"
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
@app.post("/simulate_views")
|
| 217 |
async def simulate_views_endpoint(request: VisitRequest):
|
| 218 |
try:
|
| 219 |
if os.getenv(f'{request.platform.upper()}_USER') and os.getenv(f'{request.platform.upper()}_PASSWORD'):
|
| 220 |
session = authenticate(os.getenv(f'{request.platform.upper()}_USER'), os.getenv(f'{request.platform.upper()}_PASSWORD'), request.platform)
|
| 221 |
-
|
| 222 |
url=request.url,
|
| 223 |
platform=request.platform,
|
| 224 |
count=request.count,
|
| 225 |
delay=request.delay,
|
|
|
|
| 226 |
session=session
|
| 227 |
)
|
| 228 |
return PlainTextResponse("Views simulation started")
|
|
@@ -255,100 +403,23 @@ async def login(username: str = Form(...), password: str = Form(...), platform:
|
|
| 255 |
except HTTPException as e:
|
| 256 |
return e
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
total_urls = 0
|
| 261 |
-
simulation_running = False
|
| 262 |
-
stop_event = threading.Event()
|
| 263 |
-
|
| 264 |
-
@app.get("/views")
|
| 265 |
-
def get_views():
|
| 266 |
-
return {"views": total_views}
|
| 267 |
-
|
| 268 |
-
@app.get("/progress")
|
| 269 |
-
def get_progress():
|
| 270 |
-
if total_urls > 0:
|
| 271 |
-
progress = (current_url_index / total_urls) * 100
|
| 272 |
-
else:
|
| 273 |
-
progress = 0
|
| 274 |
-
return {"progress": progress}
|
| 275 |
-
|
| 276 |
-
@app.post("/start_simulation")
|
| 277 |
-
async def start_simulation(urls: str = Form(...), platform: str = Form(...), count: int = Form(...), delay: int = Form(...), parallel_processes: int = Form(...)):
|
| 278 |
-
global total_views, current_url_index, total_urls, simulation_running, stop_event
|
| 279 |
-
|
| 280 |
-
if simulation_running:
|
| 281 |
-
return {"message": "Simulation already running."}
|
| 282 |
-
|
| 283 |
try:
|
| 284 |
if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):
|
| 285 |
session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
global total_views, current_url_index
|
| 295 |
-
for index in range(current_url_index, len(urls)):
|
| 296 |
-
if stop_event.is_set():
|
| 297 |
-
break
|
| 298 |
-
try:
|
| 299 |
-
url = urls[index]
|
| 300 |
-
video_id = extract_video_id(url, platform)
|
| 301 |
-
proxy = get_random_proxy()
|
| 302 |
-
|
| 303 |
-
if not proxy:
|
| 304 |
-
print("No proxy available.")
|
| 305 |
-
continue
|
| 306 |
-
|
| 307 |
-
fake = Faker()
|
| 308 |
-
fake_ipv4 = fake.ipv4()
|
| 309 |
-
headers = {
|
| 310 |
-
"User-Agent": fake.user_agent(),
|
| 311 |
-
"X-Forwarded-For": fake_ipv4,
|
| 312 |
-
"Client-IP": fake_ipv4,
|
| 313 |
-
"X-Real-IP": fake_ipv4
|
| 314 |
-
}
|
| 315 |
-
proxies = {
|
| 316 |
-
"http": f"http://{proxy}"
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
for _ in range(count):
|
| 320 |
-
if stop_event.is_set():
|
| 321 |
-
break
|
| 322 |
-
simulate_view(video_id, platform, proxy, session)
|
| 323 |
-
total_views += 1
|
| 324 |
-
time.sleep(delay)
|
| 325 |
-
|
| 326 |
-
current_url_index = index + 1
|
| 327 |
-
|
| 328 |
-
except Exception as e:
|
| 329 |
-
print(f"Error processing URL {index+1}: {e}")
|
| 330 |
-
|
| 331 |
-
global simulation_running
|
| 332 |
-
simulation_running = False
|
| 333 |
-
print("Simulation completed.")
|
| 334 |
-
|
| 335 |
-
thread = threading.Thread(target=run_simulation)
|
| 336 |
-
thread.start()
|
| 337 |
-
return {"message": "Simulation started."}
|
| 338 |
else:
|
| 339 |
-
return
|
| 340 |
except Exception as e:
|
| 341 |
-
return
|
| 342 |
-
|
| 343 |
-
@app.post("/stop_simulation")
|
| 344 |
-
async def stop_simulation():
|
| 345 |
-
global simulation_running, stop_event
|
| 346 |
-
if simulation_running:
|
| 347 |
-
stop_event.set()
|
| 348 |
-
simulation_running = False
|
| 349 |
-
return {"message": "Simulation stopped."}
|
| 350 |
-
else:
|
| 351 |
-
return {"message": "Simulation is not running."}
|
| 352 |
|
| 353 |
@app.get("/")
|
| 354 |
async def main_page():
|
|
@@ -418,30 +489,16 @@ async def main_page():
|
|
| 418 |
opacity: 1;
|
| 419 |
}
|
| 420 |
}
|
| 421 |
-
#progress-bar {
|
| 422 |
-
width: 100%;
|
| 423 |
-
height: 30px;
|
| 424 |
-
background-color: #ddd;
|
| 425 |
-
border-radius: 5px;
|
| 426 |
-
overflow: hidden;
|
| 427 |
-
margin-bottom: 20px;
|
| 428 |
-
}
|
| 429 |
-
#progress-bar-fill {
|
| 430 |
-
height: 100%;
|
| 431 |
-
background-color: #007bff;
|
| 432 |
-
width: 0%;
|
| 433 |
-
transition: width 0.5s ease-in-out;
|
| 434 |
-
}
|
| 435 |
</style>
|
| 436 |
</head>
|
| 437 |
<body>
|
| 438 |
<div class="container">
|
| 439 |
<h1>Video Views Simulator</h1>
|
| 440 |
-
<form action="/
|
| 441 |
<label for="urls">Video URLs (one per line):</label><br>
|
| 442 |
-
<textarea id="urls" name="urls"
|
| 443 |
<label for="platform">Platform:</label><br>
|
| 444 |
-
<select id="platform" name="platform"
|
| 445 |
<option value="instagram">Instagram</option>
|
| 446 |
<option value="tiktok">TikTok</option>
|
| 447 |
<option value="youtube">YouTube</option>
|
|
@@ -449,72 +506,23 @@ async def main_page():
|
|
| 449 |
<option value="twitch">Twitch</option>
|
| 450 |
<option value="spotify">Spotify</option>
|
| 451 |
</select><br><br>
|
| 452 |
-
<label for="count">Number of Views
|
| 453 |
-
<input type="number" id="count" name="count" value="1"
|
| 454 |
-
<label for="delay">Delay
|
| 455 |
-
<input type="number" id="delay" name="delay" value="1"
|
| 456 |
-
<
|
|
|
|
|
|
|
| 457 |
</form>
|
| 458 |
-
<br>
|
| 459 |
-
<button id="stop-button" onclick="stopSimulation()" style="display: none;">Stop Simulation</button>
|
| 460 |
-
<br>
|
| 461 |
-
<div id="progress-bar">
|
| 462 |
-
<div id="progress-bar-fill"></div>
|
| 463 |
-
</div>
|
| 464 |
-
<p>Total Views: <span id="total-views">0</span></p>
|
| 465 |
</div>
|
| 466 |
-
|
| 467 |
-
<script>
|
| 468 |
-
let simulationRunning = false;
|
| 469 |
-
|
| 470 |
-
function updateProgress() {
|
| 471 |
-
fetch('/progress')
|
| 472 |
-
.then(response => response.json())
|
| 473 |
-
.then(data => {
|
| 474 |
-
const progressBarFill = document.getElementById('progress-bar-fill');
|
| 475 |
-
progressBarFill.style.width = data.progress + '%';
|
| 476 |
-
})
|
| 477 |
-
.catch(error => console.error('Error updating progress:', error));
|
| 478 |
-
}
|
| 479 |
-
|
| 480 |
-
function updateViews() {
|
| 481 |
-
fetch('/views')
|
| 482 |
-
.then(response => response.json())
|
| 483 |
-
.then(data => {
|
| 484 |
-
document.getElementById('total-views').innerText = data.views;
|
| 485 |
-
})
|
| 486 |
-
.catch(error => console.error('Error updating views:', error));
|
| 487 |
-
}
|
| 488 |
-
|
| 489 |
-
function startSimulation() {
|
| 490 |
-
simulationRunning = true;
|
| 491 |
-
document.getElementById('stop-button').style.display = 'block';
|
| 492 |
-
setInterval(updateProgress, 1000);
|
| 493 |
-
setInterval(updateViews, 5000);
|
| 494 |
-
}
|
| 495 |
-
|
| 496 |
-
function stopSimulation() {
|
| 497 |
-
fetch('/stop_simulation', { method: 'POST' })
|
| 498 |
-
.then(response => {
|
| 499 |
-
if (response.ok) {
|
| 500 |
-
simulationRunning = false;
|
| 501 |
-
document.getElementById('stop-button').style.display = 'none';
|
| 502 |
-
alert('Simulation stopped!');
|
| 503 |
-
} else {
|
| 504 |
-
alert('Error stopping simulation!');
|
| 505 |
-
}
|
| 506 |
-
})
|
| 507 |
-
.catch(error => console.error('Error stopping simulation:', error));
|
| 508 |
-
}
|
| 509 |
-
|
| 510 |
-
const form = document.querySelector('form');
|
| 511 |
-
form.addEventListener('submit', startSimulation);
|
| 512 |
-
</script>
|
| 513 |
</body>
|
| 514 |
</html>
|
| 515 |
"""
|
| 516 |
)
|
| 517 |
|
|
|
|
|
|
|
|
|
|
| 518 |
if __name__ == "__main__":
|
| 519 |
import uvicorn
|
| 520 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 1 |
import requests
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
+
from fastapi import FastAPI, BackgroundTasks, HTTPException, Form
|
| 4 |
from fastapi.responses import PlainTextResponse, HTMLResponse
|
| 5 |
from fastapi.staticfiles import StaticFiles
|
| 6 |
from pydantic import BaseModel
|
| 7 |
import re
|
| 8 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 9 |
import urllib.parse
|
| 10 |
+
import gradio as gr
|
| 11 |
import fake_useragent as fake
|
| 12 |
import random
|
| 13 |
from dotenv import load_dotenv
|
| 14 |
import os
|
| 15 |
from tqdm import tqdm
|
| 16 |
from faker import Faker
|
| 17 |
+
import faker as fakexd
|
|
|
|
|
|
|
| 18 |
|
| 19 |
load_dotenv()
|
| 20 |
|
| 21 |
app = FastAPI()
|
| 22 |
|
|
|
|
| 23 |
class Proxy(BaseModel):
|
| 24 |
ip: str
|
| 25 |
port: str
|
|
|
|
| 29 |
platform: str
|
| 30 |
count: int
|
| 31 |
delay: int
|
| 32 |
+
parallel_processes: int
|
| 33 |
|
| 34 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 35 |
|
| 36 |
def get_random_proxy():
|
| 37 |
+
pubproxy_url = "http://pubproxy.com/api/proxy?limit=1"
|
| 38 |
+
response = requests.get(pubproxy_url, verify=False)
|
| 39 |
+
data = response.json()
|
| 40 |
+
if data['data']:
|
| 41 |
+
proxy_data = data['data'][0]
|
| 42 |
+
return f"{proxy_data['ip']}:{proxy_data['port']}"
|
| 43 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
@app.get("/get_proxies", response_class=PlainTextResponse)
|
| 46 |
def get_proxies():
|
| 47 |
try:
|
| 48 |
proxies = []
|
| 49 |
+
pubproxy_url = "http://pubproxy.com/api/proxy?limit=5"
|
| 50 |
response = requests.get(pubproxy_url, verify=False)
|
| 51 |
data = response.json()
|
| 52 |
|
|
|
|
| 62 |
@app.get("/rotate_ip", response_class=PlainTextResponse)
|
| 63 |
def rotate_ip():
|
| 64 |
try:
|
| 65 |
+
random_ip = fakexd.ipv4()
|
|
|
|
| 66 |
|
| 67 |
headers = {
|
| 68 |
"X-Forwarded-For": random_ip,
|
|
|
|
| 70 |
"X-Real-IP": random_ip
|
| 71 |
}
|
| 72 |
|
| 73 |
+
test_url = "http://pubproxy.com/api/proxy?limit=1&type=http&https=true&speed=60"
|
| 74 |
response = requests.get(test_url, headers=headers, verify=False)
|
| 75 |
data = response.json()
|
| 76 |
|
|
|
|
| 88 |
url = urllib.parse.unquote(url)
|
| 89 |
if platform == "instagram":
|
| 90 |
match = re.search(r"instagram\.com/reel/([^/?]+)", url)
|
|
|
|
|
|
|
| 91 |
elif platform == "tiktok":
|
| 92 |
match = re.search(r"tiktok\.com/@[^/]+/video/(\d+)", url)
|
| 93 |
elif platform == "youtube":
|
| 94 |
match = re.search(r"youtube\.com/watch\?v=([^&]+)", url)
|
|
|
|
|
|
|
| 95 |
elif platform == "facebook":
|
| 96 |
match = re.search(r"facebook\.com/.*/videos/(\d+)", url)
|
| 97 |
elif platform == "twitch":
|
|
|
|
| 133 |
raise HTTPException(status_code=401, detail="Authentication failed")
|
| 134 |
|
| 135 |
def tiktok_login(username: str, password: str):
|
| 136 |
+
login_url = "https://www.tiktok.com/login/"
|
| 137 |
session = requests.Session()
|
| 138 |
+
|
| 139 |
+
login_data = {
|
| 140 |
+
"username": username,
|
| 141 |
+
"password": password
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
response = session.post(login_url, data=login_data)
|
| 145 |
+
|
| 146 |
+
if response.status_code == 200:
|
| 147 |
+
return session
|
| 148 |
+
else:
|
| 149 |
+
raise HTTPException(status_code=401, detail="Authentication failed")
|
| 150 |
|
| 151 |
def youtube_login(username: str, password: str):
|
| 152 |
+
login_url = "https://accounts.google.com/ServiceLogin"
|
| 153 |
session = requests.Session()
|
| 154 |
+
|
| 155 |
+
login_data = {
|
| 156 |
+
"username": username,
|
| 157 |
+
"password": password
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
response = session.post(login_url, data=login_data)
|
| 161 |
+
|
| 162 |
+
if response.status_code == 200:
|
| 163 |
+
return session
|
| 164 |
+
else:
|
| 165 |
+
raise HTTPException(status_code=401, detail="Authentication failed")
|
| 166 |
|
| 167 |
def facebook_login(username: str, password: str):
|
| 168 |
+
login_url = "https://www.facebook.com/login"
|
| 169 |
session = requests.Session()
|
| 170 |
+
|
| 171 |
+
login_data = {
|
| 172 |
+
"email": username,
|
| 173 |
+
"pass": password
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
response = session.post(login_url, data=login_data)
|
| 177 |
+
|
| 178 |
+
if response.status_code == 200:
|
| 179 |
+
return session
|
| 180 |
+
else:
|
| 181 |
+
raise HTTPException(status_code=401, detail="Authentication failed")
|
| 182 |
|
| 183 |
def twitch_login(username: str, password: str):
|
| 184 |
+
login_url = "https://www.twitch.tv/login"
|
| 185 |
session = requests.Session()
|
| 186 |
+
|
| 187 |
+
login_data = {
|
| 188 |
+
"login": username,
|
| 189 |
+
"password": password
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
response = session.post(login_url, data=login_data)
|
| 193 |
+
|
| 194 |
+
if response.status_code == 200:
|
| 195 |
+
return session
|
| 196 |
+
else:
|
| 197 |
+
raise HTTPException(status_code=401, detail="Authentication failed")
|
| 198 |
|
| 199 |
def spotify_login(username: str, password: str):
|
| 200 |
+
login_url = "https://accounts.spotify.com/api/token"
|
| 201 |
session = requests.Session()
|
|
|
|
| 202 |
|
| 203 |
+
login_data = {
|
| 204 |
+
"username": username,
|
| 205 |
+
"password": password
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
response = session.post(login_url, data=login_data)
|
| 209 |
+
|
| 210 |
+
if response.status_code == 200:
|
| 211 |
+
return session
|
| 212 |
+
else:
|
| 213 |
+
raise HTTPException(status_code=401, detail="Authentication failed")
|
| 214 |
+
|
| 215 |
+
def simulate_instagram_view(video_id: str, proxy: str, session: requests.Session):
|
| 216 |
proxies = {
|
| 217 |
+
"http": f"http://{proxy}",
|
| 218 |
+
"https": f"http://{proxy}"
|
| 219 |
}
|
| 220 |
+
fake_ipv4 = fakexd.ipv4()
|
|
|
|
| 221 |
headers = {
|
| 222 |
"User-Agent": fake.user_agent(),
|
| 223 |
"X-Forwarded-For": fake_ipv4,
|
| 224 |
"Client-IP": fake_ipv4,
|
| 225 |
"X-Real-IP": fake_ipv4
|
| 226 |
}
|
|
|
|
| 227 |
try:
|
| 228 |
+
view_url = f"https://www.instagram.com/reel/{video_id}"
|
| 229 |
+
response = session.get(view_url, headers=headers, proxies=proxies)
|
| 230 |
+
embed_link = f"https://www.instagram.com/p/{video_id}/embed/"
|
| 231 |
+
embed_link_with_start = f"{embed_link}?start={rand(4, 8)}"
|
| 232 |
+
print(embed_link_with_start)
|
| 233 |
+
except Exception as e:
|
| 234 |
+
print(f"Error in simulate_instagram_view: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
+
def simulate_tiktok_view(video_id: str, proxy: str, session: requests.Session):
|
| 237 |
+
proxies = {
|
| 238 |
+
"http": f"http://{proxy}",
|
| 239 |
+
"https": f"http://{proxy}"
|
| 240 |
+
}
|
| 241 |
+
fake_ipv4 = fakexd.ipv4()
|
| 242 |
+
headers = {
|
| 243 |
+
"User-Agent": fake.user_agent(),
|
| 244 |
+
"X-Forwarded-For": fake_ipv4,
|
| 245 |
+
"Client-IP": fake_ipv4,
|
| 246 |
+
"X-Real-IP": fake_ipv4
|
| 247 |
+
}
|
| 248 |
+
try:
|
| 249 |
+
view_url = f"https://www.tiktok.com/@user/video/{video_id}"
|
| 250 |
response = session.get(view_url, headers=headers, proxies=proxies)
|
| 251 |
+
embed_link = f"https://www.tiktok.com/embed/v/{video_id}"
|
| 252 |
+
embed_link_with_start = f"{embed_link}?start={rand(4, 8)}"
|
| 253 |
+
print(embed_link_with_start)
|
| 254 |
+
except Exception as e:
|
| 255 |
+
print(f"Error in simulate_tiktok_view: {e}")
|
| 256 |
|
| 257 |
+
def simulate_youtube_view(video_id: str, proxy: str, session: requests.Session):
|
| 258 |
+
proxies = {
|
| 259 |
+
"http": f"http://{proxy}",
|
| 260 |
+
"https": f"http://{proxy}"
|
| 261 |
+
}
|
| 262 |
+
fake_ipv4 = fakexd.ipv4()
|
| 263 |
+
headers = {
|
| 264 |
+
"User-Agent": fake.user_agent(),
|
| 265 |
+
"X-Forwarded-For": fake_ipv4,
|
| 266 |
+
"Client-IP": fake_ipv4,
|
| 267 |
+
"X-Real-IP": fake_ipv4
|
| 268 |
+
}
|
| 269 |
+
try:
|
| 270 |
+
view_url = f"https://www.youtube.com/watch?v={video_id}"
|
| 271 |
+
response = session.get(view_url, headers=headers, proxies=proxies)
|
| 272 |
+
embed_link = f"https://www.youtube.com/embed/{video_id}"
|
| 273 |
+
embed_link_with_start = f"{embed_link}?controls=0&start={rand(4, 8)}"
|
| 274 |
+
print(embed_link_with_start)
|
| 275 |
+
except Exception as e:
|
| 276 |
+
print(f"Error in simulate_youtube_view: {e}")
|
| 277 |
+
|
| 278 |
+
def simulate_facebook_view(video_id: str, proxy: str, session: requests.Session):
|
| 279 |
+
proxies = {
|
| 280 |
+
"http": f"http://{proxy}",
|
| 281 |
+
"https": f"http://{proxy}"
|
| 282 |
+
}
|
| 283 |
+
fake_ipv4 = fakexd.ipv4()
|
| 284 |
+
headers = {
|
| 285 |
+
"User-Agent": fake.user_agent(),
|
| 286 |
+
"X-Forwarded-For": fake_ipv4,
|
| 287 |
+
"Client-IP": fake_ipv4,
|
| 288 |
+
"X-Real-IP": fake_ipv4
|
| 289 |
+
}
|
| 290 |
+
try:
|
| 291 |
+
view_url = f"https://www.facebook.com/{video_id}"
|
| 292 |
+
response = session.get(view_url, headers=headers, proxies=proxies)
|
| 293 |
+
embed_link = f"https://www.facebook.com/plugins/video.php?href=https://www.facebook.com/{video_id}/&show_text=0&width=560&height=315"
|
| 294 |
+
embed_link_with_start = f"{embed_link}&start={rand(4, 8)}"
|
| 295 |
+
print(embed_link_with_start)
|
| 296 |
+
except Exception as e:
|
| 297 |
+
print(f"Error in simulate_facebook_view: {e}")
|
| 298 |
+
|
| 299 |
+
def simulate_twitch_view(video_id: str, proxy: str, session: requests.Session):
|
| 300 |
+
proxies = {
|
| 301 |
+
"http": f"http://{proxy}",
|
| 302 |
+
"https": f"http://{proxy}"
|
| 303 |
+
}
|
| 304 |
+
fake_ipv4 = fakexd.ipv4()
|
| 305 |
+
headers = {
|
| 306 |
+
"User-Agent": fake.user_agent(),
|
| 307 |
+
"X-Forwarded-For": fake_ipv4,
|
| 308 |
+
"Client-IP": fake_ipv4,
|
| 309 |
+
"X-Real-IP": fake_ipv4
|
| 310 |
+
}
|
| 311 |
+
try:
|
| 312 |
+
view_url = f"https://www.twitch.tv/videos/{video_id}"
|
| 313 |
+
response = session.get(view_url, headers=headers, proxies=proxies)
|
| 314 |
+
embed_link = f"https://player.twitch.tv/?video=v{video_id}&parent=www.example.com&autoplay=false&muted=false"
|
| 315 |
+
embed_link_with_start = f"{embed_link}&start={rand(4, 8)}"
|
| 316 |
+
print(embed_link_with_start)
|
| 317 |
+
except Exception as e:
|
| 318 |
+
print(f"Error in simulate_twitch_view: {e}")
|
| 319 |
+
|
| 320 |
+
def simulate_spotify_view(video_id: str, proxy: str, session: requests.Session):
|
| 321 |
+
proxies = {
|
| 322 |
+
"http": f"http://{proxy}",
|
| 323 |
+
"https": f"http://{proxy}"
|
| 324 |
+
}
|
| 325 |
+
fake_ipv4 = fakexd.ipv4()
|
| 326 |
+
headers = {
|
| 327 |
+
"User-Agent": fake.user_agent(),
|
| 328 |
+
"X-Forwarded-For": fake_ipv4,
|
| 329 |
+
"Client-IP": fake_ipv4,
|
| 330 |
+
"X-Real-IP": fake_ipv4
|
| 331 |
+
}
|
| 332 |
+
try:
|
| 333 |
+
view_url = f"https://open.spotify.com/track/{video_id}"
|
| 334 |
+
response = session.get(view_url, headers=headers, proxies=proxies)
|
| 335 |
+
embed_link = f"https://open.spotify.com/embed/track/{video_id}"
|
| 336 |
+
embed_link_with_start = f"{embed_link}?start={rand(4, 8)}"
|
| 337 |
+
print(embed_link_with_start)
|
| 338 |
except Exception as e:
|
| 339 |
+
print(f"Error in simulate_spotify_view: {e}")
|
| 340 |
|
| 341 |
+
def simulate_views(url: str, platform: str, count: int, delay: int, parallel_processes: int, session: requests.Session):
|
| 342 |
video_id = extract_video_id(url, platform)
|
| 343 |
proxy = get_random_proxy()
|
| 344 |
|
|
|
|
| 346 |
print("No proxy available.")
|
| 347 |
return
|
| 348 |
|
| 349 |
+
for _ in tqdm(range(count), desc=f"Simulating views for {url}"):
|
| 350 |
+
if platform == "instagram":
|
| 351 |
+
simulate_instagram_view(video_id, proxy, session)
|
| 352 |
+
elif platform == "tiktok":
|
| 353 |
+
simulate_tiktok_view(video_id, proxy, session)
|
| 354 |
+
elif platform == "youtube":
|
| 355 |
+
simulate_youtube_view(video_id, proxy, session)
|
| 356 |
+
elif platform == "facebook":
|
| 357 |
+
simulate_facebook_view(video_id, proxy, session)
|
| 358 |
+
elif platform == "twitch":
|
| 359 |
+
simulate_twitch_view(video_id, proxy, session)
|
| 360 |
+
elif platform == "spotify":
|
| 361 |
+
simulate_spotify_view(video_id, proxy, session)
|
| 362 |
|
| 363 |
@app.post("/simulate_views")
|
| 364 |
async def simulate_views_endpoint(request: VisitRequest):
|
| 365 |
try:
|
| 366 |
if os.getenv(f'{request.platform.upper()}_USER') and os.getenv(f'{request.platform.upper()}_PASSWORD'):
|
| 367 |
session = authenticate(os.getenv(f'{request.platform.upper()}_USER'), os.getenv(f'{request.platform.upper()}_PASSWORD'), request.platform)
|
| 368 |
+
simulate_views(
|
| 369 |
url=request.url,
|
| 370 |
platform=request.platform,
|
| 371 |
count=request.count,
|
| 372 |
delay=request.delay,
|
| 373 |
+
parallel_processes=request.parallel_processes,
|
| 374 |
session=session
|
| 375 |
)
|
| 376 |
return PlainTextResponse("Views simulation started")
|
|
|
|
| 403 |
except HTTPException as e:
|
| 404 |
return e
|
| 405 |
|
| 406 |
+
@app.post("/simulate")
|
| 407 |
+
async def simulate(urls: str = Form(...), platform: str = Form(...), count: int = Form(...), delay: int = Form(...), parallel_processes: int = Form(...)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
try:
|
| 409 |
if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):
|
| 410 |
session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)
|
| 411 |
+
for index, url in enumerate(urls.split("\n")):
|
| 412 |
+
try:
|
| 413 |
+
simulate_views(url, platform, count, delay, parallel_processes, session)
|
| 414 |
+
print(f"Simulation started for URL {index+1}: {url}")
|
| 415 |
+
except Exception as e:
|
| 416 |
+
print(f"Error processing URL {index+1}: {e}")
|
| 417 |
+
|
| 418 |
+
return PlainTextResponse("Simulation completed.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
else:
|
| 420 |
+
return PlainTextResponse("Credentials not found for this platform.")
|
| 421 |
except Exception as e:
|
| 422 |
+
return PlainTextResponse(str(e), status_code=500)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
|
| 424 |
@app.get("/")
|
| 425 |
async def main_page():
|
|
|
|
| 489 |
opacity: 1;
|
| 490 |
}
|
| 491 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
</style>
|
| 493 |
</head>
|
| 494 |
<body>
|
| 495 |
<div class="container">
|
| 496 |
<h1>Video Views Simulator</h1>
|
| 497 |
+
<form action="/simulate" method="post">
|
| 498 |
<label for="urls">Video URLs (one per line):</label><br>
|
| 499 |
+
<textarea id="urls" name="urls"></textarea><br><br>
|
| 500 |
<label for="platform">Platform:</label><br>
|
| 501 |
+
<select id="platform" name="platform">
|
| 502 |
<option value="instagram">Instagram</option>
|
| 503 |
<option value="tiktok">TikTok</option>
|
| 504 |
<option value="youtube">YouTube</option>
|
|
|
|
| 506 |
<option value="twitch">Twitch</option>
|
| 507 |
<option value="spotify">Spotify</option>
|
| 508 |
</select><br><br>
|
| 509 |
+
<label for="count">Number of Views:</label><br>
|
| 510 |
+
<input type="number" id="count" name="count" value="1"><br><br>
|
| 511 |
+
<label for="delay">Delay (seconds):</label><br>
|
| 512 |
+
<input type="number" id="delay" name="delay" value="1"><br><br>
|
| 513 |
+
<label for="parallel_processes">Parallel Processes:</label><br>
|
| 514 |
+
<input type="number" id="parallel_processes" name="parallel_processes" value="1"><br><br>
|
| 515 |
+
<input type="submit" value="Simulate">
|
| 516 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
</body>
|
| 519 |
</html>
|
| 520 |
"""
|
| 521 |
)
|
| 522 |
|
| 523 |
+
def rand(min, max):
|
| 524 |
+
return random.randint(min, max)
|
| 525 |
+
|
| 526 |
if __name__ == "__main__":
|
| 527 |
import uvicorn
|
| 528 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|