Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,45 @@ from selenium.webdriver.common.by import By
|
|
| 6 |
from selenium.webdriver.support import expected_conditions as EC
|
| 7 |
from selenium.webdriver.common.action_chains import ActionChains
|
| 8 |
import gradio as gr
|
| 9 |
-
import
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def get_driver():
|
| 13 |
options = webdriver.ChromeOptions()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
options.add_argument('--headless=new')
|
| 15 |
driver = webdriver.Chrome(options=options)
|
| 16 |
return driver
|
|
@@ -18,19 +52,235 @@ def get_driver():
|
|
| 18 |
def random_sleep(min_seconds, max_seconds):
|
| 19 |
time.sleep(random.uniform(min_seconds, max_seconds))
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def view_instagram_video(video_url, max_playback_time):
|
| 22 |
status_list = []
|
| 23 |
driver = get_driver()
|
|
|
|
| 24 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
try:
|
| 26 |
driver.get(video_url)
|
| 27 |
random_sleep(5, 8)
|
| 28 |
except:
|
| 29 |
status_list.append(f"Error loading video URL: {video_url}")
|
| 30 |
-
return status_list
|
| 31 |
|
| 32 |
try:
|
| 33 |
-
not_now_popup = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, '
|
| 34 |
not_now_buttons = not_now_popup.find_elements(By.TAG_NAME, "button")
|
| 35 |
if len(not_now_buttons) > 1:
|
| 36 |
not_now_button = not_now_buttons[1]
|
|
@@ -43,40 +293,236 @@ def view_instagram_video(video_url, max_playback_time):
|
|
| 43 |
pass
|
| 44 |
|
| 45 |
try:
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
button_to_click = buttons[1]
|
| 50 |
-
button_to_click.click()
|
| 51 |
-
else:
|
| 52 |
-
print("Warning: Popup 'mt3GC' found, but not enough buttons to click.") # More specific warning
|
| 53 |
-
except (TimeoutException, NoSuchElementException, WebDriverException) as e:
|
| 54 |
-
print(f"Warning: Could not handle initial popup: {type(e).__name__} - {e}") # Include exception info
|
| 55 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
finally:
|
| 61 |
if driver:
|
| 62 |
driver.quit()
|
| 63 |
return status_list
|
| 64 |
|
| 65 |
-
def
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
def launch_gradio_interface():
|
| 69 |
iface = gr.Interface(
|
| 70 |
fn=run_button_click,
|
| 71 |
inputs=[
|
| 72 |
-
gr.Textbox(label="
|
|
|
|
| 73 |
gr.Slider(label="Max Playback Time (seconds)", minimum=5, maximum=300, value=30, step=5),
|
| 74 |
-
gr.
|
|
|
|
| 75 |
],
|
| 76 |
-
outputs = gr.Dataframe(headers=["Status"], label="Status"),
|
| 77 |
-
live=False
|
| 78 |
)
|
|
|
|
| 79 |
iface.launch(share=False)
|
| 80 |
|
|
|
|
| 81 |
if __name__ == "__main__":
|
| 82 |
launch_gradio_interface()
|
|
|
|
| 6 |
from selenium.webdriver.support import expected_conditions as EC
|
| 7 |
from selenium.webdriver.common.action_chains import ActionChains
|
| 8 |
import gradio as gr
|
| 9 |
+
import re
|
| 10 |
+
import requests
|
| 11 |
+
from bs4 import BeautifulSoup
|
| 12 |
+
from faker import Faker
|
| 13 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
| 14 |
+
import multiprocessing
|
| 15 |
+
import queue
|
| 16 |
+
|
| 17 |
+
fake = Faker()
|
| 18 |
+
|
| 19 |
+
PROXY_IP = '47.236.149.233'
|
| 20 |
+
PROXY_PORT = 9090
|
| 21 |
+
TEMP_MAIL_WEBSITE_URL = "https://temp-mail.org/es/"
|
| 22 |
+
FREE_SMS_WEBSITE_URL = "https://smsreceivefree.net/"
|
| 23 |
+
FREE_SMS_GET_NUMBER_URL = f"{FREE_SMS_WEBSITE_URL}"
|
| 24 |
+
FREE_SMS_INBOX_URL_BASE = f"{FREE_SMS_WEBSITE_URL}/lc/"
|
| 25 |
+
|
| 26 |
+
view_queue = multiprocessing.Queue()
|
| 27 |
|
| 28 |
def get_driver():
|
| 29 |
options = webdriver.ChromeOptions()
|
| 30 |
+
options.add_argument(f'user-agent={fake.user_agent()}')
|
| 31 |
+
if PROXY_IP and PROXY_PORT:
|
| 32 |
+
options.add_argument(f'--proxy-server=http://{PROXY_IP}:{PROXY_PORT}')
|
| 33 |
+
print(f"Using proxy: {PROXY_IP}:{PROXY_PORT}")
|
| 34 |
+
else:
|
| 35 |
+
print("Using direct connection (no proxy).")
|
| 36 |
+
options.add_argument("--disable-popup-blocking")
|
| 37 |
+
options.add_argument("--disable-infobars")
|
| 38 |
+
options.add_argument("--disable-web-security")
|
| 39 |
+
options.add_argument("--ignore-certificate-errors")
|
| 40 |
+
options.add_argument("--disable-notifications")
|
| 41 |
+
options.add_argument("--disable-extensions")
|
| 42 |
+
options.add_argument("--disable-gpu")
|
| 43 |
+
options.add_argument("--no-sandbox")
|
| 44 |
+
options.add_argument("--disable-dev-shm-usage")
|
| 45 |
+
options.add_argument("--mute-audio")
|
| 46 |
+
options.add_argument('--ignore-ssl-errors=yes')
|
| 47 |
+
options.add_argument('--ignore-certificate-errors')
|
| 48 |
options.add_argument('--headless=new')
|
| 49 |
driver = webdriver.Chrome(options=options)
|
| 50 |
return driver
|
|
|
|
| 52 |
def random_sleep(min_seconds, max_seconds):
|
| 53 |
time.sleep(random.uniform(min_seconds, max_seconds))
|
| 54 |
|
| 55 |
+
def generate_random_username(base_username="user"):
|
| 56 |
+
return f"{base_username}_{random.randint(100000, 999999)}"
|
| 57 |
+
|
| 58 |
+
def generate_random_password(length=15):
|
| 59 |
+
characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()"
|
| 60 |
+
return ''.join(random.choice(characters) for _ in range(length))
|
| 61 |
+
|
| 62 |
+
def get_temp_email_from_website(driver):
|
| 63 |
+
try:
|
| 64 |
+
driver.get(TEMP_MAIL_WEBSITE_URL)
|
| 65 |
+
email_element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "mail")))
|
| 66 |
+
temp_email = email_element.get_attribute('value')
|
| 67 |
+
return temp_email
|
| 68 |
+
except:
|
| 69 |
+
return None
|
| 70 |
+
|
| 71 |
+
def get_verification_code_from_website(driver):
|
| 72 |
+
try:
|
| 73 |
+
start_time = time.time()
|
| 74 |
+
while time.time() - start_time < 120:
|
| 75 |
+
try:
|
| 76 |
+
driver.refresh()
|
| 77 |
+
random_sleep(5, 8)
|
| 78 |
+
email_list_element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "inbox-id-0")))
|
| 79 |
+
email_list_element.click()
|
| 80 |
+
email_frame = WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.ID, "iframeMail")))
|
| 81 |
+
email_body = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.TAG_NAME, "body"))).text
|
| 82 |
+
verification_code_match = re.search(r'Verification code: (\d{6})', email_body)
|
| 83 |
+
if verification_code_match:
|
| 84 |
+
return verification_code_match.group(1)
|
| 85 |
+
driver.switch_to.default_content()
|
| 86 |
+
except:
|
| 87 |
+
driver.switch_to.default_content()
|
| 88 |
+
time.sleep(random.uniform(5, 10))
|
| 89 |
+
return None
|
| 90 |
+
except:
|
| 91 |
+
return None
|
| 92 |
+
|
| 93 |
+
def get_phone_number_from_free_sms_service():
|
| 94 |
+
try:
|
| 95 |
+
response = requests.get(FREE_SMS_GET_NUMBER_URL, timeout=10)
|
| 96 |
+
response.raise_for_status()
|
| 97 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
| 98 |
+
phone_number_element = soup.select_one('.number-line')
|
| 99 |
+
if phone_number_element:
|
| 100 |
+
phone_number = phone_number_element.text.strip()
|
| 101 |
+
return phone_number
|
| 102 |
+
except:
|
| 103 |
+
return None
|
| 104 |
+
|
| 105 |
+
def get_sms_code_from_free_sms_service(phone_number):
|
| 106 |
+
if not phone_number:
|
| 107 |
+
return None
|
| 108 |
+
try:
|
| 109 |
+
start_time = time.time()
|
| 110 |
+
while time.time() - start_time < 120:
|
| 111 |
+
try:
|
| 112 |
+
inbox_url = f"{FREE_SMS_INBOX_URL_BASE}{phone_number.replace('+', '')}"
|
| 113 |
+
response = requests.get(inbox_url, timeout=10)
|
| 114 |
+
response.raise_for_status()
|
| 115 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
| 116 |
+
message_element = soup.select_one('.messages > div:nth-child(2) > div:nth-child(2)')
|
| 117 |
+
if message_element:
|
| 118 |
+
message_text = message_element.text.strip()
|
| 119 |
+
verification_code_match = re.search(r'Verification code: (\d{6})', message_text)
|
| 120 |
+
if verification_code_match:
|
| 121 |
+
return verification_code_match.group(1)
|
| 122 |
+
except:
|
| 123 |
+
pass
|
| 124 |
+
time.sleep(random.uniform(5, 10))
|
| 125 |
+
return None
|
| 126 |
+
except:
|
| 127 |
+
return None
|
| 128 |
+
|
| 129 |
+
def create_instagram_account():
|
| 130 |
+
driver = get_driver()
|
| 131 |
+
try:
|
| 132 |
+
temp_email = get_temp_email_from_website(driver)
|
| 133 |
+
driver.get("https://www.instagram.com/accounts/emailsignup/")
|
| 134 |
+
random_sleep(5, 8)
|
| 135 |
+
username = generate_random_username("insta_user")
|
| 136 |
+
password = generate_random_password()
|
| 137 |
+
full_name = "Test User " + str(random.randint(100, 999))
|
| 138 |
+
email_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "emailOrPhone")))
|
| 139 |
+
email_field.send_keys(temp_email)
|
| 140 |
+
fullname_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "fullName")))
|
| 141 |
+
fullname_field.send_keys(full_name)
|
| 142 |
+
username_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "username")))
|
| 143 |
+
username_field.send_keys(username)
|
| 144 |
+
password_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "password")))
|
| 145 |
+
password_field.send_keys(password)
|
| 146 |
+
signup_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Sign up')]")))
|
| 147 |
+
signup_button.click()
|
| 148 |
+
random_sleep(8, 12)
|
| 149 |
+
month_select = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//select[@title='Month']")))
|
| 150 |
+
month_select.send_keys("January")
|
| 151 |
+
day_select = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//select[@title='Day']")))
|
| 152 |
+
day_select.send_keys("1")
|
| 153 |
+
year_select = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//select[@title='Year']")))
|
| 154 |
+
year_select.send_keys("2000")
|
| 155 |
+
next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Next')]")))
|
| 156 |
+
next_button.click()
|
| 157 |
+
random_sleep(8, 12)
|
| 158 |
+
return driver, f"Instagram Account Creation Attempted: Username: {username}, Email: {temp_email}."
|
| 159 |
+
except:
|
| 160 |
+
if driver:
|
| 161 |
+
driver.quit()
|
| 162 |
+
return None, "Instagram Account Creation Attempted: Error."
|
| 163 |
+
|
| 164 |
+
def create_google_account():
|
| 165 |
+
driver = get_driver()
|
| 166 |
+
try:
|
| 167 |
+
temp_email = get_temp_email_from_website(driver)
|
| 168 |
+
driver.get("https://accounts.google.com/signup")
|
| 169 |
+
random_sleep(5, 8)
|
| 170 |
+
first_name = "Test"
|
| 171 |
+
last_name = "User" + str(random.randint(100, 999))
|
| 172 |
+
username = generate_random_username("google_user")
|
| 173 |
+
password = generate_random_password()
|
| 174 |
+
first_name_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "firstName")))
|
| 175 |
+
first_name_field.send_keys(first_name)
|
| 176 |
+
last_name_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "lastName")))
|
| 177 |
+
last_name_field.send_keys(last_name)
|
| 178 |
+
username_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "username")))
|
| 179 |
+
username_field.send_keys(username)
|
| 180 |
+
password_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "Passwd")))
|
| 181 |
+
password_field.send_keys(password)
|
| 182 |
+
confirm_password_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "ConfirmPasswd")))
|
| 183 |
+
confirm_password_field.send_keys(password)
|
| 184 |
+
next_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Next']")))
|
| 185 |
+
next_button.click()
|
| 186 |
+
random_sleep(8, 12)
|
| 187 |
+
return driver, f"Google Account Creation Attempted (without phone/SMS): Username: {username}, Email: {temp_email}."
|
| 188 |
+
except:
|
| 189 |
+
if driver:
|
| 190 |
+
driver.quit()
|
| 191 |
+
return None, "Google Account Creation Attempted: Error."
|
| 192 |
+
|
| 193 |
+
def create_spotify_account():
|
| 194 |
+
driver = get_driver()
|
| 195 |
+
try:
|
| 196 |
+
temp_email = get_temp_email_from_website(driver)
|
| 197 |
+
driver.get("https://www.spotify.com/signup/")
|
| 198 |
+
random_sleep(5, 8)
|
| 199 |
+
password = generate_random_password()
|
| 200 |
+
profile_name = "Spotify User " + str(random.randint(100, 999))
|
| 201 |
+
birth_month = "January"
|
| 202 |
+
birth_day = "1"
|
| 203 |
+
birth_year = "2000"
|
| 204 |
+
email_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "email")))
|
| 205 |
+
email_field.send_keys(temp_email)
|
| 206 |
+
password_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "password")))
|
| 207 |
+
password_field.send_keys(password)
|
| 208 |
+
confirm_password_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "confirm")))
|
| 209 |
+
confirm_password_field.send_keys(password)
|
| 210 |
+
name_field = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "name")))
|
| 211 |
+
name_field.send_keys(profile_name)
|
| 212 |
+
month_select = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "month")))
|
| 213 |
+
month_select.send_keys(birth_month)
|
| 214 |
+
day_select = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "day")))
|
| 215 |
+
day_select.send_keys(birth_day)
|
| 216 |
+
year_select = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "year")))
|
| 217 |
+
year_select.send_keys("2000")
|
| 218 |
+
signup_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@data-encore-id='buttonPrimary']")))
|
| 219 |
+
signup_button.click()
|
| 220 |
+
random_sleep(10, 15)
|
| 221 |
+
return driver, f"Spotify Account Creation Attempted: Email: {temp_email}."
|
| 222 |
+
except:
|
| 223 |
+
if driver:
|
| 224 |
+
driver.quit()
|
| 225 |
+
return None, "Spotify Account Creation Attempted: Error."
|
| 226 |
+
|
| 227 |
+
def detect_captcha(driver):
|
| 228 |
+
captcha_detected = False
|
| 229 |
+
captcha_message = None
|
| 230 |
+
captcha_element = None
|
| 231 |
+
try:
|
| 232 |
+
captcha_element = driver.find_element(By.ID, "recaptcha-anchor")
|
| 233 |
+
captcha_detected = True
|
| 234 |
+
captcha_message = "Google reCAPTCHA v2 Checkbox detected. Attempting auto-click (not solving)."
|
| 235 |
+
except:
|
| 236 |
+
pass
|
| 237 |
+
try:
|
| 238 |
+
captcha_element = driver.find_element(By.CLASS_NAME, "grecaptcha-badge")
|
| 239 |
+
captcha_detected = True
|
| 240 |
+
captcha_message = "Google reCAPTCHA v3 Badge detected. Attempting auto-click (not solving)."
|
| 241 |
+
except:
|
| 242 |
+
pass
|
| 243 |
+
try:
|
| 244 |
+
captcha_element = driver.find_element(By.CSS_SELECTOR, 'iframe[src*="turnstile"]')
|
| 245 |
+
captcha_detected = True
|
| 246 |
+
captcha_message = "Cloudflare Turnstile CAPTCHA detected. Attempting auto-click (not solving)."
|
| 247 |
+
except:
|
| 248 |
+
pass
|
| 249 |
+
return captcha_detected, captcha_message, captcha_element
|
| 250 |
+
|
| 251 |
def view_instagram_video(video_url, max_playback_time):
|
| 252 |
status_list = []
|
| 253 |
driver = get_driver()
|
| 254 |
+
account_created = False
|
| 255 |
try:
|
| 256 |
+
try:
|
| 257 |
+
driver, creation_status = create_instagram_account()
|
| 258 |
+
status_list.append(creation_status)
|
| 259 |
+
if driver:
|
| 260 |
+
account_created = True
|
| 261 |
+
except:
|
| 262 |
+
status_list.append("Instagram Account Creation Attempted: Error during creation.")
|
| 263 |
+
|
| 264 |
+
captcha_detected, captcha_message, captcha_element = detect_captcha(driver)
|
| 265 |
+
if captcha_detected:
|
| 266 |
+
status_list.append(captcha_message)
|
| 267 |
+
if captcha_element:
|
| 268 |
+
try:
|
| 269 |
+
actions = ActionChains(driver)
|
| 270 |
+
actions.move_to_element(captcha_element).click().perform()
|
| 271 |
+
status_list.append("Auto-clicked CAPTCHA element.")
|
| 272 |
+
random_sleep(5,8)
|
| 273 |
+
except:
|
| 274 |
+
pass
|
| 275 |
+
|
| 276 |
try:
|
| 277 |
driver.get(video_url)
|
| 278 |
random_sleep(5, 8)
|
| 279 |
except:
|
| 280 |
status_list.append(f"Error loading video URL: {video_url}")
|
|
|
|
| 281 |
|
| 282 |
try:
|
| 283 |
+
not_now_popup = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'mt3GC')))
|
| 284 |
not_now_buttons = not_now_popup.find_elements(By.TAG_NAME, "button")
|
| 285 |
if len(not_now_buttons) > 1:
|
| 286 |
not_now_button = not_now_buttons[1]
|
|
|
|
| 293 |
pass
|
| 294 |
|
| 295 |
try:
|
| 296 |
+
video_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, 'video')))
|
| 297 |
+
driver.execute_script("arguments[0].play();", video_element)
|
| 298 |
+
except:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
pass
|
| 300 |
+
random_sleep(5, 7)
|
| 301 |
+
time.sleep(max_playback_time)
|
| 302 |
+
status_list.append(f"Viewed Instagram video (attempted): {video_url}")
|
| 303 |
+
except:
|
| 304 |
+
status_list.append(f"Error processing Instagram video view: {video_url}")
|
| 305 |
+
finally:
|
| 306 |
+
if driver:
|
| 307 |
+
driver.quit()
|
| 308 |
+
return status_list
|
| 309 |
|
| 310 |
+
def view_youtube_video(video_url, max_playback_time):
|
| 311 |
+
status_list = []
|
| 312 |
+
driver = get_driver()
|
| 313 |
+
account_created = False
|
| 314 |
+
try:
|
| 315 |
+
try:
|
| 316 |
+
driver, creation_status = create_google_account()
|
| 317 |
+
status_list.append(creation_status)
|
| 318 |
+
if driver:
|
| 319 |
+
account_created = True
|
| 320 |
+
except:
|
| 321 |
+
status_list.append("Google Account Creation Attempted: Error during creation.")
|
| 322 |
+
|
| 323 |
+
captcha_detected, captcha_message, captcha_element = detect_captcha(driver)
|
| 324 |
+
if captcha_detected:
|
| 325 |
+
status_list.append(captcha_message)
|
| 326 |
+
if captcha_element:
|
| 327 |
+
try:
|
| 328 |
+
actions = ActionChains(driver)
|
| 329 |
+
actions.move_to_element(captcha_element).click().perform()
|
| 330 |
+
status_list.append("Auto-clicked CAPTCHA element.")
|
| 331 |
+
random_sleep(5,8)
|
| 332 |
+
except:
|
| 333 |
+
pass
|
| 334 |
+
|
| 335 |
+
try:
|
| 336 |
+
driver.get(video_url)
|
| 337 |
+
random_sleep(5, 8)
|
| 338 |
+
except:
|
| 339 |
+
status_list.append(f"Error loading video URL: {video_url}")
|
| 340 |
+
|
| 341 |
+
try:
|
| 342 |
+
cookie_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(., 'Aceptar')]")))
|
| 343 |
+
cookie_button.click()
|
| 344 |
+
except:
|
| 345 |
+
pass
|
| 346 |
+
try:
|
| 347 |
+
not_now_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='notification-dialog']//button[contains(., 'No gracias')]")))
|
| 348 |
+
not_now_button.click()
|
| 349 |
+
except:
|
| 350 |
+
pass
|
| 351 |
+
try:
|
| 352 |
+
play_button_container = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "movie_player")))
|
| 353 |
+
actions = ActionChains(driver)
|
| 354 |
+
actions.click(play_button_container).perform()
|
| 355 |
+
except:
|
| 356 |
+
pass
|
| 357 |
+
random_sleep(15, 22)
|
| 358 |
+
time.sleep(max_playback_time)
|
| 359 |
+
status_list.append(f"Viewed YouTube video (attempted): {video_url}")
|
| 360 |
+
except:
|
| 361 |
+
status_list.append(f"Error processing YouTube video view: {video_url}")
|
| 362 |
finally:
|
| 363 |
if driver:
|
| 364 |
driver.quit()
|
| 365 |
return status_list
|
| 366 |
|
| 367 |
+
def view_spotify_track(track_url, max_playback_time):
|
| 368 |
+
status_list = []
|
| 369 |
+
driver = get_driver()
|
| 370 |
+
account_created = False
|
| 371 |
+
try:
|
| 372 |
+
try:
|
| 373 |
+
driver, creation_status = create_spotify_account()
|
| 374 |
+
status_list.append(creation_status)
|
| 375 |
+
if driver:
|
| 376 |
+
account_created = True
|
| 377 |
+
except:
|
| 378 |
+
status_list.append("Spotify Account Creation Attempted: Error during creation.")
|
| 379 |
+
|
| 380 |
+
captcha_detected, captcha_message, captcha_element = detect_captcha(driver)
|
| 381 |
+
if captcha_detected:
|
| 382 |
+
status_list.append(captcha_message)
|
| 383 |
+
if captcha_element:
|
| 384 |
+
try:
|
| 385 |
+
actions = ActionChains(driver)
|
| 386 |
+
actions.move_to_element(captcha_element).click().perform()
|
| 387 |
+
status_list.append("Auto-clicked CAPTCHA element.")
|
| 388 |
+
random_sleep(5,8)
|
| 389 |
+
except:
|
| 390 |
+
pass
|
| 391 |
+
try:
|
| 392 |
+
driver.get(track_url)
|
| 393 |
+
random_sleep(5, 8)
|
| 394 |
+
except:
|
| 395 |
+
status_list.append(f"Error loading track URL: {track_url}")
|
| 396 |
+
|
| 397 |
+
try:
|
| 398 |
+
cookie_consent_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@data-testid='cookie-banner-accept']")))
|
| 399 |
+
cookie_consent_button.click()
|
| 400 |
+
except:
|
| 401 |
+
pass
|
| 402 |
+
try:
|
| 403 |
+
play_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@data-testid='control-button-playpause']")))
|
| 404 |
+
play_button.click()
|
| 405 |
+
except:
|
| 406 |
+
pass
|
| 407 |
+
random_sleep(20, 30)
|
| 408 |
+
time.sleep(max_playback_time)
|
| 409 |
+
status_list.append(f"Viewed Spotify track (attempted): {track_url}")
|
| 410 |
+
except:
|
| 411 |
+
status_list.append(f"Error processing Spotify track view: {track_url}")
|
| 412 |
+
finally:
|
| 413 |
+
if driver:
|
| 414 |
+
driver.quit()
|
| 415 |
+
return status_list
|
| 416 |
+
|
| 417 |
+
def process_single_view_queued(task_id):
|
| 418 |
+
while True:
|
| 419 |
+
try:
|
| 420 |
+
params = view_queue.get(timeout=5)
|
| 421 |
+
except queue.Empty:
|
| 422 |
+
break
|
| 423 |
+
|
| 424 |
+
video_link = params['video_link']
|
| 425 |
+
max_playback_time = params['max_playback_time']
|
| 426 |
+
platform_type = params['platform_type']
|
| 427 |
+
status_list = []
|
| 428 |
+
|
| 429 |
+
try:
|
| 430 |
+
if "instagram.com" in video_link:
|
| 431 |
+
if not ("/reel/" in video_link or "/p/" in video_link):
|
| 432 |
+
status_list.append("Invalid Instagram video link.")
|
| 433 |
+
else:
|
| 434 |
+
status_list.extend(view_instagram_video(video_link, max_playback_time))
|
| 435 |
+
platform_type = "instagram"
|
| 436 |
+
elif "youtube.com" in video_link or "youtu.be" in video_link:
|
| 437 |
+
status_list.extend(view_youtube_video(video_link, max_playback_time))
|
| 438 |
+
platform_type = "youtube"
|
| 439 |
+
elif "open.spotify.com" in video_link and "/track/" in video_link:
|
| 440 |
+
status_list.extend(view_spotify_track(track_url=video_link, max_playback_time=max_playback_time))
|
| 441 |
+
platform_type = "spotify"
|
| 442 |
+
else:
|
| 443 |
+
status_list.append("Invalid video link. Please use Instagram, YouTube, or Spotify track links.")
|
| 444 |
+
except:
|
| 445 |
+
status_list.append(f"Critical error during view processing.")
|
| 446 |
+
finally:
|
| 447 |
+
if status_list:
|
| 448 |
+
print(f"View completed. Status: {status_list[-1] if status_list else 'No Status'}")
|
| 449 |
+
return status_list
|
| 450 |
+
|
| 451 |
+
def process_request_wrapper(video_link, num_views, max_playback_time, num_processes):
|
| 452 |
+
return list(process_request(video_link, num_views, max_playback_time, num_processes))
|
| 453 |
+
|
| 454 |
+
def process_request(video_link, num_views, max_playback_time, num_processes):
|
| 455 |
+
status_all_views = []
|
| 456 |
+
if not video_link:
|
| 457 |
+
status_all_views.append("Please enter a video link.")
|
| 458 |
+
return [[status] for status in status_all_views]
|
| 459 |
+
try:
|
| 460 |
+
num_views = int(num_views)
|
| 461 |
+
if num_views <= 0 or num_views > 10000000:
|
| 462 |
+
status_all_views.append("Number of views must be between 1 and 10,000,000.")
|
| 463 |
+
return [[status] for status in status_all_views]
|
| 464 |
+
except ValueError:
|
| 465 |
+
status_all_views.append("Invalid number of views.")
|
| 466 |
+
return [[status] for status in status_all_views]
|
| 467 |
+
|
| 468 |
+
platform_type = None
|
| 469 |
+
video_link_check = video_link if not isinstance(video_link, list) else video_link[0]
|
| 470 |
+
if "instagram.com" in video_link_check:
|
| 471 |
+
platform_type = "instagram"
|
| 472 |
+
elif "youtube.com" in video_link_check or "youtu.be" in video_link_check:
|
| 473 |
+
platform_type = "youtube"
|
| 474 |
+
elif "open.spotify.com" in video_link_check and "/track/" in video_link_check:
|
| 475 |
+
platform_type = "spotify"
|
| 476 |
+
|
| 477 |
+
for _ in range(num_views):
|
| 478 |
+
view_queue.put({
|
| 479 |
+
'video_link': video_link,
|
| 480 |
+
'max_playback_time': max_playback_time,
|
| 481 |
+
'platform_type': platform_type
|
| 482 |
+
})
|
| 483 |
+
|
| 484 |
+
num_refreshes = 100
|
| 485 |
+
refresh_interval = 5
|
| 486 |
+
refreshes_done = 0
|
| 487 |
+
last_refresh_time = time.time()
|
| 488 |
+
|
| 489 |
+
with multiprocessing.Pool(processes=num_processes) as pool:
|
| 490 |
+
results_iterator = pool.imap_unordered(process_single_view_queued, range(num_views))
|
| 491 |
+
|
| 492 |
+
for statuses in results_iterator:
|
| 493 |
+
if statuses:
|
| 494 |
+
status_all_views.extend(statuses)
|
| 495 |
+
if any("CAPTCHA" in status for status in statuses):
|
| 496 |
+
status_all_views.append("CAPTCHA detected and auto-clicked. CAPTCHA is unlikely to be solved automatically. Manual solving or a paid CAPTCHA service is required for full automation. Account creation and views may be stopped or degraded in quality.")
|
| 497 |
+
|
| 498 |
+
current_time = time.time()
|
| 499 |
+
if current_time - last_refresh_time >= refresh_interval and refreshes_done < num_refreshes:
|
| 500 |
+
yield [[status] for status in status_all_views]
|
| 501 |
+
last_refresh_time = current_time
|
| 502 |
+
refreshes_done += 1
|
| 503 |
+
|
| 504 |
+
yield [[status] for status in status_all_views]
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
def run_button_click(video_link, num_views, max_playback_time, num_processes, _):
|
| 508 |
+
return process_request_wrapper(video_link, num_views, max_playback_time, num_processes)
|
| 509 |
|
| 510 |
def launch_gradio_interface():
|
| 511 |
iface = gr.Interface(
|
| 512 |
fn=run_button_click,
|
| 513 |
inputs=[
|
| 514 |
+
gr.Textbox(label="Video Link", placeholder="Enter Instagram, YouTube, or Spotify Track Link"),
|
| 515 |
+
gr.Number(label="Number of Views (Max 10,000,000)", value=1, minimum=1, maximum=10000000, step=1),
|
| 516 |
gr.Slider(label="Max Playback Time (seconds)", minimum=5, maximum=300, value=30, step=5),
|
| 517 |
+
gr.Slider(label="Number of Processes (Simultaneous Views - Max 100, Be Resourceful!)", minimum=1, maximum=100, value=1, step=1, visible=True),
|
| 518 |
+
gr.Button("Run View Bot")
|
| 519 |
],
|
| 520 |
+
outputs = gr.Dataframe(headers=["Status"], label="View Status"),
|
| 521 |
+
live=False # Changed to False
|
| 522 |
)
|
| 523 |
+
iface.queue(max_size=1000000)
|
| 524 |
iface.launch(share=False)
|
| 525 |
|
| 526 |
+
|
| 527 |
if __name__ == "__main__":
|
| 528 |
launch_gradio_interface()
|