def get_show_by_id(id):
    found_seasons = queries.get_show_seasons(id)
    if found_seasons:
        for season in found_seasons:
            season['rating'] = float(season['rating'])
        return jsonify(found_seasons)
    else:
        return jsonify("NO FOUND")
Exemplo n.º 2
0
def tv_show(show_id, season=False):
    show_details = queries.get_show_info(show_id)
    show_seasons = queries.get_show_seasons(show_id)
    if season:
        return render_template('season.html')
    else:
        return render_template('tv-show.html',
                               show_details=show_details,
                               show_seasons=show_seasons)
Exemplo n.º 3
0
def show_page(id):
    show = queries.get_show_by_id(id)
    seasons = queries.get_show_seasons(id)
    characters = queries.get_show_characters(id)
    show['characters_str'] = ', '.join(
        [character['name'] for character in characters])
    show['trailer_id'] = show['trailer'].split(
        '=')[1] if show['trailer'] else ''
    show['runtime_str'] = ''
    return render_template('show.html', show=show, seasons=seasons)
def show(id):
    show = queries.get_show(id)
    characters = queries.get_show_characters(id)
    seasons = queries.get_show_seasons(id)

    # format character names
    show['characters_str'] = \
        ', '.join([character['name'] for character in characters])

    # getting trailer id from URL to embed video
    show['trailer_id'] = \
        show['trailer'][show['trailer'].find('=') + 1:] if show['trailer'] else ''

    # format runtime
    hours, minutes = divmod(show['runtime'], 60)
    runtime_str = (str(hours) + 'h ' if hours else '') + (str(minutes) + 'min' if minutes else '')
    show['runtime_str'] = runtime_str

    return render_template('show.html', show=show, seasons=seasons)