Add maximum length a person can queue in a row.

This commit is contained in:
Jim Driessen
2017-06-01 14:13:25 +02:00
parent 2386c7a68d
commit df1a31efb7
5 changed files with 61 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import socket, struct, binascii
from django.conf import settings
from queues.models import Queue, Playlist
from django.http import StreamingHttpResponse
def song_to_dict(song, hash=False, user=False):
@ -52,3 +53,20 @@ def get_first_queue():
queue = Queue(name='Queue', playlist=playlist, random_playlist=random_playlist)
queue.save()
return queue
def bertha_stream(hash):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(settings.BERTHA_HOST)
sock.sendall(struct.pack("<B", 2) + binascii.unhexlify(hash))
data = sock.recv(4096)
while data:
yield data
data = sock.recv(4096)
sock.close()
def get_from_bertha(hash):
response = StreamingHttpResponse(bertha_stream(hash))
response['Content-Disposition'] = 'attachment; filename="{}"'.format(hash)
return response