Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions user_scanner/user_scan/music/beatstars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from user_scanner.core.orchestrator import generic_validate, Result


def validate_beatstars(user):
url = "https://core.prod.beatstars.net/auth/graphql"
show_url = f"https://www.beatstars.com/{user}"

headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0',
'Accept-Language': 'en,en-US;q=0.9'
}

payload = {
'operationName': 'identifierAvailable',
'variables': {
'identifier': f'{user}',
},
'query': 'query identifierAvailable($identifier: String!) {\n identifierAvailable(identifier: $identifier) {\n ...AccountBasicInfo\n __typename\n }\n}\n\nfragment AccountBasicInfo on IsIdentifierAvailableResponse {\n available\n profileDetails {\n email\n username\n artwork {\n url\n fitInUrl\n __typename\n }\n __typename\n }\n __typename\n}',
}

def process(response):
try:
res_json = response.json()

if "errors" in res_json and res_json["errors"]:
raw_err = res_json["errors"][0].get("message", "")

if "ITEM_NOT_FOUND" in raw_err:
return Result.available("Username too short or invalid length")

if "valid email or username" in raw_err:
return Result.available("Invalid username format")

return Result.error(f"API Error: {raw_err}")

data = res_json.get("data", {})
identifier_data = data.get("identifierAvailable")

if not identifier_data:
return Result.error("Could not parse identifier data")

if identifier_data.get("available") is True:
return Result.available()

return Result.taken()

except (AttributeError, ValueError, KeyError):
return Result.error("Failed to decode server response, report it via GitHub issues")

return generic_validate(url, process, show_url=show_url, method="POST", headers=headers, json=payload)
16 changes: 16 additions & 0 deletions user_scanner/user_scan/social/vk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from user_scanner.core.orchestrator import generic_validate, Result


def validate_vk(user):
url = f"https://vk.com/{user}"
show_url = f"https://vk.com/{user}"

def process(response):
if response.status_code == 404:
return Result.available()
elif response.status_code == 200:
return Result.taken()

return Result.error("Unexpected response body, report it via GitHub issues.")

return generic_validate(url, process, show_url=show_url)
Loading