Skip to content

Commit

Permalink
updated some code in parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonzorn committed Aug 8, 2024
1 parent 18569a1 commit f975241
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions nlightreader/parsers/combined/shikimori/shikimori_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def update_user_rate(self, user_rate: UserRate):

@singleton
class Auth:
def __init__(self, token=None, scope=None):
def __init__(self):
self.client_id = SHIKIMORI_CLIENT_ID
self.client_secret = SHIKIMORI_CLIENT_SECRET
self.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
Expand All @@ -146,7 +146,7 @@ def __init__(self, token=None, scope=None):
self.headers = SHIKIMORI_HEADERS | {
"Authorization": f"Bearer {self.tokens.get('access_token')}",
}
self.client = self.get_client(scope, self.redirect_uri, token)
self.client = self.get_client("user_rates", self.redirect_uri, None)
self.refresh_token()
self.user: User = User(None, None, None)
self.is_authorized = False
Expand All @@ -157,7 +157,7 @@ def auth_login(self, params):
self.fetch_token(params["token"])
self.check_auth()

def get_client(self, scope, redirect_uri, token):
def get_client(self, scope, redirect_uri, token: dict | None):
client = OAuth2Session(
self.client_id,
auto_refresh_url=URL_SHIKIMORI_TOKEN,
Expand Down
4 changes: 3 additions & 1 deletion nlightreader/parsers/hentai_manga/allhentai_hmanga.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def search_manga(self, form):
manga_id = base_info.get("href")
name = base_info.get("title")
if manga_id and name:
mangas.append(Manga(manga_id, self.CATALOG_ID, name, ""))
mangas.append(
Manga(manga_id, self.CATALOG_ID, name, ""),
)
return mangas

def get_chapters(self, manga: Manga):
Expand Down
10 changes: 7 additions & 3 deletions nlightreader/parsers/manga/mangadex_manga.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,14 @@ def get_preview(self, manga: Manga):

def get_genres(self):
url = f"{self.url_api}/manga/tag"
html = get_html(url, headers=self.headers)
response = get_html(
url,
headers=self.headers,
content_type="json",
)
genres = []
if html and html.status_code == 200 and html.json():
for i in html.json().get("data"):
if response:
for i in response.get("data"):
if i.get("attributes").get("group") not in ["genre", "theme"]:
continue
genres.append(
Expand Down

0 comments on commit f975241

Please sign in to comment.