-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetFollowersExample.py
More file actions
60 lines (43 loc) · 1.95 KB
/
Copy pathgetFollowersExample.py
File metadata and controls
60 lines (43 loc) · 1.95 KB
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
import anyio
from colorama import Fore, init
from asyncX.x import AsyncX
# ✅ Initialize colorama for Windows compatibility
init(autoreset=True)
async def main(usernames=["obJellyfin", "xoey"]):
cookies = {
"auth_token": "4ac359bfbe7196fe85a9c3e6300659bfef472ade",
"kdt": "bhJXX0dmtlSf1ZgtVp0gCzlHURJlJDHTgcZeRDiC",
"ct0": "4dca27a92fe1d77d9d926e019a5b31326b74b145fa6625d8c01cae9a6e06378095d28534e9eb78e98987c7ad0c31511fd8dfd9a68a03082b5031cc4f56eb7f9ff61cf2c29492c20810dc75612784142a",
}
asyncx = AsyncX(debug=True)
await asyncx.authenticate(cookies)
print(Fore.CYAN + f"🔍 Fetching user rest_id for @{usernames}...")
async for data in asyncx.usernamesToRestIds(screen_names=usernames):
if isinstance(data, dict):
rest_id = data.get("rest_id")
username = data.get("username")
print(Fore.GREEN + f"✅ {username} rest_id: {rest_id}")
print()
unique_followers = set()
batch_count = 0
print(Fore.YELLOW + "\n🚀 Fetching followers...")
async for yieldData in asyncx.followers(user_ids=rest_id):
# if yieldData == list, it's a batch of followers
if isinstance(yieldData, list):
batch_count += 1
unique_followers.update(yieldData)
print(
Fore.BLUE
+ f"📦 Batch {batch_count}: {len(yieldData)} followers | Total: {len(unique_followers)}"
)
# if yieldData == dict, its rate limit data
if isinstance(yieldData, dict):
print(
Fore.RED
+ f"⏳ Rate limit exceeded! Resets at {yieldData['reset_time']}."
)
await anyio.sleep(yieldData["wait_time"])
continue
# print(Fore.GREEN + f"\n🎉 Completed! Total unique followers retrieved: {len(unique_followers)}")
# await asyncx.close()
anyio.run(main)