Skip to content

Commit 3d86dec

Browse files
committed
fix
1 parent ec814c2 commit 3d86dec

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

animeworld/anime.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ def __getHTML(self) -> httpx.Response:
4646
```
4747
"""
4848
r = None
49+
retry = 0
4950
while True:
5051
try:
5152
r = SES.get(self.link, timeout=(3, 27), follow_redirects=True)
5253

53-
# if len(list(filter(re.compile(r'30[^2]').search, [str(x.status_code) for x in r.history]))): # se c'è un redirect strano
54-
# continue
55-
56-
except httpx.ReadTimeout:
57-
time.sleep(1) # errore
54+
except httpx.ReadTimeout as e:
55+
if retry <= 2:
56+
retry +=1
57+
time.sleep(1) # errore
58+
else:
59+
raise e
5860

5961
else:
6062
break

animeworld/utility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self) -> None:
2323
self.fixCookie()
2424

2525
def fixCookie(self):
26+
"""Aggiunge il csrf_token all'headers."""
2627

2728
res = self.get("https://www.animeworld.so", follow_redirects=True)
2829
csrf_token = re.compile(br'<meta.*?id="csrf-token"\s*?content="(.*?)">')
@@ -110,7 +111,6 @@ def find(keyword: str) -> List[Dict]:
110111

111112
data.sort(key=lambda a: a["dub"])
112113

113-
114114
return [
115115
{
116116
"id": elem["id"],

0 commit comments

Comments
 (0)