コード例 #1
0
    def inject_metadata(self, format, version):
        
        """
        audiotools.MetaData
        """
        meta = MetaData()
        
        
        """
        prepare metadata object
        """
        # track-level metadata
        meta.track_name = self.name
        meta.track_number = self.tracknumber
        meta.media = 'DIGITAL'
        meta.isrc = self.isrc
        
        

            
        """ Needs fixing...
        for extra_artist in self.extra_artists.all():
            print extra_artist
        meta.performer_name =
        meta.composer_name =
        meta.conductor_name =
        """
        
        # release-level metadata
        if self.release:
            meta.album_name = self.release.name
            meta.catalog = self.release.catalognumber
            meta.track_total = len(self.release.media_release.all())
            
            if self.release.releasedate:
                try:
                    meta.year = str(self.release.releasedate.year)
                    meta.date = str(self.release.releasedate)
                    
                except Exception, e:
                    print e
            
            try:
                
                cover_image = self.release.cover_image if self.release.cover_image else self.release.main_image
                
                if meta.supports_images() and cover_image:
                    for i in meta.images():
                        meta.delete_image(i)
                        
                    opt = dict(size=(200, 200), crop=True, bw=False, quality=80)
                    image = get_thumbnailer(cover_image).get_thumbnail(opt)
                    meta.add_image(get_raw_image(image.path, 0))
                    
            except Exception, e:
                print e
コード例 #2
0
ファイル: process.py プロジェクト: hzlf/openbroadcast
    def inject_metadata(self, path, media):
        
        log = logging.getLogger('util.process.Process.inject_metadata')
        log.debug('inject metadata to: %s' % (path))
        log.debug('source: %s' % (media))

        """
        audiotools.MetaData
        http://audiotools.sourceforge.net/programming/audiotools.html?highlight=set_metadata#audiotools.MetaData
        class audiotools.MetaData([track_name][, track_number][, track_total][, album_name][, artist_name]
        [, performer_name][, composer_name][, conductor_name][, media][, ISRC][, catalog][, copyright]
        [, publisher][, year][, data][, album_number][, album_total][, comment][, images])
        """
        meta = MetaData()


        """
        prepare metadata object
        """
        # track-level metadata
        meta.track_name = media.name
        meta.track_number = media.tracknumber
        meta.media = 'DIGITAL'
        meta.isrc = media.isrc
        meta.genre = 2
    
        
        # release-level metadata
        if media.release:
            meta.album_name = media.release.name
            meta.catalog = media.release.catalognumber
            meta.track_total = len(media.release.media_release.all())
            
            if media.release.releasedate:
                try:
                    meta.year = str(media.release.releasedate.year)
                    meta.date = str(media.release.releasedate)
                    
                except Exception, e:
                    print e
            
            try:
                
                cover_image = media.release.cover_image if media.release.cover_image else media.release.main_image
                
                if meta.supports_images() and cover_image:
                    for i in meta.images():
                        meta.delete_image(i)
                        
                    opt = dict(size=(200, 200), crop=True, bw=False, quality=80)
                    image = get_thumbnailer(cover_image).get_thumbnail(opt)
                    meta.add_image(get_raw_image(image.path, 0))
                    
            except Exception, e:
                print e
コード例 #3
0
    def metadata(self):
        def get_track_metadata(track_node, album_metadata, track_number):
            try:
                #FIXME - not sure if name or sort-name should take precendence
                artist_name = get_xml_text_node(
                    get_xml_nodes(track_node, u'artist')[0], u'name')
            except IndexError:
                artist_name = album_metadata.artist_name

            track_metadata = MetaData(track_name=get_xml_text_node(
                track_node, u'title'),
                                      artist_name=artist_name,
                                      track_number=track_number)

            track_metadata.merge(album_metadata)
            return track_metadata

        try:
            release = self.dom.getElementsByTagName(u'release')[0]
        except IndexError:
            return AlbumMetaData([])

        album_name = get_xml_text_node(release, u'title')

        try:
            #FIXME - not sure if name or sort-name should take precendence
            artist_name = get_xml_text_node(
                get_xml_nodes(release, u'artist')[0], u'name')
        except IndexError:
            artist_name = u''

        try:
            tracks = get_xml_nodes(
                get_xml_nodes(release, u'track-list')[0], u'track')
        except IndexError:
            tracks = []

        album_metadata = MetaData(album_name=album_name,
                                  artist_name=artist_name,
                                  track_total=len(tracks))

        try:
            release_events = get_xml_nodes(release, u'release-event-list')[0]
            event = get_xml_nodes(release_events, u'event')[-1]
            album_metadata.year = event.getAttribute('date')[0:4]
            album_metadata.catalog = event.getAttribute('catalog-number')
        except IndexError:
            pass

        return AlbumMetaData([
            get_track_metadata(track_node=node,
                               album_metadata=album_metadata,
                               track_number=i + 1)
            for (i, node) in enumerate(tracks)
        ])
コード例 #4
0
    def inject_metadata(self, format, version):
        """
        audiotools.MetaData
        """
        meta = MetaData()
        """
        prepare metadata object
        """
        # track-level metadata
        meta.track_name = self.name
        meta.track_number = self.tracknumber
        meta.media = 'DIGITAL'
        meta.isrc = self.isrc
        """ Needs fixing...
        for extra_artist in self.extra_artists.all():
            print extra_artist
        meta.performer_name =
        meta.composer_name =
        meta.conductor_name =
        """

        # release-level metadata
        if self.release:
            meta.album_name = self.release.name
            meta.catalog = self.release.catalognumber
            meta.track_total = len(self.release.media_release.all())

            if self.release.releasedate:
                try:
                    meta.year = str(self.release.releasedate.year)
                    meta.date = str(self.release.releasedate)

                except Exception, e:
                    print e

            try:

                cover_image = self.release.cover_image if self.release.cover_image else self.release.main_image

                if meta.supports_images() and cover_image:
                    for i in meta.images():
                        meta.delete_image(i)

                    opt = dict(size=(200, 200),
                               crop=True,
                               bw=False,
                               quality=80)
                    image = get_thumbnailer(cover_image).get_thumbnail(opt)
                    meta.add_image(get_raw_image(image.path, 0))

            except Exception, e:
                print e
コード例 #5
0
 def incect_metadata(self, path, media):
     
     log = logging.getLogger('util.process.Process.incect_metadata')
     log.debug('incect metadata to: %s' % (path))
     log.debug('source: %s' % (media))
     
     
     """
     audiotools.MetaData
     """
     meta = MetaData()
     
     
     """
     prepare metadata object
     """
     # track-level metadata
     meta.track_name = media.name
     meta.track_number = media.tracknumber
     meta.media = 'DIGITAL'
     meta.isrc = media.isrc
     meta.genre = 2
 
     
     # release-level metadata
     if media.release:
         meta.album_name = media.release.name
         meta.catalog = media.release.catalognumber
         meta.track_total = len(media.release.media_release.all())
         
         if media.release.releasedate:
             try:
                 meta.year = str(media.release.releasedate.year)
                 meta.date = str(media.release.releasedate)
                 
             except Exception, e:
                 print e
         
         try:
             
             cover_image = media.release.cover_image if media.release.cover_image else media.release.main_image
             
             if meta.supports_images() and cover_image:
                 for i in meta.images():
                     meta.delete_image(i)
                     
                 opt = dict(size=(200, 200), crop=True, bw=False, quality=80)
                 image = get_thumbnailer(cover_image).get_thumbnail(opt)
                 meta.add_image(get_raw_image(image.path, 0))
                 
         except Exception, e:
             print e
コード例 #6
0
ファイル: process.py プロジェクト: ppp0/openbroadcast
    def incect_metadata(self, path, media):

        log = logging.getLogger('util.process.Process.incect_metadata')
        log.debug('incect metadata to: %s' % (path))
        log.debug('source: %s' % (media))
        """
        audiotools.MetaData
        """
        meta = MetaData()
        """
        prepare metadata object
        """
        # track-level metadata
        meta.track_name = media.name
        meta.track_number = media.tracknumber
        meta.media = 'DIGITAL'
        meta.isrc = media.isrc
        meta.genre = 2

        # release-level metadata
        if media.release:
            meta.album_name = media.release.name
            meta.catalog = media.release.catalognumber
            meta.track_total = len(media.release.media_release.all())

            if media.release.releasedate:
                try:
                    meta.year = str(media.release.releasedate.year)
                    meta.date = str(media.release.releasedate)

                except Exception, e:
                    print e

            try:

                cover_image = media.release.cover_image if media.release.cover_image else media.release.main_image

                if meta.supports_images() and cover_image:
                    for i in meta.images():
                        meta.delete_image(i)

                    opt = dict(size=(200, 200),
                               crop=True,
                               bw=False,
                               quality=80)
                    image = get_thumbnailer(cover_image).get_thumbnail(opt)
                    meta.add_image(get_raw_image(image.path, 0))

            except Exception, e:
                print e