~nhanb/pytaku

2300766f50b1f6fe993b13352b40bc622d694a34 — Bùi Thành Nhân 19 days ago 67d3b85
fix mangadex get_chapter

They moved chapter data (hash, file names) from the normal `chapter` API
to the `at-home` one for some reason.
1 files changed, 9 insertions(+), 10 deletions(-)

M src/mangoapi/mangadex.py
M src/mangoapi/mangadex.py => src/mangoapi/mangadex.py +9 -10
@@ 102,14 102,17 @@ class Mangadex(Site):
            if rel["type"] == "manga":
                title_id = rel["id"]
                break

        chapter_hash = data["attributes"]["hash"]
        filenames = data["attributes"]["data"]
        # chapter_hash = data["attributes"]["hash"]
        # filenames = data["attributes"]["data"]
        md_server = "https://uploads.mangadex.org"

        mdah_server = self._get_md_at_home_server(chapter_id)
        if mdah_server != md_server:
            print(">> MDAH-server:", mdah_server)
        mdah_api_url = f"https://api.mangadex.org/at-home/server/{chapter_id}"
        mdah_resp = self.http_get(mdah_api_url)
        assert mdah_resp.status_code == 200, f"Failed request to {mdah_api_url}"
        mdah_data = mdah_resp.json()
        mdah_server = mdah_data["baseUrl"]
        chapter_hash = mdah_data["chapter"]["hash"]
        filenames = mdah_data["chapter"]["data"]

        chapter = {
            "id": chapter_id,


@@ 130,10 133,6 @@ class Mangadex(Site):
        }
        return chapter

    def _get_md_at_home_server(self, chapter_id):
        resp = self.http_get(f"https://api.mangadex.org/at-home/server/{chapter_id}")
        return resp.json()["baseUrl"] if resp.status_code == 200 else None

    def search_title(self, query):
        params = {
            "limit": 100,