mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-22 09:18:13 +00:00
Fixed some db stuff and fuck up
This commit is contained in:
@@ -80,14 +80,22 @@ class RadioHelper(Helper):
|
||||
return Response(data=ret, status=HTTP_200_OK)
|
||||
|
||||
def post(self, request):
|
||||
try:
|
||||
if 'action' in request.query_params:
|
||||
action = request.query_params.get('action')
|
||||
if action == 'shuffle':
|
||||
ice_scrobbler.shuffle()
|
||||
return Response(status=HTTP_200_OK)
|
||||
if action == 'play':
|
||||
m = Mix.objects.get(slug=request.query_params.get('slug'))
|
||||
ice_scrobbler.play(m.get_stream_url())
|
||||
return Response(status=HTTP_200_OK)
|
||||
if 'update' in request.query_params and 'url' in request.query_params:
|
||||
activity.post_activity('site:radio_changed', message={
|
||||
'description': request.query_params.get('update'),
|
||||
'url': request.query_params.get('url')
|
||||
})
|
||||
except:
|
||||
pass
|
||||
|
||||
return Response(status=HTTP_400_BAD_REQUEST)
|
||||
|
||||
@@ -45,6 +45,10 @@ def shuffle():
|
||||
url = "http://%s:%s/a/shuffle" % (settings.RADIO_HOST, settings.RADIO_PORT)
|
||||
r = requests.post(url)
|
||||
|
||||
def play(url):
|
||||
url = "http://%s:%s/a/shuffle" % (settings.RADIO_HOST, settings.RADIO_PORT)
|
||||
r = requests.post(url)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
d = get_server_details("localhost", "8000", "dss")
|
||||
|
||||
25
spa/management/commands/restore.py
Normal file
25
spa/management/commands/restore.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from django.core.management.base import LabelCommand
|
||||
import dropbox
|
||||
from dss import settings
|
||||
|
||||
|
||||
def _restore_database():
|
||||
""" find latest database backup """
|
||||
client = dropbox.client.DropboxClient(settings.DSS_DB_BACKUP_TOKEN)
|
||||
|
||||
|
||||
class Command(LabelCommand):
|
||||
help = (
|
||||
"Handles restoring of items backed up"
|
||||
)
|
||||
missing_args_message = "Enter one of [database, settings, media, all]"
|
||||
|
||||
def handle_label(self, label, **options):
|
||||
if label == "database":
|
||||
_restore_database()
|
||||
if label == "settings":
|
||||
pass
|
||||
if label == "media":
|
||||
pass
|
||||
if label == "all":
|
||||
_restore_database()
|
||||
Reference in New Issue
Block a user