Skip to content

Commit

Permalink
Merge pull request #13 from ginop-1/master
Browse files Browse the repository at this point in the history
cambiamento dell'attributo "release" da datetime a stringa
  • Loading branch information
MainKronos authored Aug 15, 2023
2 parents 471bb93 + 825e0cc commit 676a963
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
15 changes: 2 additions & 13 deletions animeworld/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
from typing import *
import re

from datetime import datetime
import time
import locale

from .exceptions import DeprecatedLibrary

class MySession(httpx.Client):
Expand Down Expand Up @@ -88,7 +84,7 @@ def find(keyword: str) -> List[Dict]:
"name": str, # Nome dell'anime
"jtitle": str, # Nome giapponese (con caratteri latini)
"studio": str, # Studio dell'anime
"release": datetime, # Giorno, Mese e Anno della release dell'anime
"release": str | None, # Giorno, Mese e Anno della release dell'anime. Se non disponibile ("??" al posto della data), ritorna None.
"episodes": int, # Numero di episodi
"state": str, # Es. "0", "1", ...
"story": str, # Trama dell'anime
Expand All @@ -115,11 +111,6 @@ def find(keyword: str) -> List[Dict]:
```
"""

try:
locale.setlocale(locale.LC_TIME, "it_IT.UTF-8")
except locale.Error:
pass

res = SES.post("https://www.animeworld.so/api/search/v2?", params = {"keyword": keyword}, follow_redirects=True)

data = res.json()
Expand All @@ -130,8 +121,6 @@ def find(keyword: str) -> List[Dict]:
for k in elem:
if elem[k] == "??":
elem[k] = None
if elem["release"] and elem["release"].find("??") != -1:
elem["release"] = elem["release"].replace("??", "1")

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

Expand All @@ -141,7 +130,7 @@ def find(keyword: str) -> List[Dict]:
"name": elem["name"],
"jtitle": elem["jtitle"],
"studio": elem["studio"],
"release": datetime.strptime(elem["release"], "%d %B %Y") if elem["release"] is not None else None,
"release": elem["release"],
"episodes": int(elem["episodes"]) if elem["episodes"] is not None else None,
"state": elem["state"],
"story": elem["story"],
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ print(res)
"name": "Sword Art Online",
"jtitle": "Sword Art Online",
"studio": "A-1 Pictures",
"release": datetime.datetime(2012, 7, 8, 0, 0),
"release": "05 Luglio 2014",
"episodes": 25,
"state": "1",
"story": 'Kazuto "Kirito" Kirigaya, un genio della programmazione, entra in una realtà virtuale interattiva con pluralità di giocatori (una realtà "massively multi-player online" o "MMO") denominata "Sword Art Online". Il problema sta nel fatto che, una volta entrati, se ne può uscire solo vincitori, completando il gioco, perché il game over equivale a morte certa del giocatore.',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_animeworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_ServerNotSupported(self) -> None:
"""
Testa il corretto riconoscimento di un server non supportato.
"""
ep = random.choice(aw.Anime("https://www.animeworld.so/play/fullmetal-alchemist-brotherhood.Ihtnf").getEpisodes())
ep = random.choice(aw.Anime("https://www.animeworld.so/play/fullmetal-alchemist-brotherhood.4vGGQ").getEpisodes())

server = [s for s in ep.links if s.Nid == 2][0]

Expand All @@ -81,7 +81,7 @@ class TestAnimeWorld(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
"""Inizializza la classe Anime."""
cls.anime = aw.Anime("https://www.animeworld.so/play/fullmetal-alchemist-brotherhood.Ihtnf")
cls.anime = aw.Anime("https://www.animeworld.so/play/fullmetal-alchemist-brotherhood.4vGGQ")

def test_anime(self):
"""
Expand Down

0 comments on commit 676a963

Please sign in to comment.