예제 #1
0
파일: context.py 프로젝트: andyhelp/G2
def positionContextProcessor(request):
  cue = CueFile(settings.LOGIC_DIR + "/ices.cue")
  d = {}
  try:
    now_playing = PlaylistEntry.objects.nowPlaying().song
  except PlaylistEntry.DoesNotExist:
    d['song_position'] = d['song_progress'] = d['song_length'] = 0
  else:
    d['song_position'] = cue.getTime(now_playing)
    d['song_progress'] = cue.getProgress()*100 #percentagise
    d['song_length'] = now_playing.length
  return d
예제 #2
0
def positionContextProcessor(request):
    if not request.user.is_authenticated(): return {}
    cue = CueFile(settings.LOGIC_DIR + "/ices.cue")
    d = {}
    try:
        now_playing = PlaylistEntry.objects.nowPlaying().song
    except PlaylistEntry.DoesNotExist:
        d['song_position'] = d['song_progress'] = d['song_length'] = 0
    else:
        d['song_position'] = cue.getTime(now_playing)
        d['song_progress'] = cue.getProgress() * 100  #percentagise
        d['song_length'] = now_playing.length
    return d
예제 #3
0
파일: context.py 프로젝트: phuzion/G2
def positionContextProcessor(request):
    if not request.user.is_authenticated():
        return {}
    cue = CueFile(settings.LOGIC_DIR + "/ices.cue")
    d = {}
    try:
        now_playing = PlaylistEntry.objects.nowPlaying().song
    except PlaylistEntry.DoesNotExist:
        d["song_position"] = d["song_progress"] = d["song_length"] = 0
    else:
        d["song_position"] = cue.getTime(now_playing)
        d["song_progress"] = cue.getProgress() * 100  # percentagise
        d["song_length"] = now_playing.length
    return d
예제 #4
0
파일: views.py 프로젝트: ggreer/G2
  if resource == "randid":
    randomid = randomdongid()
    return HttpResponse(int(randomid[0]))

  if resource == "listeners":
    return HttpResponse(ListenerCount())
    
  if resource == "users":
    return HttpResponse(Users.objects.all().count())
    
  if resource == "position":
    cue = CueFile(settings.LOGIC_DIR + "/ices.cue")
    d = {}
    now_playing = PlaylistEntry.objects.nowPlaying().song
    d['position'] = cue.getTime(now_playing)
    d['progress'] = cue.getProgress()
    d['length'] = now_playing.length
    return HttpResponse(json.dumps(d))  
  
  raise Http404
  
@login_required()
def favourite(request, songid=0):
  try:
    song = Song.objects.get(id=songid)
  except Song.DoesNotExist:
    raise Http404
  request.user.get_profile().favourites.add(song)
  request.user.message_set.create(message="Song favourited successfully")
  
  referrer = request.META.get('HTTP_REFERER', None)
예제 #5
0
파일: views.py 프로젝트: madsl/gbsfm_web
    return HttpResponse(str(playlistinfo[0]) + "\n" + playlistinfo[2] + "\n" + playlistinfo[3] + "\n" + playlistinfo[1])
    #return HttpResponse(playlistinfo)

  if resource == "listeners":
    return HttpResponse(gbsfmListenerCount())

  if resource == "users":
    return HttpResponse(Users.objects.all().count())

  if resource == "position":
    #cue = CueFile(settings.LOGIC_DIR + "/work/ices.cue")
    cue = CueFile("/remaining/ices2.cue")
    d = {}
    now_playing = PlaylistEntry.objects.nowPlaying().song
    d['position'] = cue.getTime(now_playing)
    d['progress'] = cue.getProgress()
    d['length'] = now_playing.length
    return HttpResponse(json.dumps(d))

  raise Http404

@login_required()
def favourite(request, songid=0):
  try:
    song = Song.objects.get(id=songid)
  except Song.DoesNotExist:
    raise Http404
  request.user.userprofile.favourites.add(song)
  messages.add_message(request, messages.SUCCESS, "Song favourited successfully")

  referrer = request.META.get('HTTP_REFERER', None)