From 5a1d0da33ed36e1e7c1948cf1d17edbad043e73a Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sat, 14 Jan 2023 00:36:13 +0100 Subject: [PATCH] Fix anime-ultime --- pynyaata/bridge/animeultime.py | 10 +++++++--- tests/bridge/test_animeultime.py | 24 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/pynyaata/bridge/animeultime.py b/pynyaata/bridge/animeultime.py index a544be1..abb8fb3 100644 --- a/pynyaata/bridge/animeultime.py +++ b/pynyaata/bridge/animeultime.py @@ -49,6 +49,7 @@ class AnimeUltime(Bridge): torrents: List[RemoteFile] = [] html = BeautifulSoup(response.content, "html.parser") title = html.select_one("div.title") + titre = html.select_one("div.titre") history = html.select_one("h1") player = html.select_one("div.AUVideoPlayer") tables = html.select("table.jtable") @@ -93,15 +94,18 @@ class AnimeUltime(Bridge): date=parse(h3s[i].get_text()[:-3], ["%A %d %B %Y"]), ) ) - elif player and title and history and tables: + elif player and titre and history: torrents.append( RemoteFile( bridge=self.__class__.__name__, id=player["data-serie"], - category=title.get_text(), + category=titre.get_text().split("(")[0].strip(), name=history.get_text(), link=f"{self.base_url}/file-0-1/{player['data-serie']}", - date=tables[0].find_all("tr")[1].find_all("td")[1].get_text(), + date=datetime.strptime( + tables[0].find_all("tr")[1].find_all("td")[1].get_text(), + "%d/%m/%y", + ), ) ) diff --git a/tests/bridge/test_animeultime.py b/tests/bridge/test_animeultime.py index d7c3b33..7afc60e 100644 --- a/tests/bridge/test_animeultime.py +++ b/tests/bridge/test_animeultime.py @@ -148,6 +148,28 @@ async def test_history(requests_mock: Mocker): category="Film", name="Crayon Shin-chan - Arashi wo Yobu Appare! Sengoku Dai Kassen", link="http://www.anime-ultime.net/file-0-1/167/Crayon-Shin-chan---Arashi-wo-Yobu-Appare-Sengoku-Dai-Kassen-vostfr", - date="2006-04-10 00:00:00" + date="2006-04-10 00:00:00", + ), + ] + + +@mark.asyncio +async def test_search_one(requests_mock: Mocker): + requests_mock.real_http = True + requests_mock.post( + AnimeUltime().search_url("akuma"), + text=requests.get( + "http://www.anime-ultime.net/file-0-1/4631/Akuma-no-Riddle-Shousha-wa-Dare-Nukiuchi-Test-vostfr" + ).text, + ) + + assert await AnimeUltime().search("akuma") == [ + RemoteFile( + bridge="AnimeUltime", + id=4631, + category="OAV", + name="Akuma no Riddle: Shousha wa Dare? Nukiuchi Test vostfr", + link="http://www.anime-ultime.net/file-0-1/4631", + date="2014-12-27 00:00:00", ), ]