Skip to content

Commit d659ee5

Browse files
authored
Merge pull request #220 from kaifcodec/feat/speed-up
feat: speed up username scans by removing category-wise scan waits
2 parents fe9b72c + 2fb50d4 commit d659ee5

4 files changed

Lines changed: 30 additions & 9 deletions

File tree

user_scanner/core/orchestrator.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def run_user_category(category_path: Path, username: str, show_url: bool = False
4848
results = []
4949
modules = load_modules(category_path)
5050

51-
with ThreadPoolExecutor(max_workers=10) as executor:
51+
with ThreadPoolExecutor(max_workers=20) as executor:
5252
exec_map = executor.map(lambda m: _worker_single(m, username), modules)
5353
for result in exec_map:
5454
result.update(category=category_name)
@@ -60,11 +60,32 @@ def run_user_category(category_path: Path, username: str, show_url: bool = False
6060

6161
def run_user_full(username: str, show_url: bool = False) -> List[Result]:
6262
results = []
63+
all_modules = []
64+
categories = list(load_categories().items())
65+
module_to_cat = {}
66+
printed_categories = set()
67+
68+
for cat_name, cat_path in categories:
69+
modules = load_modules(cat_path)
70+
display_name = cat_name.capitalize()
71+
for m in modules:
72+
all_modules.append(m)
73+
module_to_cat[get_site_name(m)] = display_name
74+
75+
with ThreadPoolExecutor(max_workers=60) as executor:
76+
exec_map = executor.map(
77+
lambda m: _worker_single(m, username), all_modules)
78+
for result in exec_map:
79+
site_name = result.site_name
80+
cat_name = module_to_cat.get(site_name, "Unknown") if site_name else "Unknown"
81+
82+
if cat_name not in printed_categories:
83+
print(f"\n{Fore.MAGENTA}== {cat_name} SITES =={Style.RESET_ALL}")
84+
printed_categories.add(cat_name)
6385

64-
categories = list(load_categories().values())
65-
for category_path in categories:
66-
temp = run_user_category(category_path, username, show_url=show_url)
67-
results.extend(temp)
86+
result.update(category=cat_name)
87+
results.append(result)
88+
result.show(show_url=show_url)
6889

6990
return results
7091

user_scanner/user_scan/gaming/battlenet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def process(response):
5656
return Result.error("Failed to parse response")
5757

5858
return generic_validate(
59-
url, process, show_url=show_url, headers=headers, timeout=15.0, follow_redirects=True
59+
url, process, show_url=show_url, headers=headers, timeout=6.0, follow_redirects=True
6060
)
6161

6262

user_scanner/user_scan/social/tiktok.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def process(response) -> Result:
3737
return Result.taken()
3838
return Result.error("Unable to load tiktok")
3939

40-
return generic_validate(url, process, show_url=show_url, headers=headers)
40+
return generic_validate(url, process, show_url=show_url, headers=headers, timeout=4.0)
4141

4242

4343
if __name__ == "__main__":
@@ -49,4 +49,4 @@ def process(response) -> Result:
4949
elif result == 0:
5050
print("Unavailable!")
5151
else:
52-
print(f"Error occurred! Reason: {result.get_reason()}")
52+
print(f"Error occurred! Reason: {result.get_reason()}")

user_scanner/user_scan/social/youtube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def validate_youtube(user) -> Result:
3535
}
3636

3737

38-
return status_validate(url, 404, 200, show_url=show_url, headers=headers)
38+
return status_validate(url, 404, 200, show_url=show_url, headers=headers, follow_redirects=True)
3939

4040

4141
if __name__ == "__main__":

0 commit comments

Comments
 (0)