diff --git a/maigret/checking.py b/maigret/checking.py index 8a6e795..7667580 100644 --- a/maigret/checking.py +++ b/maigret/checking.py @@ -6,6 +6,7 @@ try: except ImportError: from unittest.mock import Mock +import ast import re import ssl import sys @@ -374,8 +375,16 @@ def process_site_result( if extracted_ids_data: new_usernames = {} for k, v in extracted_ids_data.items(): - if "username" in k: + if "username" in k and not "usernames" in k: new_usernames[v] = "username" + elif "usernames" in k: + try: + tree = ast.literal_eval(v) + if type(tree) == list: + for n in tree: + new_usernames[n] = "username" + except Exception as e: + logger.warning(e) if k in SUPPORTED_IDS: new_usernames[v] = k diff --git a/maigret/maigret.py b/maigret/maigret.py index b4858fa..aafb55e 100755 --- a/maigret/maigret.py +++ b/maigret/maigret.py @@ -1,6 +1,7 @@ """ Maigret main module """ +import ast import asyncio import logging import os @@ -85,8 +86,17 @@ def extract_ids_from_page(url, logger, timeout=5) -> dict: else: print(get_dict_ascii_tree(info.items(), new_line=False), ' ') for k, v in info.items(): - if 'username' in k: + # TODO: merge with the same functionality in checking module + if 'username' in k and not 'usernames' in k: results[v] = 'username' + elif 'usernames' in k: + try: + tree = ast.literal_eval(v) + if type(tree) == list: + for n in tree: + results[n] = 'username' + except Exception as e: + logger.warning(e) if k in SUPPORTED_IDS: results[v] = k diff --git a/maigret/resources/data.json b/maigret/resources/data.json index ee026fe..c197497 100644 --- a/maigret/resources/data.json +++ b/maigret/resources/data.json @@ -24135,6 +24135,24 @@ "usernameUnclaimed": "noonewouldeverusethis7", "usernameClaimed": "alex" }, + "memory.lol": { + "tags": [ + "messaging" + ], + "regexCheck": "^[a-zA-Z0-9_]{1,15}$", + "checkType": "message", + "absenceStrs": [ + "{\"accounts\":[]}" + ], + "presenseStrs": [ + "{\"accounts\":[{" + ], + "source": "Twitter", + "urlMain": "https://memory.lol", + "url": "https://api.memory.lol/v1/tw/{username}", + "usernameClaimed": "libsoftiktok", + "usernameUnclaimed": "noonewould123" + }, "metroman.3dn.ru": { "engine": "uCoz", "urlMain": "http://metroman.3dn.ru",