Esempio n. 1
0
    def save(self, *args, **kwargs):

        self.clear_cache_file()        
        unique_slugify(self, self.name)
        
        # update d_tags
        t_tags = ''
        for tag in self.tags:
            t_tags += '%s, ' % tag    
        
        self.tags = t_tags;
        self.d_tags = t_tags;
        

        # convert approx date to real one
        ad = self.releasedate_approx
        try:
            ad_y = ad.year
            ad_m = ad.month
            ad_d = ad.day
            if ad_m == 0:
                ad_m = 1        
            if ad_d == 0:
                ad_d = 1
            
            rd = datetime.strptime('%s/%s/%s' % (ad_y, ad_m, ad_d), '%Y/%m/%d')
            self.releasedate = rd
        except:
            self.releasedate = None
        
        super(Release, self).save(*args, **kwargs)
Esempio n. 2
0
    def save(self, *args, **kwargs):

        self.clear_cache_file()
        unique_slugify(self, self.name)

        # update d_tags
        t_tags = ''
        for tag in self.tags:
            t_tags += '%s, ' % tag

        self.tags = t_tags
        self.d_tags = t_tags

        # convert approx date to real one
        ad = self.releasedate_approx
        try:
            ad_y = ad.year
            ad_m = ad.month
            ad_d = ad.day
            if ad_m == 0:
                ad_m = 1
            if ad_d == 0:
                ad_d = 1

            rd = datetime.strptime('%s/%s/%s' % (ad_y, ad_m, ad_d), '%Y/%m/%d')
            self.releasedate = rd
        except:
            self.releasedate = None

        super(Release, self).save(*args, **kwargs)
Esempio n. 3
0
    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)

        t_tags = ''
        for tag in self.tags:
            t_tags += '%s, ' % tag

        self.tags = t_tags
        self.d_tags = t_tags

        super(Distributor, self).save(*args, **kwargs)
Esempio n. 4
0
    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)

        t_tags = ''
        for tag in self.tags:
            t_tags += '%s, ' % tag

        self.tags = t_tags
        self.d_tags = t_tags

        super(Distributor, self).save(*args, **kwargs)
Esempio n. 5
0
 def save(self, *args, **kwargs):
     unique_slugify(self, self.name)
     
     # update d_tags
     t_tags = ''
     for tag in self.tags:
         t_tags += '%s, ' % tag    
     
     self.tags = t_tags;
     self.d_tags = t_tags;
     
     super(Artist, self).save(*args, **kwargs)
Esempio n. 6
0
    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)

        # update d_tags
        t_tags = ''
        for tag in self.tags:
            t_tags += '%s, ' % tag

        self.tags = t_tags
        self.d_tags = t_tags

        super(Label, self).save(*args, **kwargs)
Esempio n. 7
0
 def save(self, *args, **kwargs):
     unique_slugify(self, self.name)
     
     # update d_tags
     """
     t_tags = ''
     for tag in self.tags:
         t_tags += '%s, ' % tag    
     
     self.tags = t_tags
     self.d_tags = t_tags
     """
     
     super(Label, self).save(*args, **kwargs)
    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)

        if self.type:
            self.type = self.type.lower()
        
        # update d_tags
        """
        t_tags = ''
        for tag in self.tags:
            t_tags += '%s, ' % tag    
        
        self.tags = t_tags
        self.d_tags = t_tags
        """

        super(Artist, self).save(*args, **kwargs)
Esempio n. 9
0
    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)

        if self.type:
            self.type = self.type.lower()
        """
        TODO: implement otherwise
        there is a special-case artist called "Various Artists" that should only exist once.
        in the case we - for whatever unplanned reason - there is a duplicate coming in we
        add a counter to the name ensure uniqueness.
        """

        if self.name == 'Various Artists' and self.pk is None:
            log.warning('attempt to create "Various Artists"')
            original_name = self.name
            i = 1
            while Artist.objects.filter(name=self.name).count() > 0:
                self.name = u'%s %s' % (original_name, i)
                i += 1

        super(Artist, self).save(*args, **kwargs)
Esempio n. 10
0
    def save(self, *args, **kwargs):
        unique_slugify(self, self.name)

        if self.type:
            self.type = self.type.lower()

        """
        TODO: implement otherwise
        there is a special-case artist called "Various Artists" that should only exist once.
        in the case we - for whatever unplanned reason - there is a duplicate coming in we
        add a counter to the name ensure uniqueness.
        """

        if self.name == 'Various Artists' and self.pk is None:
            log.warning('attempt to create "Various Artists"')
            original_name = self.name
            i = 1
            while Artist.objects.filter(name=self.name).count() > 0:
                self.name = u'%s %s' % (original_name, i)
                i += 1

        super(Artist, self).save(*args, **kwargs)
Esempio n. 11
0
 def save(self, *args, **kwargs):
     unique_slugify(self, self.name)
     super(Label, self).save(*args, **kwargs)
Esempio n. 12
0
    def save(self, *args, **kwargs):

        # Assign a default license
        """
         - not applying default license anymore
         - applying default license again: #898
        """
        if not self.license:
            try:
                license = License.objects.filter(is_default=True)[0]
                self.license = license
                log.debug('applied default license: %s' % license.name)
            except Exception as e:
                log.warning('unable to apply default license: {}'.format(e))


        self.master_changed = False
        if self.uuid is not None:
            try:
                orig = Media.objects.filter(uuid=self.uuid)[0]
                if orig.master != self.master:
                    self.master_changed = True
            except:
                pass

        if self.master_changed:
            self.process_master_info()

        # check if master changed. if yes we need to reprocess the cached files
        if self.pk is not None:

            try:
                orig = Media.objects.filter(pk=self.pk)[0]
                if orig.master != self.master:
                    log.info('Media id: %s - Master changed from "%s" to "%s"' % (self.pk, orig.master, self.master))

                    # `_master_changed` can be / is used in signal listeners
                    self._master_changed = True

                    # reset processing flags
                    self.fprint_ingested = None

                    # set 'original filename'
                    if not self.original_filename and self.master.name:
                        try:
                            self.original_filename = self.master.name[0:250]
                        except Exception as e:
                            log.warning('unable to update original_filename on media: {}'.format(self.pk))

            except Exception as e:
                log.warning('unable to update master: {}'.format(e))

        if self.version:
            self.version = self.version.lower()

        if self.mediatype:
            self.mediatype = self.mediatype.lower()


        # sha1 for quick duplicate checks
        if self.master and not self.master_sha1:
            self.master_sha1 = self.generate_sha1()
        else:
            self.master_sha1 = None

        unique_slugify(self, self.name)

        # pretty of ugly, clean empty relations
        for ea in MediaExtraartists.objects.filter(media__pk=self.pk):
            try:
                if not ea.artist:
                    ea.delete()
            except:
                pass

        # # TODO: remove! just for testing!
        # self._master_changed = True

        super(Media, self).save(*args, **kwargs)
Esempio n. 13
0
                base_filesize = None
                base_duration = None
                self.processed = 2

            self.base_format = iext
            self.base_bitrate = base_bitrate
            self.base_samplerate = base_samplerate
            self.base_filesize = base_filesize
            self.base_duration = base_duration

        if self.master:
            self.master_sha1 = self.generate_sha1()
        else:
            self.master_sha1 = None

        unique_slugify(self, self.name)

        # update d_tags
        t_tags = ""
        for tag in self.tags:
            t_tags += "%s, " % tag

        self.tags = t_tags
        self.d_tags = t_tags

        super(Media, self).save(*args, **kwargs)


try:
    tagging.register(Media)
except:
Esempio n. 14
0
 def save(self, *args, **kwargs):
     unique_slugify(self, self.name)
     super(Label, self).save(*args, **kwargs)
Esempio n. 15
0
    def save(self, *args, **kwargs):

        # Assign a default license
        """
         - not applying default license anymore
         - applying default license again: #898
        """
        if not self.license:
            try:
                license = License.objects.filter(is_default=True)[0]
                self.license = license
                log.debug('applied default license: %s' % license.name)
            except Exception as e:
                log.warning('unable to apply default license: {}'.format(e))

        self.master_changed = False
        if self.uuid is not None:
            try:
                orig = Media.objects.filter(uuid=self.uuid)[0]
                if orig.master != self.master:
                    self.master_changed = True
            except:
                pass

        if self.master_changed:
            self.process_master_info()

        # check if master changed. if yes we need to reprocess the cached files
        if self.pk is not None:

            try:
                orig = Media.objects.filter(pk=self.pk)[0]
                if orig.master != self.master:
                    log.info(
                        'Media id: %s - Master changed from "%s" to "%s"' %
                        (self.pk, orig.master, self.master))

                    # reset processing flags
                    self.fprint_ingested = None

                    # set 'original filename'
                    if not self.original_filename and self.master.name:
                        try:
                            self.original_filename = self.master.name[0:250]
                        except Exception as e:
                            log.warning(
                                'unable to update original_filename on media: {}'
                                .format(self.pk))

            except Exception as e:
                log.warning('unable to update master: {}'.format(e))

        if self.version:
            self.version = self.version.lower()

        if self.mediatype:
            self.mediatype = self.mediatype.lower()

        # sha1 for quick duplicate checks
        if self.master and not self.master_sha1:
            self.master_sha1 = self.generate_sha1()
        else:
            self.master_sha1 = None

        unique_slugify(self, self.name)

        # pretty of ugly, clean empty relations
        for ea in MediaExtraartists.objects.filter(media__pk=self.pk):
            try:
                if not ea.artist:
                    ea.delete()
            except:
                pass

        super(Media, self).save(*args, **kwargs)
Esempio n. 16
0
                print e
                pass

        try:
            cache_folder = self.folder
        except Exception, e:
            print e
            log.info('Media id: %s - cache folder does not exist' % (self.pk))
            cache_folder = None

        if self.master:
            log.info('Media id: %s - set master path to: %s' %
                     (self.pk, self.master.path))
            self.master_path = self.master.path

        unique_slugify(self, self.name)
        super(Media, self).save(*args, **kwargs)


# register
post_save.connect(library_post_save, sender=Media)


# media post save
def media_post_save(sender, **kwargs):
    log = logging.getLogger('alibrary.mediamodels.media_post_save')
    obj = kwargs['instance']

    print "media_post_save - PROCESSED?:",
    print obj.processed