def AddSong(request, videoId): token_str = request.COOKIES['token'] token = AuthToken.Get(token_str) player = Player.instance() url = "https://www.youtube.com/watch?v={}".format(videoId) result = player.addSong(token.user, url) if result is True: return HttpResponse() else: return HttpResponse(status=400)
def Queue(request, ids=None): print("Request: {}".format(request)) print("Queue!") token_str = request.COOKIES['token'] print("Huh?") token = AuthToken.Get(token_str) print("Got token, getting player!") player = Player.instance() player.queueSong(token.user, ids) print("Queue here: {}".format(ids)) return HttpResponse()
def Status(request): player = Player.instance() song = player.getCurrentSong() data = {} data['playing'] = player.isPlaying() if song is not None and player.isPlaying(): data['title'] = song.title else: data['title'] = "" data['time'] = player.getTime() data['length'] = player.getLength() data['volume'] = player.getVolume() return HttpResponse(json.dumps(data))
def Next(request): Player.instance().nextSong() return HttpResponse()
def Stop(request): Player.instance().stop() return HttpResponse()
def GetLength(request): return HttpResponse(Player.instance().getLength())
def SetTime(request, time): time = int(time) Player.instance().setTime(time) return HttpResponse(Player.instance().getTime())
def GetTime(request): return HttpResponse(Player.instance().getTime())
def SetVolume(request, volume): volume = int(volume) Player.instance().setVolume(volume) return HttpResponse(Player.instance().getVolume())
""" WSGI config for DJPajton2 project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application from player.Player import Player from skype.Skype import Skype os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DJPajton2.settings") # Start player vlc = Player.instance() try: skype = Skype.instance() skype.start() except Exception as e: print("Skype initialization failed! Use web panel :(") print(" {}".format(e)) print("Started!") application = get_wsgi_application()