Пример #1
0
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)
Пример #2
0
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()
Пример #3
0
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))
Пример #4
0
def Next(request):
    Player.instance().nextSong()
    return HttpResponse()
Пример #5
0
def Stop(request):
    Player.instance().stop()
    return HttpResponse()
Пример #6
0
def GetLength(request):
    return HttpResponse(Player.instance().getLength())
Пример #7
0
def SetTime(request, time):
    time = int(time)
    Player.instance().setTime(time)
    return HttpResponse(Player.instance().getTime())
Пример #8
0
def GetTime(request):
    return HttpResponse(Player.instance().getTime())
Пример #9
0
def SetVolume(request, volume):
    volume = int(volume)
    Player.instance().setVolume(volume)
    return HttpResponse(Player.instance().getVolume())
Пример #10
0
"""
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()