mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-03 07:24:00 +00:00
Added download url handler
This commit is contained in:
14
spa/audio.py
14
spa/audio.py
@@ -10,9 +10,23 @@ class AudioHandler(object):
|
||||
def urls(self):
|
||||
pattern_list = [
|
||||
url(r'^stream/(?P<mix_id>\d+)/$', 'spa.audio.start_streaming', name='audio_start_streaming'),
|
||||
url(r'^download/(?P<mix_id>\d+)/$', 'spa.audio.download', name='audio_download'),
|
||||
]
|
||||
return pattern_list
|
||||
|
||||
def download(request, mix_id):
|
||||
try:
|
||||
mix = Mix.objects.get(pk=mix_id)
|
||||
if mix is not None:
|
||||
filename = mix.local_file.path # Select your file here.
|
||||
file, ext = os.path.splitext(filename)
|
||||
response = sendfile(request, filename, attachment=True, attachment_filename="%s.%s" % (mix.title, ext))
|
||||
return response
|
||||
except Exception, ex:
|
||||
print ex
|
||||
|
||||
raise Http404("Mix not found")
|
||||
|
||||
def start_streaming(request, mix_id):
|
||||
try:
|
||||
mix = Mix.objects.get(pk=mix_id)
|
||||
|
||||
0
static/js/libs/ape/apeClientJS.js
Normal file → Executable file
0
static/js/libs/ape/apeClientJS.js
Normal file → Executable file
0
static/js/libs/ape/apeClientMoo.js
Normal file → Executable file
0
static/js/libs/ape/apeClientMoo.js
Normal file → Executable file
0
static/js/libs/ape/apeCore.js
Normal file → Executable file
0
static/js/libs/ape/apeCore.js
Normal file → Executable file
0
static/js/libs/ape/apeCoreSession.js
Normal file → Executable file
0
static/js/libs/ape/apeCoreSession.js
Normal file → Executable file
Reference in New Issue
Block a user