-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
82 lines (66 loc) · 2.68 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import instabot as pyinstafollow
import instaloader
import shutil
import time
import json
import os
os.system("title PyInstaFollow")
print("[+] Welcome to PyInstaFollow!")
with open("config.json", "r", encoding="utf-8") as file:
login_data = json.load(file)
username = login_data["username"]
password = login_data["password"]
login_on_start = login_data["login-on-start"]
L = instaloader.Instaloader()
global is_logged_in; is_logged_in = False
def login():
global is_logged_in
try:
print("\n[+] Logging in...")
L.login(username, password)
print("[+] Logged in!")
is_logged_in = True
except Exception as e:
print("[!] Login failed:\n" + str(e))
print("\n[+] Press Enter to continue..."); os.system("pause > nul"); os.system("cls")
def read_usernames_from_csv(filename):
with open(filename, 'r', encoding="utf-8") as file:
return set(line.strip() for line in file)
def backup_cvs_files(mode):
if not os.path.exists("backup\\"):
os.mkdir("backup")
if os.path.exists(f"output\\{mode}.csv"):
try:
shutil.copy(f"output\\{mode}.csv", "backup")
print(f"[+] {mode}.csv has been backed up.")
except: print("[!] Something went wrong!")
if login_on_start:
login()
while True:
print("\nSelect an option:\n[1] Get Followers\n[2] Get Followees\n[3] Compare\n[4] Backup\n")
user_choice = input(">> ")
match user_choice:
case '1':
if not login_on_start and not is_logged_in:
login()
pyinstafollow.follow_handler("followers", L)
case '2':
if not login_on_start and not is_logged_in:
login()
pyinstafollow.follow_handler("followees", L)
case '3':
if os.path.exists("output\\followers.csv") and os.path.exists("output\\followees.csv"):
os.system("cls")
print("[+] List of people not following you back will be printed below.\n")
time.sleep(1)
followers = read_usernames_from_csv('output\\followers.csv')
followees = read_usernames_from_csv('output\\followees.csv')
non_followers = followees - followers
for username in non_followers:
print(username)
else: print("[!] Error: Files are missing...\nPlease run options [1] and [2] before comparing.")
case '4':
backup_cvs_files("followers")
backup_cvs_files("followees")
case _: print("[!] Invalid option. Please try again.")
print("\n[+] Press Enter to continue..."); os.system("pause > nul"); os.system("cls")