Esempio n. 1
0
def add2ActivePlaylist(request, song_id, library_id, player):
  player.lockActivePlaylist()
  if ActivePlaylistEntry.isQueued(song_id, library_id, player):
    voteSong(player, request.udjuser, song_id, library_id, 1)
    return HttpResponse()
  elif ActivePlaylistEntry.isPlaying(song_id, library_id, player):
    return HttpResponse()

  if LibraryEntry.songExsitsAndNotBanned(song_id, int(library_id), player):
    addSongsToPlaylist([{'id' : song_id , 'library_id' : library_id}], player, request.udjuser)
  else:
    return HttpResponseMissingResource('song')

  return HttpResponse(status=201)
Esempio n. 2
0
def add2ActivePlaylist(user, lib_id, player):
  player.lockActivePlaylist()
  if ActivePlaylistEntry.isQueued(lib_id, player):
    voteSong(player, user, lib_id, 1)
    return HttpResponse()
  elif ActivePlaylistEntry.isPlaying(lib_id, player):
    return HttpResponse()

  try:
    addSongsToPlaylist([lib_id], player, user)
  except ObjectDoesNotExist:
    toReturn = HttpResponseNotFound()
    toReturn[MISSING_RESOURCE_HEADER] = 'song'
    return toReturn

  return HttpResponse(status=201)
Esempio n. 3
0
def add2ActivePlaylist(user, lib_id, default_library, player):
  player.lockActivePlaylist()
  if ActivePlaylistEntry.isQueued(lib_id, default_library, player):
    voteSong(player, user, lib_id, 1)
    return HttpResponse()
  elif ActivePlaylistEntry.isPlaying(lib_id, default_library, player):
    return HttpResponse()

  if LibraryEntry.songExsitsAndNotBanned(lib_id, default_library, player):
    addSongsToPlaylist([lib_id], default_library, player, user)
  else:
    toReturn = HttpResponseNotFound()
    toReturn[MISSING_RESOURCE_HEADER] = 'song'
    return toReturn

  return HttpResponse(status=201)