Update app.py
Browse files
app.py
CHANGED
|
@@ -344,20 +344,19 @@ def simulate_views(url: str, platform: str, count: int, delay: int, parallel_pro
|
|
| 344 |
print("No proxy available.")
|
| 345 |
return
|
| 346 |
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
executor.submit(simulate_spotify_view, video_id, proxy, session)
|
| 361 |
|
| 362 |
@app.post("/simulate_views")
|
| 363 |
async def simulate_views_endpoint(request: VisitRequest):
|
|
@@ -402,39 +401,134 @@ async def login(username: str = Form(...), password: str = Form(...), platform:
|
|
| 402 |
except HTTPException as e:
|
| 403 |
return e
|
| 404 |
|
| 405 |
-
|
|
|
|
| 406 |
try:
|
| 407 |
if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):
|
| 408 |
session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
executor.submit(simulate_views, url, platform, count, delay, parallel_processes, session)
|
| 416 |
-
print(f"Simulation started for URL {index+1}: {url}")
|
| 417 |
-
except Exception as e:
|
| 418 |
-
print(f"Error processing URL {index+1}: {e}")
|
| 419 |
|
| 420 |
-
return "Simulation completed."
|
| 421 |
else:
|
| 422 |
-
return "Credentials not found for this platform."
|
| 423 |
except Exception as e:
|
| 424 |
-
return
|
| 425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
def rand(min, max):
|
| 428 |
return random.randint(min, max)
|
| 429 |
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
gr.Textbox(label="Video URLs (one per line)"),
|
| 434 |
-
gr.Dropdown(choices=["instagram", "tiktok", "youtube", "facebook", "twitch", "spotify"], label="Platform"),
|
| 435 |
-
gr.Slider(minimum=1, maximum=1000, label="Count"),
|
| 436 |
-
gr.Slider(minimum=1, maximum=60, label="Delay (seconds)"),
|
| 437 |
-
gr.Slider(minimum=1, maximum=10, label="Parallel Processes")
|
| 438 |
-
],
|
| 439 |
-
outputs=gr.Textbox(label="Output")
|
| 440 |
-
).launch(share=True)
|
|
|
|
| 344 |
print("No proxy available.")
|
| 345 |
return
|
| 346 |
|
| 347 |
+
for _ in tqdm(range(count), desc=f"Simulating views for {url}"):
|
| 348 |
+
if platform == "instagram":
|
| 349 |
+
simulate_instagram_view(video_id, proxy, session)
|
| 350 |
+
elif platform == "tiktok":
|
| 351 |
+
simulate_tiktok_view(video_id, proxy, session)
|
| 352 |
+
elif platform == "youtube":
|
| 353 |
+
simulate_youtube_view(video_id, proxy, session)
|
| 354 |
+
elif platform == "facebook":
|
| 355 |
+
simulate_facebook_view(video_id, proxy, session)
|
| 356 |
+
elif platform == "twitch":
|
| 357 |
+
simulate_twitch_view(video_id, proxy, session)
|
| 358 |
+
elif platform == "spotify":
|
| 359 |
+
simulate_spotify_view(video_id, proxy, session)
|
|
|
|
| 360 |
|
| 361 |
@app.post("/simulate_views")
|
| 362 |
async def simulate_views_endpoint(request: VisitRequest):
|
|
|
|
| 401 |
except HTTPException as e:
|
| 402 |
return e
|
| 403 |
|
| 404 |
+
@app.post("/simulate")
|
| 405 |
+
async def simulate(urls: str = Form(...), platform: str = Form(...), count: int = Form(...), delay: int = Form(...), parallel_processes: int = Form(...)):
|
| 406 |
try:
|
| 407 |
if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):
|
| 408 |
session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)
|
| 409 |
+
for index, url in enumerate(urls.split("\n")):
|
| 410 |
+
try:
|
| 411 |
+
simulate_views(url, platform, count, delay, parallel_processes, session)
|
| 412 |
+
print(f"Simulation started for URL {index+1}: {url}")
|
| 413 |
+
except Exception as e:
|
| 414 |
+
print(f"Error processing URL {index+1}: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
|
| 416 |
+
return PlainTextResponse("Simulation completed.")
|
| 417 |
else:
|
| 418 |
+
return PlainTextResponse("Credentials not found for this platform.")
|
| 419 |
except Exception as e:
|
| 420 |
+
return PlainTextResponse(str(e), status_code=500)
|
| 421 |
|
| 422 |
+
@app.get("/")
|
| 423 |
+
async def main_page():
|
| 424 |
+
return HTMLResponse(
|
| 425 |
+
"""
|
| 426 |
+
<!DOCTYPE html>
|
| 427 |
+
<html>
|
| 428 |
+
<head>
|
| 429 |
+
<title>Video Views Simulator</title>
|
| 430 |
+
<style>
|
| 431 |
+
body {
|
| 432 |
+
background-color: #f0f0f0;
|
| 433 |
+
font-family: sans-serif;
|
| 434 |
+
display: flex;
|
| 435 |
+
justify-content: center;
|
| 436 |
+
align-items: center;
|
| 437 |
+
min-height: 100vh;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
.container {
|
| 441 |
+
background-color: #fff;
|
| 442 |
+
padding: 30px;
|
| 443 |
+
border-radius: 10px;
|
| 444 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
| 445 |
+
text-align: center;
|
| 446 |
+
animation: fadeIn 1s ease-in-out;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
h1 {
|
| 450 |
+
color: #333;
|
| 451 |
+
margin-bottom: 20px;
|
| 452 |
+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
form {
|
| 456 |
+
display: flex;
|
| 457 |
+
flex-direction: column;
|
| 458 |
+
width: 350px;
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
label {
|
| 462 |
+
margin-bottom: 5px;
|
| 463 |
+
font-weight: bold;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
input[type="text"],
|
| 467 |
+
textarea,
|
| 468 |
+
select,
|
| 469 |
+
input[type="number"] {
|
| 470 |
+
padding: 10px;
|
| 471 |
+
margin-bottom: 15px;
|
| 472 |
+
border: 1px solid #ddd;
|
| 473 |
+
border-radius: 5px;
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
input[type="submit"] {
|
| 477 |
+
background-color: #007bff;
|
| 478 |
+
color: #fff;
|
| 479 |
+
border: none;
|
| 480 |
+
padding: 12px 20px;
|
| 481 |
+
border-radius: 5px;
|
| 482 |
+
cursor: pointer;
|
| 483 |
+
transition: background-color 0.3s;
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
input[type="submit"]:hover {
|
| 487 |
+
background-color: #0056b3;
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
@keyframes fadeIn {
|
| 491 |
+
from {
|
| 492 |
+
opacity: 0;
|
| 493 |
+
}
|
| 494 |
+
to {
|
| 495 |
+
opacity: 1;
|
| 496 |
+
}
|
| 497 |
+
}
|
| 498 |
+
</style>
|
| 499 |
+
</head>
|
| 500 |
+
<body>
|
| 501 |
+
<div class="container">
|
| 502 |
+
<h1>Video Views Simulator</h1>
|
| 503 |
+
<form action="/simulate" method="post">
|
| 504 |
+
<label for="urls">Video URLs (one per line):</label><br>
|
| 505 |
+
<textarea id="urls" name="urls"></textarea><br><br>
|
| 506 |
+
<label for="platform">Platform:</label><br>
|
| 507 |
+
<select id="platform" name="platform">
|
| 508 |
+
<option value="instagram">Instagram</option>
|
| 509 |
+
<option value="tiktok">TikTok</option>
|
| 510 |
+
<option value="youtube">YouTube</option>
|
| 511 |
+
<option value="facebook">Facebook</option>
|
| 512 |
+
<option value="twitch">Twitch</option>
|
| 513 |
+
<option value="spotify">Spotify</option>
|
| 514 |
+
</select><br><br>
|
| 515 |
+
<label for="count">Number of Views:</label><br>
|
| 516 |
+
<input type="number" id="count" name="count" value="1"><br><br>
|
| 517 |
+
<label for="delay">Delay (seconds):</label><br>
|
| 518 |
+
<input type="number" id="delay" name="delay" value="1"><br><br>
|
| 519 |
+
<label for="parallel_processes">Parallel Processes:</label><br>
|
| 520 |
+
<input type="number" id="parallel_processes" name="parallel_processes" value="1"><br><br>
|
| 521 |
+
<input type="submit" value="Simulate">
|
| 522 |
+
</form>
|
| 523 |
+
</div>
|
| 524 |
+
</body>
|
| 525 |
+
</html>
|
| 526 |
+
"""
|
| 527 |
+
)
|
| 528 |
|
| 529 |
def rand(min, max):
|
| 530 |
return random.randint(min, max)
|
| 531 |
|
| 532 |
+
if __name__ == "__main__":
|
| 533 |
+
import uvicorn
|
| 534 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|