示例#1
0
def play(request):
    with CustMPDClient.GetClient() as mpd:
        if mpd.status().get('state', None) == 'play':
            mpd.pause()
        else:
            mpd.play()
    return HttpResponse("OK")
示例#2
0
def playlist_info(request):
    with CustMPDClient.GetClient() as mpd:
        data = {}
        data['info'] = mpd.playlistinfo()
        data['playlist'] = mpd.playlist()

    return data
示例#3
0
def status(request):
    with CustMPDClient.GetClient() as mpd:
        data = mpd.status()
        data.update(mpd.currentsong())
        data.update(mpd.stats())

    return data
示例#4
0
def remove_songs(request):
    post = request.POST
    with CustMPDClient.GetClient() as mpd:
        for song in json.loads(post['songs']):
            song = int(song)
            mpd.deleteid(song)
    return HttpResponse("OK")
示例#5
0
def save_playlist(request):
    name = request.POST['name']
    with CustMPDClient.GetClient() as mpd:
        try:
            mpd.rm(name)
        except:
            pass
        mpd.save(name)
    return HttpResponse("OK")
示例#6
0
def add_songs(request):
    post = request.POST
    with CustMPDClient.GetClient() as mpd:
        for song in json.loads(post['songs']):
            mpd.add(song)
    return HttpResponse("OK")
示例#7
0
def volume(request, volume):
    with CustMPDClient.GetClient() as mpd:
        mpd.setvol(volume)
        volume = mpd.status()['volume']
    return HttpResponse("Volume: %s" % volume)
示例#8
0
def random(request):
    with CustMPDClient.GetClient() as mpd:
        random = int(mpd.status()['random'])
        mpd.random(0 if random == 1 else 1)

    return HttpResponse("Random: %s" % random)
示例#9
0
def repeat(request):
    with CustMPDClient.GetClient() as mpd:
        repeat = int(mpd.status()['repeat'])
        mpd.repeat(0 if repeat == 1 else 1)
    return HttpResponse("Repeat: %s" % repeat)
示例#10
0
def play_song(request, song_id):
    with CustMPDClient.GetClient() as mpd:
        mpd.playid(song_id)
    return HttpResponse("Playing Song %s." % song_id)
示例#11
0
def stop(request):
    with CustMPDClient.GetClient() as mpd:
        mpd.stop()
    return HttpResponse("OK")
示例#12
0
def next(request):
    with CustMPDClient.GetClient() as mpd:
        mpd.next()
    return HttpResponse("OK")
示例#13
0
def prev(request):
    with CustMPDClient.GetClient() as mpd:
        mpd.previous()
    return HttpResponse("OK")
示例#14
0
def all_songs(request, page=0):
    with CustMPDClient.GetClient() as mpd:
        mpd.iterate = True
        data = [x for x in mpd.listallinfo('/')[10 * page:10 * (page + 1) - 1]]

    return data
示例#15
0
def update_library(request):
    with CustMPDClient.GetClient() as mpd:
        mpd.update()
    return HttpResponse("OK")
示例#16
0
def clear_songs(request):
    with CustMPDClient.GetClient() as mpd:
        mpd.clear()
    return HttpResponse("OK")