Ejemplo n.º 1
0
 def handle_noargs(self, **options):
     try:
         mix = Mix.objects.get(duration=None)
         if mix is not None:
             mix.waveform_generated = True
             mix.duration = mp3_length(path)
             mix.save(update_fields=["waveform_generated", "duration"])
     except Exception as ex:
         print("Debug exception: %s" % ex)
Ejemplo n.º 2
0
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.duration = mp3_length(mix.get_absolute_path())
                mix.save(update_fields=["waveform_generated", "duration"])
    except ObjectDoesNotExist:
        print "Mix has still not been uploaded"
        pass
Ejemplo n.º 3
0
    def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
        if not self.id:
            self.slug = unique_slugify(self, self.title)

        self.clean_image('mix_image', Mix)
        #Check for the unlikely event that the waveform has been generated
        if os.path.isfile(self.get_waveform_path()):
            self.waveform_generated = True
            try:
                self.duration = mp3_length(self.get_absolute_path())
            except Mp3FileNotFoundException:
                #Not really bothered about this in save as it can be called before we have an mp3
                pass

        super(Mix, self).save(force_insert, force_update, using, update_fields)
Ejemplo n.º 4
0
 def handle(self, *args, **options):
     try:
         candidates = Mix.objects.all()
         for mix in candidates:
             try:
                 if mix.duration is None:
                     print "Finding duration for: %s" % mix.title
                     length = mp3_length(mix.get_absolute_path())
                     print "\tLength: %d" % length
                     mix.duration = length
                 if mix.slug == 'Invalid':
                     print "Slugifying mix: %s" % mix.title
                     mix.slug = unique_slugify(mix, mix.title)
                     print "\tNew title: %s" % mix.slug
                 mix.save()
             except Mp3FileNotFoundException, me:
                 mix.delete()
                 print me.message
     except Exception, ex:
         raise CommandError(ex.message)
Ejemplo n.º 5
0
 def handle(self, *args, **options):
     try:
         candidates = Mix.objects.all()
         for mix in candidates:
             try:
                 if mix.duration is None:
                     print("Finding duration for: %s" % mix.title)
                     length = mp3_length(mix.get_absolute_path())
                     print("\tLength: %d" % length)
                     mix.duration = length
                 if mix.slug == 'Invalid':
                     print("Slugifying mix: %s" % mix.title)
                     mix.slug = unique_slugify(mix, mix.title)
                     print("\tNew title: %s" % mix.slug)
                 mix.save()
             except Mp3FileNotFoundException as me:
                 mix.delete()
                 print(me.message)
     except Exception as ex:
         raise CommandError(ex.message)
Ejemplo n.º 6
0
 def set_cdn_details(self, path):
     self.waveform_generated = True
     self.duration = mp3_length(path)
     self.save(update_fields=["waveform_generated", "duration"])
     self.update_file_http_headers(self.uid, self.title)
Ejemplo n.º 7
0
 def set_cdn_details(self, path):
     self.waveform_generated = True
     self.duration = mp3_length(path)
     self.save(update_fields=["waveform_generated", "duration"])
     self.update_file_http_headers(self.uid, self.title)