Ejemplo n.º 1
0
def generate(request):
  # generates a recommendation from the engine
  playlist = request.GET.get('playlist', 'NO PLAYLIST')
  print "generating for playlist: " + playlist 
  rec = engine.generate_recommendation(playlist)
  response = rec.video_id + DELIMITER + rec.title
  return HttpResponse(response)
Ejemplo n.º 2
0
def playing(request):
  # playing the requesting piece
  video_id = request.GET.get('video_id', '')
  playlist = request.GET.get('playlist', '')
  tag = request.GET.get('tag', '')
  template = loader.get_template('playing_script.html')
  deb_arg = request.GET.get('deb', '0')
  if not playlist:
    return render_landing(tag);
  
  if not video_id:
    video_id = engine.generate_recommendation(playlist).video_id
  queue = engine.generate_queue(playlist)
  
  playlist_model = Playlist.objects.get(name=playlist)
  playlists = Playlist.objects.order_by("-last_played")
  playlists_alphabetical = Playlist.objects.order_by("name")
  
  context = Context({
    'playlist': playlist_model,
    'playlists': playlists,
    'playlists_alphabetical': playlists_alphabetical,
    'queue': queue,
    'video_id': video_id, 
    'video_title': engine.get_title(playlist, video_id),
  })
  return HttpResponse(template.render(context))