def get_category_from_topchart_url(url: str) -> str:
    """Return the category from an url.

    Throws an error if the url isn't recognized.
    """

    category = url.split("/")[3]
    # check category
    if category not in [
        "films",
        "series",
        "jeuxvideo",
        "livres",
        "bd",
        "musique",
    ]:
        raise Exception(
            "URL malformed. Check that the url contains a Senscritique Top (not a Survey)."
        )
    return category