|
|
@ -123,9 +123,12 @@ class Trakt:
|
|
|
|
logger.info(f"Navigate to: {url}")
|
|
|
|
logger.info(f"Navigate to: {url}")
|
|
|
|
logger.info("If you get an OAuth error your client_id or client_secret is invalid")
|
|
|
|
logger.info("If you get an OAuth error your client_id or client_secret is invalid")
|
|
|
|
webbrowser.open(url, new=2)
|
|
|
|
webbrowser.open(url, new=2)
|
|
|
|
try: pin = util.logger_input("Trakt pin (case insensitive)", timeout=300).strip()
|
|
|
|
try:
|
|
|
|
except TimeoutExpired: raise Failed("Input Timeout: Trakt pin required.")
|
|
|
|
pin = util.logger_input("Trakt pin (case insensitive)", timeout=300).strip()
|
|
|
|
if not pin: raise Failed("Trakt Error: Trakt pin required.")
|
|
|
|
except TimeoutExpired:
|
|
|
|
|
|
|
|
raise Failed("Input Timeout: Trakt pin required.")
|
|
|
|
|
|
|
|
if not pin:
|
|
|
|
|
|
|
|
raise Failed("Trakt Error: Trakt pin required.")
|
|
|
|
json = {
|
|
|
|
json = {
|
|
|
|
"code": pin,
|
|
|
|
"code": pin,
|
|
|
|
"client_id": self.client_id,
|
|
|
|
"client_id": self.client_id,
|
|
|
@ -135,7 +138,8 @@ class Trakt:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response = self.config.post(f"{base_url}/oauth/token", json=json, headers={"Content-Type": "application/json"})
|
|
|
|
response = self.config.post(f"{base_url}/oauth/token", json=json, headers={"Content-Type": "application/json"})
|
|
|
|
if response.status_code != 200:
|
|
|
|
if response.status_code != 200:
|
|
|
|
raise Failed("Trakt Error: Invalid trakt pin. If you're sure you typed it in correctly your client_id or client_secret may be invalid")
|
|
|
|
raise Failed(f"Trakt Error: ({response.status_code}) {response.reason}")
|
|
|
|
|
|
|
|
#raise Failed("Trakt Error: Invalid trakt pin. If you're sure you typed it in correctly your client_id or client_secret may be invalid")
|
|
|
|
elif not self._save(response.json()):
|
|
|
|
elif not self._save(response.json()):
|
|
|
|
raise Failed("Trakt Error: New Authorization Failed")
|
|
|
|
raise Failed("Trakt Error: New Authorization Failed")
|
|
|
|
|
|
|
|
|
|
|
@ -151,10 +155,8 @@ class Trakt:
|
|
|
|
response = self.config.get(f"{base_url}/users/settings", headers=headers)
|
|
|
|
response = self.config.get(f"{base_url}/users/settings", headers=headers)
|
|
|
|
if response.status_code == 423:
|
|
|
|
if response.status_code == 423:
|
|
|
|
raise Failed("Trakt Error: Account is Locked please Contact Trakt Support")
|
|
|
|
raise Failed("Trakt Error: Account is Locked please Contact Trakt Support")
|
|
|
|
if self.config.trace_mode:
|
|
|
|
if response.status_code != 200:
|
|
|
|
logger.debug(f"Trakt Error Code: {response.status_code}")
|
|
|
|
logger.debug(f"Trakt Error: ({response.status_code}) {response.reason}")
|
|
|
|
logger.debug(f"Trakt Error Reason: {response.reason}")
|
|
|
|
|
|
|
|
logger.debug(f"Trakt Error JSON: {response.json()}")
|
|
|
|
|
|
|
|
return response.status_code == 200
|
|
|
|
return response.status_code == 200
|
|
|
|
|
|
|
|
|
|
|
|
def _refresh(self):
|
|
|
|
def _refresh(self):
|
|
|
|