Skip to content

Commit d0cd53b

Browse files
committed
fixed errors when content is null
1 parent 3aabd64 commit d0cd53b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

nlightreader/parsers/Shikimori.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,18 @@ def search_manga(self, req_params: RequestForm):
174174
lib_list = "rewatching"
175175
else:
176176
lib_list = req_params.lib_list.name
177-
if response:
178-
for i in response.json():
177+
if response and (resp_json := response.json()):
178+
for i in resp_json:
179179
if not i.get("status") == lib_list:
180180
continue
181181
i = i.get("manga")
182182
mangas.append(self.setup_manga(i))
183183
return mangas
184184

185185
def get_user(self):
186-
whoami = self.session.request("GET", f"{self.url_api}/users/whoami")
187-
if whoami and whoami.status_code == 200:
188-
data = whoami.json()
186+
response = self.session.request("GET", f"{self.url_api}/users/whoami")
187+
if response and (resp_json := response.json()):
188+
data = resp_json
189189
return User(data.get("id"), data.get("nickname"), data.get("avatar"))
190190
return User(None, None, None)
191191

@@ -207,9 +207,9 @@ def check_user_rate(self, manga: Manga):
207207
"user_id": self.get_user().id,
208208
"target_id": manga.content_id,
209209
}
210-
html = self.session.request("GET", url, params=params)
211-
if html and html.status_code == 200 and html.json():
212-
for i in html.json():
210+
response = self.session.request("GET", url, params=params)
211+
if response and (resp_json := response.json()):
212+
for i in resp_json:
213213
if manga.content_id == i.get("target_id"):
214214
return True
215215
return False
@@ -225,9 +225,9 @@ def get_user_rate(self, manga: Manga):
225225
"user_id": self.get_user().id,
226226
"target_id": manga.content_id,
227227
}
228-
html = self.session.request("GET", url, params=params)
229-
if html and html.status_code == 200 and html.json():
230-
for i in html.json():
228+
response = self.session.request("GET", url, params=params)
229+
if response and (resp_json := response.json()):
230+
for i in resp_json:
231231
return UserRate(i.get("id"), i.get("user_id"), i.get("target_id"),
232232
i.get("score"), i.get("status"), i.get("chapters"))
233233

0 commit comments

Comments
 (0)