Update app.py
Browse files
app.py
CHANGED
|
@@ -244,8 +244,9 @@ def simulate_instagram_view(video_id: str, proxy: Proxy, session: Client):
|
|
| 244 |
pass
|
| 245 |
|
| 246 |
time.sleep(rand(10, 20))
|
|
|
|
| 247 |
except Exception as e:
|
| 248 |
-
|
| 249 |
finally:
|
| 250 |
driver.quit()
|
| 251 |
|
|
@@ -299,8 +300,9 @@ def simulate_tiktok_view(video_id: str, proxy: Proxy, session: Client):
|
|
| 299 |
pass
|
| 300 |
|
| 301 |
time.sleep(rand(10, 20))
|
|
|
|
| 302 |
except Exception as e:
|
| 303 |
-
|
| 304 |
finally:
|
| 305 |
driver.quit()
|
| 306 |
|
|
@@ -354,8 +356,9 @@ def simulate_youtube_view(video_id: str, proxy: Proxy, session: Client):
|
|
| 354 |
pass
|
| 355 |
|
| 356 |
time.sleep(rand(10, 20))
|
|
|
|
| 357 |
except Exception as e:
|
| 358 |
-
|
| 359 |
finally:
|
| 360 |
driver.quit()
|
| 361 |
|
|
@@ -409,8 +412,9 @@ def simulate_facebook_view(video_id: str, proxy: Proxy, session: Client):
|
|
| 409 |
pass
|
| 410 |
|
| 411 |
time.sleep(rand(10, 20))
|
|
|
|
| 412 |
except Exception as e:
|
| 413 |
-
|
| 414 |
finally:
|
| 415 |
driver.quit()
|
| 416 |
|
|
@@ -464,8 +468,9 @@ def simulate_twitch_view(video_id: str, proxy: Proxy, session: Client):
|
|
| 464 |
pass
|
| 465 |
|
| 466 |
time.sleep(rand(10, 20))
|
|
|
|
| 467 |
except Exception as e:
|
| 468 |
-
|
| 469 |
finally:
|
| 470 |
driver.quit()
|
| 471 |
|
|
@@ -519,8 +524,9 @@ def simulate_spotify_view(video_id: str, proxy: Proxy, session: Client):
|
|
| 519 |
pass
|
| 520 |
|
| 521 |
time.sleep(rand(10, 20))
|
|
|
|
| 522 |
except Exception as e:
|
| 523 |
-
|
| 524 |
finally:
|
| 525 |
driver.quit()
|
| 526 |
|
|
@@ -530,23 +536,36 @@ def simulate_views_background(url: str, platform: str, count: int, delay: int, s
|
|
| 530 |
if not proxy:
|
| 531 |
return
|
| 532 |
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 550 |
|
| 551 |
def simulate_views_endpoint(request: VisitRequest):
|
| 552 |
try:
|
|
@@ -561,7 +580,7 @@ def simulate_views_endpoint(request: VisitRequest):
|
|
| 561 |
request.platform,
|
| 562 |
request.count,
|
| 563 |
request.delay,
|
| 564 |
-
session,
|
| 565 |
)
|
| 566 |
).start()
|
| 567 |
|
|
@@ -598,7 +617,6 @@ def simulate(urls: str, platform: str, count: int, delay: int, parallel_processe
|
|
| 598 |
session = None
|
| 599 |
if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):
|
| 600 |
session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)
|
| 601 |
-
|
| 602 |
for url in urls.split("\n"):
|
| 603 |
for _ in range(parallel_processes):
|
| 604 |
threading.Thread(
|
|
|
|
| 244 |
pass
|
| 245 |
|
| 246 |
time.sleep(rand(10, 20))
|
| 247 |
+
return True
|
| 248 |
except Exception as e:
|
| 249 |
+
return False
|
| 250 |
finally:
|
| 251 |
driver.quit()
|
| 252 |
|
|
|
|
| 300 |
pass
|
| 301 |
|
| 302 |
time.sleep(rand(10, 20))
|
| 303 |
+
return True
|
| 304 |
except Exception as e:
|
| 305 |
+
return False
|
| 306 |
finally:
|
| 307 |
driver.quit()
|
| 308 |
|
|
|
|
| 356 |
pass
|
| 357 |
|
| 358 |
time.sleep(rand(10, 20))
|
| 359 |
+
return True
|
| 360 |
except Exception as e:
|
| 361 |
+
return False
|
| 362 |
finally:
|
| 363 |
driver.quit()
|
| 364 |
|
|
|
|
| 412 |
pass
|
| 413 |
|
| 414 |
time.sleep(rand(10, 20))
|
| 415 |
+
return True
|
| 416 |
except Exception as e:
|
| 417 |
+
return False
|
| 418 |
finally:
|
| 419 |
driver.quit()
|
| 420 |
|
|
|
|
| 468 |
pass
|
| 469 |
|
| 470 |
time.sleep(rand(10, 20))
|
| 471 |
+
return True
|
| 472 |
except Exception as e:
|
| 473 |
+
return False
|
| 474 |
finally:
|
| 475 |
driver.quit()
|
| 476 |
|
|
|
|
| 524 |
pass
|
| 525 |
|
| 526 |
time.sleep(rand(10, 20))
|
| 527 |
+
return True
|
| 528 |
except Exception as e:
|
| 529 |
+
return False
|
| 530 |
finally:
|
| 531 |
driver.quit()
|
| 532 |
|
|
|
|
| 536 |
if not proxy:
|
| 537 |
return
|
| 538 |
|
| 539 |
+
successful_views = 0
|
| 540 |
+
failed_views = 0
|
| 541 |
+
with tqdm(total=count, desc=f"Simulating views for {url}") as pbar:
|
| 542 |
+
for i in range(count):
|
| 543 |
+
try:
|
| 544 |
+
if platform == "instagram":
|
| 545 |
+
success = simulate_instagram_view(video_id, proxy, session)
|
| 546 |
+
elif platform == "tiktok":
|
| 547 |
+
success = simulate_tiktok_view(video_id, proxy, session)
|
| 548 |
+
elif platform == "youtube":
|
| 549 |
+
success = simulate_youtube_view(video_id, proxy, session)
|
| 550 |
+
elif platform == "facebook":
|
| 551 |
+
success = simulate_facebook_view(video_id, proxy, session)
|
| 552 |
+
elif platform == "twitch":
|
| 553 |
+
success = simulate_twitch_view(video_id, proxy, session)
|
| 554 |
+
elif platform == "spotify":
|
| 555 |
+
success = simulate_spotify_view(video_id, proxy, session)
|
| 556 |
+
|
| 557 |
+
if success:
|
| 558 |
+
successful_views += 1
|
| 559 |
+
else:
|
| 560 |
+
failed_views += 1
|
| 561 |
+
|
| 562 |
+
pbar.update(1)
|
| 563 |
+
pbar.set_postfix({"Successful": successful_views, "Failed": failed_views})
|
| 564 |
+
time.sleep(delay)
|
| 565 |
+
except Exception as e:
|
| 566 |
+
failed_views += 1
|
| 567 |
+
pbar.update(1)
|
| 568 |
+
pbar.set_postfix({"Successful": successful_views, "Failed": failed_views})
|
| 569 |
|
| 570 |
def simulate_views_endpoint(request: VisitRequest):
|
| 571 |
try:
|
|
|
|
| 580 |
request.platform,
|
| 581 |
request.count,
|
| 582 |
request.delay,
|
| 583 |
+
session,
|
| 584 |
)
|
| 585 |
).start()
|
| 586 |
|
|
|
|
| 617 |
session = None
|
| 618 |
if os.getenv(f'{platform.upper()}_USER') and os.getenv(f'{platform.upper()}_PASSWORD'):
|
| 619 |
session = authenticate(os.getenv(f'{platform.upper()}_USER'), os.getenv(f'{platform.upper()}_PASSWORD'), platform)
|
|
|
|
| 620 |
for url in urls.split("\n"):
|
| 621 |
for _ in range(parallel_processes):
|
| 622 |
threading.Thread(
|