Esempio n. 1
0
def playlist_rename(request,playlist_id):
    try:
        playlist = db.playlist.find_one(ObjectId(playlist_id))
        name = request.POST['name']
        playlist.name = name
        playlist.save()
        return JsonResponse({'success': True, 'playlist': playlist})
    except Exception as e:
        return JsonResponse({'success': False, 'error': str(e)})
Esempio n. 2
0
def playlist_delete_song(request,playlist_id):
    try:
        playlist = db.playlist.find_one(ObjectId(playlist_id))
        song_id = request.POST['song_id']
        song = get_song(song_id)
        playlist.songs.remove(song)
        playlist.save()
        return JsonResponse({'success': True, 'playlist': playlist})
    except Exception as e:
        return JsonResponse({'success': False, 'error': str(e)})
Esempio n. 3
0
def playlist_enqueue(request,playlist_id):
    playlist = db.playlist.find_one(ObjectId(playlist_id))
    if playlist != None:
        player = get_player(player_name)
        songs = playlist.songs
        for song in songs:
            player.enqueue(ObjectId(song.id))
        save_player(player)
        return JsonResponse({'success': True, 'playlist': playlist})
    else:
        return JsonResponse({'success': False})
Esempio n. 4
0
def playlist_to_player(request, playlist_name, player_name):
    playlist = get_playlist(playlist_name)
    player = get_player(player_name)
    for song in playlist.songs:
        player.enqueue(song)
    save_player(player)
    return JsonResponse({'success': True})
Esempio n. 5
0
def summary(request, playlist_name):
    playlist = get_playlist(playlist_name)
    return JsonResponse({
        'length': len(playlist.songs),
        'names': [db.songs.Song.find_one(song).title for song in playlist.songs],
    })
Esempio n. 6
0
def list_playlists(request):
    return JsonResponse({
        'playlists': [pl.name for pl in db.playlists.Playlist.find()],
    })
Esempio n. 7
0
def playlist_from_player(request, playlist_name, player_name):
    playlist = get_or_create_playlist(playlist_name)
    player = get_player(player_name)
    playlist.songs = player.queue
    playlist.save()
    return JsonResponse({'success': True})
Esempio n. 8
0
def view_all(request):
    # user = User(request).user
    # playlists = db.playlists.find({'$or' : [{'creator': user}, {'public': True}]}) 
    playlists = db.playlists.find({'public': True})
    return JsonResponse({'success': True, 'playlists': list(playlists)})
Esempio n. 9
0
def playlist_reorder(request,playlist_id):
    return JsonResponse({"success": True})