Exemple #1
0
async def show(show_name: str):
    """ Fetch show info by show slug """
    try:
        show = get_show(show_name)
    except NoSuchShow:
        raise HTTPException(status_code=404)
    return show_model_from_show(show)
def test_finding_next_previous():
    show = get_show(SHOW_NAME)
    episode = show.get_episode("2020", "06.11.2020")
    preceding = show.get_preceding_episode(episode)
    following = show.get_following_episode(episode)

    assert preceding.prf_id == "MUHH43002920"
    assert following.prf_id == "MUHH43003120"

    last_season_two = show.get_episode("2011", "16.12.2011")
    following = show.get_following_episode(last_season_two)
    preceding = show.get_preceding_episode(following)

    assert following.prf_id == "MUHH40000112"
    assert preceding.prf_id == last_season_two.prf_id
def test_finding_next_previous():
    show = get_show(SHOW_NAME)
    episode = show.get_episode(1, 2)
    preceding = show.get_preceding_episode(episode)
    following = show.get_following_episode(episode)

    assert preceding.prf_id == "MSUB19120116"
    assert following.prf_id == "MSUB19120316"

    last_season_one = show.get_episode(1, 11)
    following = show.get_following_episode(last_season_one)
    preceding = show.get_preceding_episode(following)

    assert following.prf_id == "MYNT15000116"
    assert preceding.prf_id == last_season_one.prf_id
Exemple #4
0
async def subs(
    show_name: str, season_name: Union[str, int], episode_number: Union[str, int]
):
    """ Fetch subs for specific episode """
    try:
        show = get_show(show_name)
        current_episode = show.get_episode(season_name, episode_number)
        subs: Optional[List[str]] = current_episode.get_subs()
    except NoSuchShow:
        raise HTTPException(status_code=404, detail="No such show")
    except NoSuchSeason:
        raise HTTPException(status_code=404, detail="No such season")
    except NoSuchEpisode:
        raise HTTPException(status_code=404, detail="No such episode")
    except InvalidURL:
        subs = None
    next_episode = show.get_following_episode(current_episode)
    previous_episode = show.get_preceding_episode(current_episode)

    if next_episode is not None:
        next_model: Optional[EpisodeModel] = episode_model_from_episode(
            next_episode, show.get_season_number(next_episode)
        )
    else:
        next_model = None

    if previous_episode is not None:
        previous_model: Optional[EpisodeModel] = episode_model_from_episode(
            previous_episode, show.get_season_number(previous_episode)
        )
    else:
        previous_model = None

    return SubtitlesModel(
        episode=episode_model_from_episode(current_episode, season_name),
        next_episode=next_model,
        previous_episode=previous_model if previous_episode else None,
        subs=subs,
    )
def test_get_season_one():
    show = get_show(SHOW_NAME)
    episodes = show.get_episodes(1)
    assert len(episodes) == 11
def test_get_first_episode_of_show():
    show = get_show(SHOW_NAME)
    episode = show.get_episode(1, 1)
    assert episode.episode_number == 1
def test_get_all_seasons():
    show = get_show(SHOW_NAME)
    seasons = show.get_available_seasons()
    assert len(seasons) == 4
def test_finding_season_title():
    show = get_show(SHOW_NAME)
    season_title = show.get_season_title("2020")
    assert season_title == "2020"
def test_get_season_one():
    show = get_show(SHOW_NAME)
    episodes = show.get_episodes("2020")
    # Always 10 per page
    assert len(episodes) == 10
def test_get_more_loaded_season():
    """ Aparently not necessary but if this fails it means they added pagination to single seasons """
    show = get_show(SHOW_NAME)
    episode = show.get_episode("2016", "08.01.2016")
    assert episode is not None
    assert episode.episode_number == "08.01.2016"
def test_get_first_episode_of_show():
    show = get_show(SHOW_NAME)
    episode = show.get_episode("1999", "09.04.1999")
    assert episode is not None
def test_get_known_episode_of_show():
    show = get_show(SHOW_NAME)
    episode = show.get_episode("2020", "13.11.2020")
    assert episode.episode_number == "13.11.2020"