Skip to content

Commit

Permalink
Added memory.lol (Twitter usernames archive) (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
soxoj authored Jul 24, 2023
1 parent 656b9c1 commit f5ca005
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
11 changes: 10 additions & 1 deletion maigret/checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
except ImportError:
from unittest.mock import Mock

import ast
import re
import ssl
import sys
Expand Down Expand Up @@ -374,8 +375,16 @@ def build_result(status, **kwargs):
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

Expand Down
12 changes: 11 additions & 1 deletion maigret/maigret.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Maigret main module
"""
import ast
import asyncio
import logging
import os
Expand Down Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions maigret/resources/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f5ca005

Please sign in to comment.