Пример #1
0
def list_podcasts():
    """
    Lists all the podcasts in your media server
    Can do this without a login
    """
    # # Check if the user is logged in, if not: back to login.
    # if('logged_in' not in session or not session['logged_in']):
    #     return redirect(url_for('login'))
    global allmovies
    global alltvshows
    page['title'] = 'List podcasts'

    # Get a list of all podcasts from the database
    allpodcasts = None
    allpodcasts = database.get_allpodcasts()

    # Data integrity checks
    if allpodcasts == None:
        allpodcasts = []

    # Data integrity checks
    if allmovies == None:
        allmovies = []
    
    if alltvshows == None:
        alltvshows == []

    return render_template('listitems/listpodcasts.html',
                           session=session,
                           page=page,
                           user=user_details,
                           allpodcasts=allpodcasts,
                           allmovies = allmovies,
                           alltvshows=alltvshows)
Пример #2
0
def search_all():
    """
    Extension: power search autocomplete
    """
    data = []
    movies = database.get_allmovies()
    songs = database.get_allsongs()
    artists = database.get_allartists()
    genre = database.get_all_genre()
    podcasts = database.get_allpodcasts()
    tvshows = database.get_alltvshows()

    for instance in movies:
        data.append(instance['movie_title'])

    for instance in songs:
        data.append(instance['song_title'])

    for instance in artists:
        data.append(instance['artist_name'])

    for instance in genre:
        data.append(instance['md_value'])

    for instance in podcasts:
        data.append(instance['podcast_title'])

    for instance in tvshows:
        data.append(instance['tvshow_title'])

    return json.dumps(data, encoding='utf-8')
Пример #3
0
def add_podcast():
    """
    Add a new podcast
    """
    # # Check if the user is logged in, if not: back to login.
    if ('logged_in' not in session or not session['logged_in']):
        return redirect(url_for('login'))

    page['title'] = 'Podcast Creation'
    if bool(database.is_superuser([user_details['username']])) == False:
        flash("You do not have access to this feature.")
        allpodcasts = database.get_allpodcasts()
        return render_template('listitems/listpodcasts.html',
                               session=session,
                               page=page,
                               user=user_details,
                               allpodcasts=allpodcasts)
    else:

        podcasts = None
        print("request form is:")
        newdict = {}
        print(request.form)

        if (database.is_superuser(user_details['username'])):
            page['bar'] = False
            flash("You do not have access to this feature.")

        # Check your incoming parameters
        if (request.method == 'POST'):
            #print (database.is_superuser(user_details['username']))

            # verify that the values are available:
            if ('podcast_title' not in request.form):
                newdict['podcast_title'] = 'Empty Podcast Value'
            else:
                newdict['podcast_title'] = request.form['podcast_title']
                print("We have a value: ", newdict['podcast_title'])

            if ('podcast_uri' not in request.form):
                newdict['podcast_uri'] = 'Empty URI Value'
            else:
                newdict['podcast_uri'] = request.form['podcast_uri']
                print("We have a value: ", newdict['podcast_uri'])

            if ('podcast_last_updated' not in request.form):
                newdict['podcast_last_updated'] = '2019-01-01'
            else:
                newdict['podcast_last_updated'] = request.form[
                    'podcast_last_updated']
                print("We have a value: ", newdict['podcast_last_updated'])

            if ('description' not in request.form):
                newdict['description'] = 'Empty description field'
            else:
                newdict['description'] = request.form['description']
                print("We have a value: ", newdict['description'])

            # if ('artwork' not in request.form):
            #     newdict['artwork'] = 'https://user-images.githubusercontent.com/24848110/33519396-7e56363c-d79d-11e7-969b-09782f5ccbab.png'
            # else:
            #     newdict['artwork'] = request.form['artwork']
            #     print("We have a value: ",newdict['artwork'])

            print('newdict is:')
            print(newdict)

            #forward to the database to manage insert
            podcasts = database.add_podcast_to_db(
                newdict['podcast_title'], newdict['podcast_uri'],
                newdict['podcast_last_updated'], newdict['description'])

            max_podcast_id = database.get_last_podcast()[0]['podcast_id']
            print(podcasts)
            if podcasts is not None:
                max_podcast_id = podcasts[0]

            # ideally this would redirect to your newly added artist
            return single_podcast(max_podcast_id)
        else:
            return render_template('createitems/createpodcast.html',
                                   session=session,
                                   page=page,
                                   user=user_details)