示例#1
0
def view_show(show):
    log_event(request, "ViewShow")
    add_epguides_key_to_redis(show)
    try:
        return json_response(get_show_by_key(show).get_show_data())
    except EpisodeNotFoundException:
        return json_response({'error': 'Show not found'}, 404)
    except SeasonNotFoundException:
        return json_response({'error': 'Season not found'}, 404)
示例#2
0
def last(show):
    log_event(request, "ViewShowLastEpisode")
    add_epguides_key_to_redis(show)
    try:
        return json_response({'episode': get_show_by_key(show).last_episode()})
    except EpisodeNotFoundException:
        return json_response({'error': 'Show not found'}, 404)
    except SeasonNotFoundException:
        return json_response({'error': 'Season not found'}, 404)
示例#3
0
def next_from_given_episode(show, season, episode):
    log_event(request, "ViewNextFromGivenEpisode")
    add_epguides_key_to_redis(show)
    try:
        show = get_show_by_key(show)
        return json_response(
            {'episode': show.get_episode(int(season), int(episode)).next()})
    except EpisodeNotFoundException:
        return json_response({'error': 'Show not found'}, 404)
    except SeasonNotFoundException:
        return json_response({'error': 'Season not found'}, 404)
示例#4
0
def released(show, season, episode):
    log_event(request, "ViewReleased")
    add_epguides_key_to_redis(show)
    try:
        show = get_show_by_key(show)
        return json_response(
            {'status': show.episode_released(int(season), int(episode))})
    except EpisodeNotFoundException:
        return json_response({'error': 'Show not found'}, 404)
    except SeasonNotFoundException:
        return json_response({'error': 'Season not found'}, 404)
示例#5
0
def episode(show, season, episode):
    log_event(request, "ViewEpisode")
    add_epguides_key_to_redis(show)
    try:
        return json_response({
            'episode':
            get_show_by_key(show).get_episode(int(season), int(episode))
        })
    except EpisodeNotFoundException:
        return json_response({'error': 'Show not found'}, 404)
    except SeasonNotFoundException:
        return json_response({'error': 'Season not found'}, 404)
示例#6
0
def next_released_from_given_episode(show, season, episode):
    log_event(request, "ViewNextReleasedFromGivenEpisode")
    add_epguides_key_to_redis(show)
    try:
        show = get_show_by_key(show)
        next_episode = show.get_episode(season, episode).next()
        if not next_episode:
            raise EpisodeNotFoundException
        return json_response({'status': next_episode.released()})
    except EpisodeNotFoundException:
        return json_response({'error': 'Show not found'}, 404)
    except SeasonNotFoundException:
        return json_response({'error': 'Season not found'}, 404)
示例#7
0
    def test_all_episodes_included_in_show_data(self):
        show_keys = [
            "greysanatomy", "bigbangtheory", "howimetyourmother",
            "lastweektonightwithjohnoliver", "vampirediaries", "chuck",
            "originals", "gameofthrones", "modernfamily"
        ]

        for show_key in show_keys:
            show = models.get_show_by_key(show_key)
            current_season = 1
            for season_key in show.seasons_keys():
                self.assertEqual(current_season, int(season_key))
                current_episode = 1
                for episode in show.season_episodes(season_key):
                    if episode.number == 0:
                        continue
                    self.assertEqual(current_episode, int(episode.number))
                    current_episode += 1
                current_season += 1
示例#8
0
    def test_all_episodes_included_in_show_data(self):
        show_keys = [
            "greysanatomy", "bigbangtheory", "howimetyourmother",
            "lastweektonightwithjohnoliver", "vampirediaries",
            "chuck", "originals", "gameofthrones", "modernfamily"
        ]

        for show_key in show_keys:
            show = models.get_show_by_key(show_key)
            current_season = 1
            for season_key in show.seasons_keys():
                self.assertEqual(current_season, int(season_key))
                current_episode = 1
                for episode in show.season_episodes(season_key):
                    if episode.number == 0:
                        continue
                    self.assertEqual(current_episode, int(episode.number))
                    current_episode += 1
                current_season += 1