mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 22:12:22 +01:00
Add maximum length a person can queue in a row.
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user