Fixed mix add flow

This commit is contained in:
=
2012-09-22 19:34:43 +01:00
parent 9e747c9ca2
commit f0a118691b
547 changed files with 86 additions and 78 deletions

0
LICENSE Executable file → Normal file
View File

0
README Executable file → Normal file
View File

0
_working/create Executable file → Normal file
View File

0
_working/event.sql Executable file → Normal file
View File

0
_working/label.sql Executable file → Normal file
View File

0
_working/mix.sql Executable file → Normal file
View File

0
_working/recurrence.sql Executable file → Normal file
View File

0
_working/release.sql Executable file → Normal file
View File

0
_working/release_audio.sql Executable file → Normal file
View File

0
_working/social.sql Executable file → Normal file
View File

0
_working/venue.sql Executable file → Normal file
View File

0
apache/django_live.wsgi Executable file → Normal file
View File

0
core/__init__.py Executable file → Normal file
View File

0
core/analytics/__init__.py Executable file → Normal file
View File

0
core/analytics/google.py Executable file → Normal file
View File

0
core/decorators.py Executable file → Normal file
View File

0
core/serialisers/__init__.py Executable file → Normal file
View File

0
core/serialisers/json.py Executable file → Normal file
View File

0
core/social/Facebook.py Executable file → Normal file
View File

0
core/social/_Social.py Executable file → Normal file
View File

0
core/social/__init__.py Executable file → Normal file
View File

10
core/tasks.py Executable file → Normal file
View File

@@ -3,13 +3,11 @@ from celery.task import task
import os
from core.utils.waveform import generate_waveform
from dss import settings
from spa.signals import waveform_generated
"""
name='core.tasks.create_waveform_task'
"""
@task()
def create_waveform_task(in_file, uid):
out_file = os.path.join(settings.MEDIA_ROOT, 'waveforms/%s.png' % uid)
def create_waveform_task(in_file, mix_uid):
out_file = os.path.join(settings.MEDIA_ROOT, 'waveforms/%s.png' % mix_uid)
print "Creating waveform \n\tIn: %s\n\tOut: %s" % (in_file, out_file)
generate_waveform(in_file, out_file)
if os.path.isfile(out_file):
@@ -18,5 +16,7 @@ def create_waveform_task(in_file, uid):
new_file = in_file.replace('cache', 'mixes')
print "Moving cache audio clip from %s to %s" % (in_file, new_file)
shutil.move(in_file, new_file)
print "Uid: %s" % mix_uid
waveform_generated.send(sender=None, uid=mix_uid)
else:
print "Outfile is missing"

0
core/tests/__init__.py Executable file → Normal file
View File

0
core/tests/mix.py Executable file → Normal file
View File

0
core/utils/__init__.py Executable file → Normal file
View File

4
core/utils/file.py Executable file → Normal file
View File

@@ -1,7 +1,7 @@
import uuid
import os
def generate_save_file_name(prefix, filename):
def generate_save_file_name(uid, prefix, filename):
filename, extension = os.path.splitext(filename)
ret = "%s%s" % ('/'.join([prefix, str(uuid.uuid1())]), extension)
ret = "%s%s" % ('/'.join([prefix, uid]), extension)
return ret

0
core/utils/html.py Executable file → Normal file
View File

0
core/utils/live.py Executable file → Normal file
View File

0
core/utils/string.py Executable file → Normal file
View File

4
core/utils/url.py Normal file
View File

@@ -0,0 +1,4 @@
__author__ = 'fergalm'
def urlclean(url):
ret = url.replace('//', '/')
return ret

0
core/utils/waveform.py Executable file → Normal file
View File

0
core/widgets/__init__.py Executable file → Normal file
View File

0
core/widgets/upload.py Executable file → Normal file
View File

0
dss/__init__.py Executable file → Normal file
View File

1
dss/settings.py Executable file → Normal file
View File

@@ -142,6 +142,7 @@ INSTALLED_APPS = (
'avatar',
'notification',
'spa',
'spa.signals',
'core',
'allauth',
'allauth.account',

0
dss/urls.py Executable file → Normal file
View File

0
dss/wsgi.py Executable file → Normal file
View File

0
initial_data.json Executable file → Normal file
View File

0
manage.py Executable file → Normal file
View File

0
requirements.txt Executable file → Normal file
View File

0
spa/__init__.py Executable file → Normal file
View File

0
spa/admin.py Executable file → Normal file
View File

2
spa/ajax.py Executable file → Normal file
View File

@@ -214,7 +214,7 @@ def upload_mix_file_handler(request):
for chunk in f.chunks():
destination.write(chunk)
try:
create_waveform_task.delay(in_file=in_file, uid=uid)
create_waveform_task.delay(in_file=in_file, mix_uid=uid)
except Exception, ex:
logger.exception("Error starting waveform generation task: %s" % ex.message)
return HttpResponse(_get_json("Success"), mimetype='application/json')

0
spa/api/__init__.py Executable file → Normal file
View File

0
spa/api/v1/BackboneCompatibleResource.py Executable file → Normal file
View File

0
spa/api/v1/CommentResource.py Executable file → Normal file
View File

0
spa/api/v1/EventResource.py Executable file → Normal file
View File

3
spa/api/v1/MixResource.py Executable file → Normal file
View File

@@ -21,8 +21,7 @@ class MixResource(BackboneCompatibleResource):
file_name = "mixes/%s.%s" % (bundle.data['upload-hash'], bundle.data['upload-extension'])
uid = bundle.data['upload-hash']
bundle.data['user'] = request.user.get_profile()
return super(MixResource, self).obj_create(bundle, request, user=request.user.get_profile(),
local_file=file_name, uid=uid)
return super(MixResource, self).obj_create(bundle, request, user=request.user.get_profile(), local_file=file_name, uid=uid)
def obj_get_list(self, request=None, **kwargs):
sort = 'latest'

0
spa/api/v1/ReleaseAudioResource.py Executable file → Normal file
View File

0
spa/api/v1/ReleaseResource.py Executable file → Normal file
View File

0
spa/api/v1/UserResource.py Executable file → Normal file
View File

0
spa/api/v1/__init__.py Executable file → Normal file
View File

0
spa/audio.py Executable file → Normal file
View File

0
spa/forms.py Executable file → Normal file
View File

0
spa/management/__init__.py Executable file → Normal file
View File

0
spa/management/commands/__init__.py Executable file → Normal file
View File

0
spa/management/commands/cleanup.py Executable file → Normal file
View File

0
spa/management/commands/drop.py Executable file → Normal file
View File

0
spa/management/commands/purchaselinks.py Executable file → Normal file
View File

0
spa/management/commands/tracklists.py Executable file → Normal file
View File

19
spa/management/commands/waveforms.py Executable file → Normal file
View File

@@ -6,6 +6,12 @@ from spa.models.Mix import Mix
class Command(NoArgsCommand):
help = "Generate all outstanding waveforms"
def _generateWaveform(self, guid):
output_file = 'waveforms/%s.png' % guid
local_file = '%s/%s' % (settings.CACHE_ROOT, guid)
if os.path.isfile(local_file):
self._check_file(local_file, output_file)
def _check_file(self, local_file, output_file):
if os.path.isfile(os.path.join(settings.MEDIA_ROOT, local_file)):
file = os.path.join(settings.MEDIA_ROOT, output_file)
@@ -14,14 +20,9 @@ class Command(NoArgsCommand):
generate_waveform(local_file, file)
def handle(self, *args, **options):
for guid in args:
output_file = 'waveforms/%s.png' % guid
local_file = '%s/%s' % (self.CACHE_ROOT, guid)
if os.path.isfile(local_file):
self._check_file(local_file, output_file)
def handle_noargs(self, **options):
print "Generating waveforms for mix"
unprocessed = Mix.objects.filter(waveform_generated=False)
for mix in unprocessed:
pass
self._generateWaveform(mix.uid)
def handle_noargs(self, **options):
pass

0
spa/middleware/__init__.py Executable file → Normal file
View File

0
spa/middleware/uploadify.py Executable file → Normal file
View File

0
spa/models/Comment.py Executable file → Normal file
View File

0
spa/models/Event.py Executable file → Normal file
View File

0
spa/models/Label.py Executable file → Normal file
View File

40
spa/models/Mix.py Executable file → Normal file
View File

@@ -1,20 +1,22 @@
from django.db.models.signals import post_save
from django.dispatch import Signal, receiver
import os
from core.utils import url
from datetime import datetime
from django.db import models
from django.db.models import Count
from django.forms import save_instance
import os
from core.utils.file import generate_save_file_name
from dss import settings, localsettings
from spa.models.MixLike import MixLike
from spa.models.MixPlay import MixPlay
from dss import settings, localsettings
from spa.models.UserProfile import UserProfile
from spa.models._BaseModel import _BaseModel
from core.utils.file import generate_save_file_name
def mix_file_name(instance, filename):
return generate_save_file_name('mixes', filename)
return generate_save_file_name(instance.uid, 'mixes', filename)
def mix_image_name(instance, filename):
return generate_save_file_name('mix-images', filename)
ret = generate_save_file_name(instance.uid, 'mix-images', filename)
return ret
class Mix(_BaseModel):
class Meta:
@@ -30,7 +32,7 @@ class Mix(_BaseModel):
is_active = models.BooleanField(default=True)
user = models.ForeignKey(UserProfile, editable=False)
waveform_generated = models.BooleanField(default=False)
uid = models.CharField(max_length=38, blank=True)
uid = models.CharField(max_length=38, blank=True, unique=True)
def __unicode__(self):
return self.title
@@ -40,6 +42,11 @@ class Mix(_BaseModel):
#from image - will sort when I've figured backbone out better
if self.mix_image.name.startswith(settings.MEDIA_URL):
self.mix_image.name = self.mix_image.name[len(settings.MEDIA_URL):len(self.mix_image.name)]
#Check for the unlikely event that the waveform has been generated
if os.path.isfile(self.get_waveform_path()):
self.waveform_generated = True
super(Mix, self).save(force_insert, force_update, using)
def get_absolute_url(self):
@@ -51,23 +58,18 @@ class Mix(_BaseModel):
def get_waveform_url(self):
waveform_root = localsettings.WAVEFORM_URL if hasattr(localsettings, 'WAVEFORM_URL') else "%s/waveforms/" % settings.MEDIA_URL
ret = "%s/%s.%s" % (waveform_root, self.uid, "png")
return ret
return url.urlclean(ret)
def get_image_url(self):
images_root = localsettings.IMAGE_URL if hasattr(localsettings, 'IMAGE_URL') else "%s/mix_images/" % settings.MEDIA_URL
ret = "%s/%s" % (images_root, self.mix_image)
return ret
"""
try:
if os.path.isfile(self.mix_image.path):
image_root = localsettings.IMAGE_URL if hasattr(localsettings, 'IMAGE_URL') else settings.MEDIA_URL
ret = "%s/%s" % (image_root, self.mix_image.name)
return ret
except:
return settings.STATIC_URL + 'img/default-track.png'
images_root = localsettings.IMAGE_URL if hasattr(localsettings, 'IMAGE_URL') else "%s/" % settings.MEDIA_URL
ret = "%s/%s" % (images_root, self.mix_image)
return url.urlclean(ret)
except Exception, ex:
pass
return settings.STATIC_URL + 'img/default-track.png'
"""
def get_stream_path(self):
#return 'media/%s/' % self.local_file.name

0
spa/models/MixFavourite.py Executable file → Normal file
View File

0
spa/models/MixLike.py Executable file → Normal file
View File

0
spa/models/MixPlay.py Executable file → Normal file
View File

0
spa/models/PurchaseLink.py Executable file → Normal file
View File

0
spa/models/Recurrence.py Executable file → Normal file
View File

0
spa/models/Release.py Executable file → Normal file
View File

0
spa/models/Tracklist.py Executable file → Normal file
View File

0
spa/models/UserProfile.py Executable file → Normal file
View File

0
spa/models/Venue.py Executable file → Normal file
View File

0
spa/models/_Activity.py Executable file → Normal file
View File

0
spa/models/_BaseModel.py Executable file → Normal file
View File

0
spa/models/_Lookup.py Executable file → Normal file
View File

0
spa/models/__init__.py Executable file → Normal file
View File

20
spa/signals.py Normal file
View File

@@ -0,0 +1,20 @@
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.signals import post_save
from django.dispatch import receiver, Signal
import os
from spa.models.Mix import Mix
waveform_generated = Signal()
def waveform_generated_callback(sender, **kwargs):
print "Updating model with waveform"
try:
uid = kwargs['uid']
if uid is not None:
mix = Mix.objects.get(uid=uid)
if mix is not None:
mix.waveform_generated = True
mix.save()
except ObjectDoesNotExist:
pass
waveform_generated.connect(waveform_generated_callback)

0
spa/social.py Executable file → Normal file
View File

0
spa/templates.py Executable file → Normal file
View File

0
spa/templatetags/__init__.py Executable file → Normal file
View File

0
spa/templatetags/spa_extras.py Executable file → Normal file
View File

0
spa/urls.py Executable file → Normal file
View File

0
spa/views.py Executable file → Normal file
View File

0
static/bin/sm/soundmanager2.swf Executable file → Normal file
View File

0
static/bin/sm/soundmanager2_debug.swf Executable file → Normal file
View File

0
static/bin/sm/soundmanager2_flash9.swf Executable file → Normal file
View File

0
static/bin/sm/soundmanager2_flash9_debug.swf Executable file → Normal file
View File

0
static/bin/sm/soundmanager2_flash_xdomain.zip Executable file → Normal file
View File

0
static/css/bootstrap/bootstrap-datepicker.css vendored Executable file → Normal file
View File

0
static/css/bootstrap/bootstrap-responsive.css vendored Executable file → Normal file
View File

0
static/css/bootstrap/bootstrap-responsive.min.css vendored Executable file → Normal file
View File

0
static/css/bootstrap/bootstrap-timepicker.css vendored Executable file → Normal file
View File

0
static/css/bootstrap/bootstrap.css vendored Executable file → Normal file
View File

0
static/css/bootstrap/bootstrap.min.css vendored Executable file → Normal file
View File

0
static/css/colorbox.css Executable file → Normal file
View File

0
static/css/com.podnoms.player.css Executable file → Normal file
View File

Some files were not shown because too many files have changed in this diff Show More