Skip to content

Commit f975241

Browse files
committed
updated some code in parsers
1 parent 18569a1 commit f975241

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

nlightreader/parsers/combined/shikimori/shikimori_lib.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def update_user_rate(self, user_rate: UserRate):
134134

135135
@singleton
136136
class Auth:
137-
def __init__(self, token=None, scope=None):
137+
def __init__(self):
138138
self.client_id = SHIKIMORI_CLIENT_ID
139139
self.client_secret = SHIKIMORI_CLIENT_SECRET
140140
self.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
@@ -146,7 +146,7 @@ def __init__(self, token=None, scope=None):
146146
self.headers = SHIKIMORI_HEADERS | {
147147
"Authorization": f"Bearer {self.tokens.get('access_token')}",
148148
}
149-
self.client = self.get_client(scope, self.redirect_uri, token)
149+
self.client = self.get_client("user_rates", self.redirect_uri, None)
150150
self.refresh_token()
151151
self.user: User = User(None, None, None)
152152
self.is_authorized = False
@@ -157,7 +157,7 @@ def auth_login(self, params):
157157
self.fetch_token(params["token"])
158158
self.check_auth()
159159

160-
def get_client(self, scope, redirect_uri, token):
160+
def get_client(self, scope, redirect_uri, token: dict | None):
161161
client = OAuth2Session(
162162
self.client_id,
163163
auto_refresh_url=URL_SHIKIMORI_TOKEN,

nlightreader/parsers/hentai_manga/allhentai_hmanga.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def search_manga(self, form):
3636
manga_id = base_info.get("href")
3737
name = base_info.get("title")
3838
if manga_id and name:
39-
mangas.append(Manga(manga_id, self.CATALOG_ID, name, ""))
39+
mangas.append(
40+
Manga(manga_id, self.CATALOG_ID, name, ""),
41+
)
4042
return mangas
4143

4244
def get_chapters(self, manga: Manga):

nlightreader/parsers/manga/mangadex_manga.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,14 @@ def get_preview(self, manga: Manga):
187187

188188
def get_genres(self):
189189
url = f"{self.url_api}/manga/tag"
190-
html = get_html(url, headers=self.headers)
190+
response = get_html(
191+
url,
192+
headers=self.headers,
193+
content_type="json",
194+
)
191195
genres = []
192-
if html and html.status_code == 200 and html.json():
193-
for i in html.json().get("data"):
196+
if response:
197+
for i in response.get("data"):
194198
if i.get("attributes").get("group") not in ["genre", "theme"]:
195199
continue
196200
genres.append(

0 commit comments

Comments
 (0)