From aec8b717fc8a992b916cfe46e210d11939d22b38 Mon Sep 17 00:00:00 2001 From: iojw Date: Tue, 7 Jul 2020 17:41:46 +0800 Subject: [PATCH] Fix wrong results for Spotify email queries - Bump version to 1.2.1 --- socialscan/__init__.py | 2 +- socialscan/platforms.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/socialscan/__init__.py b/socialscan/__init__.py index c68196d..a955fda 100644 --- a/socialscan/__init__.py +++ b/socialscan/__init__.py @@ -1 +1 @@ -__version__ = "1.2.0" +__version__ = "1.2.1" diff --git a/socialscan/platforms.py b/socialscan/platforms.py index a5e03ed..004fbcf 100644 --- a/socialscan/platforms.py +++ b/socialscan/platforms.py @@ -582,21 +582,17 @@ async def check_username(self, username): class Spotify(PlatformChecker): URL = "https://www.spotify.com/signup/" - EMAIL_ENDPOINT = "https://www.spotify.com/sg-en/xhr/json/isEmailAvailable.php" + EMAIL_ENDPOINT = "https://spclient.wg.spotify.com/signup/public/v1/account" async def check_email(self, email): - async with self.get( - Spotify.EMAIL_ENDPOINT, params={"signup_form[email]": email, "email": email} - ) as r: - text = await r.text() - if text == "true": + async with self.get(Spotify.EMAIL_ENDPOINT, params={"validate": 1, "email": email}) as r: + json_body = await self.get_json(r) + if json_body["status"] == 1: return self.response_available(email) - elif text == "false": - return self.response_unavailable(email) + elif json_body["status"] == 20: + return self.response_unavailable(email, message=json_body["errors"]["email"]) else: - return self.response_failure( - email, message=PlatformChecker.TOO_MANY_REQUEST_ERROR_MESSAGE - ) + return self.response_failure(email, message=json_body["errors"]["email"]) class Yahoo(PlatformChecker):