~nhanb/pytaku

1bba6d466ae6eda679504708750bccbd35093bb0 — Bùi Thành Nhân 3 years ago 8bd5aee
fix mangadex cover link

It may not always have a `?` now.
2 files changed, 9 insertions(+), 1 deletions(-)

M src/mangoapi/mangadex.py
M tests/mangoapi/test_mangadex.py
M src/mangoapi/mangadex.py => src/mangoapi/mangadex.py +4 -1
@@ 27,7 27,10 @@ class Mangadex(Site):
        groups_dict = {group["id"]: group["name"] for group in groups}

        cover = manga["mainCover"].split("/")[-1]
        cover_ext = cover[cover.find(".") + 1 : cover.rfind("?")]
        ext_start_index = cover.find(".") + 1
        url_params_index = cover.rfind("?")
        ext_end_index = url_params_index if url_params_index != -1 else None
        cover_ext = cover[ext_start_index:ext_end_index]

        current_timestamp = time.time()


M tests/mangoapi/test_mangadex.py => tests/mangoapi/test_mangadex.py +5 -0
@@ 88,6 88,11 @@ def test_get_title_webtoon():
    assert title["is_webtoon"] is True


def test_get_title_no_url_params():
    title = Mangadex().get_title("23801")
    assert title["cover_ext"] == "jpg"


def test_get_chapter():
    chap = Mangadex().get_chapter("doesn't matter", "696882")
    pages = chap.pop("pages")