diff --git a/mandown/sources/source_mangadex.py b/mandown/sources/source_mangadex.py index e49fc0a..fbebfda 100644 --- a/mandown/sources/source_mangadex.py +++ b/mandown/sources/source_mangadex.py @@ -51,6 +51,9 @@ def fetch_metadata(self) -> BaseMetadata: if metadata["attributes"]["description"]: description: str = metadata["attributes"]["description"][self.lang_code] + + # strip trailing spaces on each line + description = "\n".join(s.strip() for s in description.split("\n")) else: description = "" @@ -68,7 +71,8 @@ def fetch_metadata(self) -> BaseMetadata: genres: list[str] = [] for d in metadata["attributes"]["tags"]: - if d["attributes"]["group"] == "genre": + tag = d["attributes"]["group"] + if tag == "genre" or tag == "theme": genres.append(d["attributes"]["name"][self.lang_code]) return BaseMetadata( diff --git a/tests/test_source_mangadex.py b/tests/test_source_mangadex.py index 7c1cb85..9575059 100644 --- a/tests/test_source_mangadex.py +++ b/tests/test_source_mangadex.py @@ -2,23 +2,27 @@ import mandown -URL = "https://mangadex.org/title/a3d681d7-a239-45a9-8446-5bfc61ca48fa" -COVER_URL = "https://uploads.mangadex.org/covers/a3d681d7-a239-45a9-8446-5bfc61ca48fa/f6c8523e-cc60-410a-8709-99fd3020c6e3.jpg" -DESCRIPTION = "Satoshi, a 16-year-old first year high school student just got a part time job as a housekeeper for a mansion surrounded by roses. A girl called Shizu lives there, who appears innocent and pure but lives haphazardly. However, there seems to be a mystery surrounding her: who is the other girl that looks at Satoshi with a cold blank stare?" +URL = "https://mangadex.org/title/37f5cce0-8070-4ada-96e5-fa24b1bd4ff9" +COVER_URL = "https://uploads.mangadex.org/covers/37f5cce0-8070-4ada-96e5-fa24b1bd4ff9/6bfc8f2a-7510-4746-90d6-b97d01c20796.jpg" +DESCRIPTION = """All’s fair when love is war! + +Two geniuses. Two brains. Two hearts. One battle. Who will confess their love first…?! + +Kaguya Shinomiya and Miyuki Shirogane are two geniuses who stand atop their prestigious academy’s student council, making them the elite among elite. But it’s lonely at the top and each has fallen for the other. There’s just one huge problem standing in the way of lovey-dovey bliss—they’re both too prideful to be the first to confess their romantic feelings and thus become the “loser” in the competition of love! And so begins their daily schemes to force the other to confess first!""" @skip_in_ci -def test_ibarahime() -> None: +def test_kaguya_mangadex() -> None: comic = mandown.query(URL) expected_res = { - "title": "Good Morning, Sleeping Beauty", - "authors": ["Megumi Morino"], + "title": "Kaguya-sama: Love is War", + "authors": ["Akasaka Aka"], "genres": [ - "Psychological", "Romance", "Comedy", "Drama", + "School Life", "Slice of Life", ], "description": DESCRIPTION, @@ -28,3 +32,6 @@ def test_ibarahime() -> None: assert comic.metadata.asdict() == expected_res assert comic.chapters + + first_chapter = comic.get_chapter_image_urls(comic.chapters[0]) + assert first_chapter diff --git a/tests/test_source_manganato.py b/tests/test_source_manganato.py index 76740ae..ed6f531 100644 --- a/tests/test_source_manganato.py +++ b/tests/test_source_manganato.py @@ -29,3 +29,6 @@ def test_punpun() -> None: assert comic.metadata.asdict() == expected_res assert comic.chapters + + first_chapter = comic.get_chapter_image_urls(comic.chapters[0]) + assert first_chapter diff --git a/tests/test_source_mangasee.py b/tests/test_source_mangasee.py index 5ba50fa..08f3fbb 100644 --- a/tests/test_source_mangasee.py +++ b/tests/test_source_mangasee.py @@ -29,3 +29,6 @@ def test_kaguya() -> None: assert comic.metadata.asdict() == expected_res assert comic.chapters + + first_chapter = comic.get_chapter_image_urls(comic.chapters[0]) + assert first_chapter diff --git a/tests/test_source_manhuaes.py b/tests/test_source_manhuaes.py index 5064c00..b0d8d69 100644 --- a/tests/test_source_manhuaes.py +++ b/tests/test_source_manhuaes.py @@ -22,3 +22,6 @@ def test_undefeatable() -> None: assert comic.metadata.asdict() == expected_res assert comic.chapters + + first_chapter = comic.get_chapter_image_urls(comic.chapters[0]) + assert first_chapter diff --git a/tests/test_source_readcomiconline.py b/tests/test_source_readcomiconline.py index 48d4170..1456f0a 100644 --- a/tests/test_source_readcomiconline.py +++ b/tests/test_source_readcomiconline.py @@ -22,3 +22,6 @@ def test_behemoth() -> None: assert comic.metadata.asdict() == expected_res assert comic.chapters + + first_chapter = comic.get_chapter_image_urls(comic.chapters[0]) + assert first_chapter diff --git a/tests/test_source_webtoons.py b/tests/test_source_webtoons.py index 0d8afb7..6fe9242 100644 --- a/tests/test_source_webtoons.py +++ b/tests/test_source_webtoons.py @@ -42,3 +42,7 @@ def test_reyn() -> None: } assert comic.metadata.asdict() == expected_res + assert comic.chapters + + first_chapter = comic.get_chapter_image_urls(comic.chapters[0]) + assert first_chapter