Exemple #1
0
    def merge_episode(episode_info):

        # Split the name
        path, info = episode_info
        show_name = info['series'].lower()
        parsed_season = info['season']
        parsed_episode = info['episodeNumber']

        try:
            show = Show.get(Show.name == show_name)
        except DoesNotExist:
            # Show does not exist yet
            show = Show.create(name=show_name)
            season = Season.create(show=show, season_number=parsed_season)
            Episode.create(season=season, episode_number=parsed_episode, path=path, added_time=datetime.datetime.now())
            print('Merged "' + show.name + '" season ' + str(parsed_season) + ' episode ' + str(parsed_episode))
        else:
            try:
                season = Season.get(Season.show == show, Season.season_number == parsed_season)
            except DoesNotExist:
                # Season did not exist yet
                season = Season.create(show=show, season_number=parsed_season)
                Episode.create(season=season, episode_number=parsed_episode, path=path,
                               added_time=datetime.datetime.now())
                print('Merged "' + show.name + '" season ' + str(parsed_season) + ' episode ' + str(parsed_episode))
            else:
                try:
                    Episode.get(Episode.season == season, Episode.episode_number == parsed_episode)
                except DoesNotExist:
                    Episode.create(season=season, episode_number=parsed_episode, path=path,
                                   added_time=datetime.datetime.now())
                    print('Merged "' + show.name + '" season ' + str(parsed_season) + ' episode ' + str(parsed_episode))
Exemple #2
0
def create_show_submission():
    """
  Called to create new shows in the db, upon submitting new show listing form
  """

    try:
        request.get_data()
        show_dict = request.form.to_dict()
        show = Show(venue_id=show_dict["venue_id"],
                    artist_id=show_dict["artist_id"],
                    start_time=show_dict["start_time"])
        show.create()
        flash('Show was successfully listed!')
        return render_template('pages/home.html')
    except Exception as e:
        print("Error in creating new show: ", e)
        print(traceback.format_exc())
        flash('An error occurred. Show could not be listed.')
        abort(500)