You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

227 lines
7.2 KiB

import random
import traceback
from getopt import getopt
from sys import argv
from time import sleep
from datetime import datetime
from config import set_pwd
from random import randint
if __name__ == "__main__":
print()
proxieservers = 'mullvad'
# Argument och alternativ
# Variabler som kan ändras
url_other_pictures = [] # Fylls eventuellt på
test = False
write = True
mode = 'all'
pwd = None
proxieservers = 'mullvad'
argv = argv[1:]
opts, args = getopt(argv, "bim:u:o:p:wl:", ["backup", "images", "mode=", "user=", "other=", "profiles=", "write", "password="])
for o, a in opts:
print(o)
if o in ['-l', "--password"]:
pwd = a.strip()
set_pwd(pwd)
# Importera andra moduler
from config import url_bas
from arangodb import (
blocked_profile,
new_profile,
backup,
get_user,
check_for_user,
friends_of_user,
)
from classes import Profile, User
from helpers import sleep_, write_error, _print, check_profile_status, update_cookie
from scrapers import profile_picture_reactions
for o, a in opts:
# Bestäm vilka profiler/proxies som ska användas
if o in ['-p', '--profiles']:
proxieservers = a.strip()
print(f'Proxieservers: {proxieservers}')
# Bestäm mode
if o in ["-m", "--mode"]:
mode = a.strip()
if mode == "single":
mode_nr = 1.7
elif mode == "few":
mode_nr = 1.4
elif mode == "solo":
mode_nr = 1.4
elif mode == "force":
mode_nr = 1
# Bestäm user
if o in ["-u", "--user"]:
if a == 'test': # För att testa profiler i profiles_test
test = True
container = str(a.strip())
if all([a.strip()[:4] == "leak", len(a) < 7]) or a == 'test':
sleep(randint(0, 40)/10) # För att docker service inte ska gå vidare exakt samtidigt
lookups = "leak_lookups"
userdoc = get_user(collection=lookups)
elif a.strip()[:7] == "lookups":
lookups = "lookups"
userdoc = get_user(collection=lookups)
if 'other' in userdoc:
url_other_pictures = userdoc['other']
else:
url_other_pictures = []
elif a == 'test':
lookups = "leak_lookups"
userdoc = get_user(collection=lookups)
else:
lookups = "lookups"
userdoc = {'_key': a}
if o in ["-o", "--other"]:
url_other_pictures = a.split(",")
if o in ["-b", "--backup"]:
backup(db)
if o in ['-w', "--write"]:
write = False
if 'userdoc' not in globals():
lookups = "lookups"
userdoc = {'_key': str(input("Vem/vilka vill du kolla bilder för? ")).strip()}
print('Mode:', mode)
print('Write:', write)
# Hämta en användare att kolla upp
user = User(str(userdoc['_key']).strip(), mode, other_pictures=url_other_pictures)
if "url_other_pictures" in globals():
l = []
for url in url_other_pictures:
l.append(url[url.find("facebook.com") + 12 :])
user.url_other_pictures = l
# Hämta profil
profile = new_profile(container, proxieservers)
profile.write = write
update_cookie(profile.browser.session.cookies, profile)
sleep(3)
# Gå igenom de användare som efterfrågats
if lookups == "leak_lookups":
id = user.username
check_profile_status(profile, user)
if profile.blocked:
profile = blocked_profile(profile, proxieservers=proxieservers)
profile.open(url_bas + "/" + user.username)
url = profile.browser.state.url.strip("/").strip("?_rdr")
if "php?" not in url:
user = User(str(url[url.rfind("/") + 1 :]).strip(), mode)
user.id = id
sleep_(4)
container = str(user.username)
profile.container = container
if "container" not in globals():
container = str(user.username)
profile.container = container
profile.users_checked += 1
# Hämta reaktioner för den första användaren
if any([not check_for_user(user.username, mode=mode), mode == "force"]):
try:
while True:
# Uppdatera in_use
profile.update_time()
profile = profile_picture_reactions(
profile, user, first_user=True, mode=mode
)
if profile.blocked:
profile = blocked_profile(profile, proxieservers=proxieservers)
else:
break
except:
_print(profile, user, traceback.format_exc())
if mode == 'solo':
exit()
friends = friends_of_user(user.username)
_print(profile, user, f"\nKlar med, {user.username}\n")
_print(profile, user, f"Vänner som reagerat: {len(friends)}")
_print(profile, user, "\nVänner att kolla:")
friends_unchecked = []
for friend in friends:
if not check_for_user(friend):
print(friend)
friends_unchecked.append(friend)
_print(profile, user, [friends_unchecked], silent=True)
_print(profile, user, f'Totalt: {len(friends_unchecked)}')
print()
# Hämta reaktioner för users vänner (som reagerat)
count_friends = 0
for friend in friends_unchecked:
if datetime.now().strftime("%H") == '03' and int(datetime.now().strftime("%M")) < 30: # Sov för att kunna säkerhetskopieraa
sleep(1800)
count_friends += 1
user = User(str(friend), mode, other_pictures=[])
sleep_(2)
# Uppdatera in_use
profile.update_time()
try:
if not check_for_user(user.username):
p = profile_picture_reactions(profile, user, mode=mode)
if isinstance(p, Profile):
profile = p
except Exception as e: # Fel4
write_error(
4,
profile,
e=e,
user=user,
traceback=traceback.format_exc(),
soup=profile.viewing(),
)
_print(profile, user, f"\nFel: {str(user.username)}\n")
sleep_(15)
if not profile.blocked:
_print(profile, user, f"Klar med {user.username} \n")
# Rotera fb-profiler
if count_friends > 2 * mode_nr:
if random.randrange(0, 2, 1) == 1:
profile = new_profile(container, proxieservers=proxieservers)
count_friends = 0
_print(profile, user, f"Växlar till {profile.name}")
elif count_friends > 4 * mode_nr:
profile = new_profile(container, proxieservers=proxieservers)
count_friends = 0
_print(profile, user, f"Växlar till {profile.name}")
elif profile.blocked:
profile = blocked_profile(profile, proxieservers=proxieservers)
_print(profile, None, f"Klar med alla vänner.")