def xml_edit(request): if not request.user.is_authenticated(): return xml_error('user not logged in') form = request.POST try: song = Song.objects.get(pk=int(form.get('id',''))) except (ValueError, TypeError, Song.DoesNotExist), err: return xml_error(str(err))
def xml_edit(request): if not request.user.is_authenticated(): return xml_error('user not logged in') form = request.POST try: song = Song.objects.get(pk=int(form.get('id', ''))) except (ValueError, TypeError, Song.DoesNotExist), err: return xml_error(str(err))
def xml_control(request): form = request.POST action = form.get('action','') channel = Channel.default() ctrl = channel.controller() try: if action == 'play': ctrl.unpause() elif action == 'pause': ctrl.pause() elif action == 'skip': ctrl.skip() elif action == 'shuffle': ctrl.shuffle() else: return xml_error('invalid action: ' + action) except ControlError, err: return xml_error(str(err)) else: return simple_xml_response('success')
def xml_control(request): form = request.POST action = form.get('action', '') channel = Channel.default() ctrl = channel.controller() try: if action == 'play': ctrl.unpause() elif action == 'pause': ctrl.pause() elif action == 'skip': ctrl.skip() elif action == 'shuffle': ctrl.shuffle() else: return xml_error('invalid action: ' + action) except ControlError, err: return xml_error(str(err))
def xml_dequeue(request): form = request.POST # Get the selected songs. playids = get_int_list(form, 'playids') # Dequeue the songs. channel = Channel.default() ctrl = channel.controller() try: ctrl.remove_songs(playids) except ControlError, err: return xml_error(str(err)) else: return simple_xml_response('success')
def xml_queue(request): form = request.POST # Get the selected songs. songs = get_song_list(form) # Queue the songs. channel = Channel.default() ctrl = channel.controller() try: ctrl.add_songs(songs) except ControlError, err: return xml_error(str(err)) else: return simple_xml_response('success')
def xml_dequeue(request): form = request.POST # Get the selected songs. playids = get_int_list(form, 'playids') # Dequeue the songs. channel = Channel.default() ctrl = channel.controller() try: ctrl.remove_songs(playids) except ControlError, err: return xml_error(str(err))
def xml_queue(request): form = request.POST # Get the selected songs. songs = get_song_list(form) # Queue the songs. channel = Channel.default() ctrl = channel.controller() try: ctrl.add_songs(songs) except ControlError, err: return xml_error(str(err))
def xml_update(request): # TODO(rnk): This code is dead and untested. form = request.POST channel_id = get_integer(form, 'channel', 1) try: channel = Channel.objects.get(pk=channel_id) except Channel.DoesNotExist: return xml_error('invalid channel id: ' + repr(channel_id)) timestamp = get_integer(form, 'timestamp', None) if timestamp is None: return xml_error('invalid timestamp') elif timestamp >= channel.last_touched_timestamp(): # up-to-date timestamp try: snapshot = request.get_channel_snapshot(channel) if snapshot.status != "playing": return simple_xml_response('continue') elapsed_time = snapshot.time_elapsed total_time = snapshot.current_song.time return render_xml_to_response('aenclave/update.xml', {'elapsed_time':elapsed_time, 'total_time':total_time}) except ControlError, err: return xml_error(str(err)) else: return simple_xml_response('reload') # old timestamp
def xml_update(request): # TODO(rnk): This code is dead and untested. form = request.POST channel_id = get_integer(form, 'channel', 1) try: channel = Channel.objects.get(pk=channel_id) except Channel.DoesNotExist: return xml_error('invalid channel id: ' + repr(channel_id)) timestamp = get_integer(form, 'timestamp', None) if timestamp is None: return xml_error('invalid timestamp') elif timestamp >= channel.last_touched_timestamp(): # up-to-date timestamp try: snapshot = request.get_channel_snapshot(channel) if snapshot.status != "playing": return simple_xml_response('continue') elapsed_time = snapshot.time_elapsed total_time = snapshot.current_song.time return render_xml_to_response('aenclave/update.xml', { 'elapsed_time': elapsed_time, 'total_time': total_time }) except ControlError, err: return xml_error(str(err))
def permission_required_xml(perm): return permission_required(perm, '', lambda r,text,act: xml_error(text))