summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nop/__init__.py0
-rw-r--r--nop/models.py36
-rw-r--r--nop/urls.py7
-rw-r--r--nop/views.py26
4 files changed, 69 insertions, 0 deletions
diff --git a/nop/__init__.py b/nop/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nop/__init__.py
diff --git a/nop/models.py b/nop/models.py
new file mode 100644
index 0000000..8bb87af
--- /dev/null
+++ b/nop/models.py
@@ -0,0 +1,36 @@
+from django.db import models
+
+class Master(models.Model):
+ timestamp = models.BigIntegerField(primary_key=True)
+ cart = models.IntegerField()
+ len = models.IntegerField(null=True, blank=True)
+ showtitle = models.CharField(max_length=765, blank=True)
+ title = models.CharField(max_length=765, blank=True)
+ artist = models.CharField(max_length=765, blank=True)
+ album = models.CharField(max_length=765, blank=True)
+ ismusic = models.IntegerField(null=True, blank=True)
+ class Meta:
+ db_table = u'master'
+ ordering = ['-timestamp']
+
+
+class Standby(models.Model):
+ timestamp = models.BigIntegerField(primary_key=True)
+ cart = models.IntegerField()
+ len = models.IntegerField(null=True, blank=True)
+ showtitle = models.CharField(max_length=765, blank=True)
+ title = models.CharField(max_length=765, blank=True)
+ artist = models.CharField(max_length=765, blank=True)
+ album = models.CharField(max_length=765, blank=True)
+ ismusic = models.IntegerField(null=True, blank=True)
+ class Meta:
+ db_table = u'standby'
+ ordering = ['-timestamp']
+
+class State(models.Model):
+ timestamp = models.BigIntegerField(primary_key=True)
+ state = models.CharField(max_length=96, blank=True)
+ class Meta:
+ db_table = u'state'
+ ordering = ['-timestamp']
+
diff --git a/nop/urls.py b/nop/urls.py
new file mode 100644
index 0000000..a4700cf
--- /dev/null
+++ b/nop/urls.py
@@ -0,0 +1,7 @@
+from django.conf.urls.defaults import patterns, url
+from views import get, get_current
+
+urlpatterns = patterns('',
+ url(r'^$', get_current),
+ url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<hour>\d{1,2})/(?P<minute>\d{1,2})/?$', get),
+)
diff --git a/nop/views.py b/nop/views.py
new file mode 100644
index 0000000..6fec3a3
--- /dev/null
+++ b/nop/views.py
@@ -0,0 +1,26 @@
+from django.http import HttpResponse
+from models import Master
+import json
+#import time
+#from datetime import date, datetime, time, timedelta
+
+def get_current(request):
+
+ #current = int(time.time())*1000000
+ #time.gmtime(Master.objects.using('nop').all()[6000].timestamp//1000000)
+ # select all where timestamp < givenTS, get most recent one -> order DESC
+
+ # reverse sorted. get the first object = last played
+ result = Master.objects.using('nop').all()[0]
+ response = json.dumps({'artist': result.artist, 'title': result.title})
+
+ #return HttpResponse(response, mimetype='application/json')
+ return HttpResponse(response, mimetype='text/plain')
+
+def get(request, year=None, month=None, day=None, hour=None, minute=None):
+ #if year is None and month is None and day is None:
+ # today = datetime.combine(date.today(), time(6, 0))
+ #else:
+ # today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M')
+ return None
+