fix: use constant now that authenticate is in Auditui class
This commit is contained in:
12
main.py
12
main.py
@@ -6,7 +6,6 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -685,12 +684,11 @@ class Auditui(App):
|
|||||||
|
|
||||||
def authenticate(self) -> None:
|
def authenticate(self) -> None:
|
||||||
"""Authenticate with Audible and set auth and client objects."""
|
"""Authenticate with Audible and set auth and client objects."""
|
||||||
auth_path = Path.home() / ".config" / "auditui" / "auth.json"
|
self.AUTH_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||||
auth_path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
if auth_path.exists():
|
if self.AUTH_PATH.exists():
|
||||||
try:
|
try:
|
||||||
authenticator = audible.Authenticator.from_file(str(auth_path))
|
authenticator = audible.Authenticator.from_file(str(self.AUTH_PATH))
|
||||||
audible_client = audible.Client(auth=authenticator)
|
audible_client = audible.Client(auth=authenticator)
|
||||||
self.auth = authenticator
|
self.auth = authenticator
|
||||||
self.client = audible_client
|
self.client = audible_client
|
||||||
@@ -715,8 +713,8 @@ class Auditui(App):
|
|||||||
username=email, password=password, locale=marketplace
|
username=email, password=password, locale=marketplace
|
||||||
)
|
)
|
||||||
|
|
||||||
auth_path.parent.mkdir(parents=True, exist_ok=True)
|
self.AUTH_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||||
authenticator.to_file(str(auth_path))
|
authenticator.to_file(str(self.AUTH_PATH))
|
||||||
print("Authentication successful!")
|
print("Authentication successful!")
|
||||||
audible_client = audible.Client(auth=authenticator)
|
audible_client = audible.Client(auth=authenticator)
|
||||||
self.auth = authenticator
|
self.auth = authenticator
|
||||||
|
|||||||
Reference in New Issue
Block a user