コード例 #1
0
def allmusic_genre(album, metadata, release):
    if metadata["albumartist"] != "Various Artists":
        albumartist = translate_artist(metadata["artist"], metadata["artistsort"])
    else:
        albumartist = metadata["albumartist"]
    albumtitle = clean_album_title(metadata["album"])
    albumartist = unicode(ununicode(albumartist))
    albumtitle = unicode(ununicode(albumtitle))
    print " * Looking for " + albumtitle + " by " + albumartist
    print " * Sending album search request",
    album._requests += 1
    album.tagger.xmlws.add_task(partial(album_search, album, metadata, albumtitle, albumartist), position=1)
コード例 #2
0
ファイル: track.py プロジェクト: lalinsky/picard-debian
    def _customize_metadata(self, ignore_tags=None):
        tm = self.metadata

        # 'Translate' artist name
        if self.config.setting["translate_artist_names"]:
            tm["artist"] = translate_artist(tm["artist"], tm["artistsort"])

        # Custom VA name
        if tm["musicbrainz_artistid"] == VARIOUS_ARTISTS_ID:
            tm["artistsort"] = tm["artist"] = self.config.setting["va_name"]

        if self.config.setting["folksonomy_tags"]:
            if ignore_tags is None:
                ignore_tags = [s.strip() for s in self.config.setting["ignore_tags"].split(",")]
            self._convert_folksonomy_tags_to_genre(ignore_tags)

        # Convert Unicode punctuation
        if self.config.setting["convert_punctuation"]:
            tm.apply_func(asciipunct)
コード例 #3
0
ファイル: track.py プロジェクト: lalinsky/picard
    def _customize_metadata(self, ignore_tags=None):
        tm = self.metadata

        # 'Translate' artist name
        if self.config.setting['translate_artist_names']:
            tm['artist'] = translate_artist(tm['artist'], tm['artistsort'])

        # Custom VA name
        if tm['musicbrainz_artistid'] == VARIOUS_ARTISTS_ID:
            tm['artistsort'] = tm['artist'] = self.config.setting['va_name']

        if self.config.setting['folksonomy_tags']:
            if ignore_tags is None:
                ignore_tags = [s.strip() for s in self.config.setting['ignore_tags'].split(',')]
            self._convert_folksonomy_tags_to_genre(ignore_tags)

        # Convert Unicode punctuation
        if self.config.setting['convert_punctuation']:
            tm.apply_func(asciipunct)
コード例 #4
0
ファイル: mbxml.py プロジェクト: lalinsky/picard
def _relations_to_metadata(relation_lists, m, config):
    for relation_list in relation_lists:
        if relation_list.target_type == 'artist':
            for relation in relation_list.relation:
                value = relation.artist[0].name[0].text
                if config.setting['translate_artist_names']:
                    value = translate_artist(value, relation.artist[0].sort_name[0].text)
                reltype = relation.type
                attribs = []
                if 'attribute_list' in relation.children:
                    attribs = [a.text for a in relation.attribute_list[0].attribute]
                if reltype == 'vocal':
                    name = 'performer:' + ' '.join([_parse_attributes(attribs), 'vocal']).strip()
                elif reltype == 'instrument':
                    name = 'performer:' + _parse_attributes(attribs)
                elif reltype == 'performer':
                    name = 'performer:' + _parse_attributes(attribs)
                else:
                    try:
                        name = _artist_rel_types[reltype]
                    except KeyError:
                        continue
                if value not in m[name]:
                    m.add(name, value)
        elif relation_list.target_type == 'work':
            for relation in relation_list.relation:
                if relation.type == 'performance':
                    work = relation.work[0]
                    if 'relation_list' in work.children:
                        _relations_to_metadata(work.relation_list, m, config)
        elif relation_list.target_type == 'url':
            for relation in relation_list.relation:
                if relation.type == 'amazon asin':
                    url = relation.target[0].text
                    match = AMAZON_ASIN_URL_REGEX.match(url)
                    if match is not None and 'asin' not in m:
                        m['asin'] = match.group(2)
コード例 #5
0
ファイル: album.py プロジェクト: lalinsky/picard
    def _parse_release(self, document):
        self.log.debug("Loading release %r", self.id)

        release_node = document.metadata[0].release[0]
        if release_node.id != self.id:
            album = self.tagger.get_album_by_id(release_node.id)
            self.tagger.albumids[self.id] = release_node.id
            self.id = release_node.id
            if album:
                album.match_files(self.unmatched_files.files)
                album.update()
                self.tagger.remove_album(self)
                self.log.debug("Release %r already loaded", self.id)
                return False

        # Get release metadata
        m = self._new_metadata
        m.length = 0
        release_to_metadata(release_node, m, config=self.config, album=self)

        self.format_str = media_formats_from_node(release_node.medium_list[0])
        self.rgid = release_node.release_group[0].id
        if self._discid:
            m['musicbrainz_discid'] = self._discid

        # 'Translate' artist name
        if self.config.setting['translate_artist_names']:
            m['albumartist'] = translate_artist(m['albumartist'], m['albumartistsort'])

        # Custom VA name
        if m['musicbrainz_albumartistid'] == VARIOUS_ARTISTS_ID:
            m['albumartistsort'] = m['albumartist'] = self.config.setting['va_name']

        ignore_tags = [s.strip() for s in self.config.setting['ignore_tags'].split(',')]
        first_artist = None
        compilation = False
        track_counts = []

        m['totaldiscs'] = release_node.medium_list[0].count

        self._metadata_processors = [partial(run_album_metadata_processors, self, m, release_node)]

        for medium_node in release_node.medium_list[0].medium:
            mm = Metadata()
            mm.copy(m)
            medium_to_metadata(medium_node, mm)
            track_counts.append(mm['totaltracks'])

            for track_node in medium_node.track_list[0].track:
                t = Track(track_node.recording[0].id, self)
                self._new_tracks.append(t)

                # Get track metadata
                tm = t.metadata
                tm.copy(mm)
                track_to_metadata(track_node, t, self.config)
                m.length += tm.length

                artist_id = tm['musicbrainz_artistid']
                if compilation is False:
                    if first_artist is None:
                        first_artist = artist_id
                    if first_artist != artist_id:
                        compilation = True
                        for track in self._new_tracks:
                            track.metadata['compilation'] = '1'
                else:
                    tm['compilation'] = '1'

                t._customize_metadata(ignore_tags)
                plugins = partial(run_track_metadata_processors, self, tm, release_node, track_node)
                self._metadata_processors.append(plugins)

        m["~totalalbumtracks"] = str(sum(map(int, track_counts)))
        self.tracks_str = " + ".join(track_counts)

        return True
コード例 #6
0
 def test_kanji2(self):
     self.failUnlessEqual(u"Ayumi Hamasaki & Keiko", util.translate_artist(u"浜崎あゆみ & KEIKO", u"Hamasaki, Ayumi & Keiko"))
     self.failIfEqual(u"浜崎あゆみ & KEIKO", util.translate_artist(u"浜崎あゆみ & KEIKO", u"Hamasaki, Ayumi & Keiko"))
     self.failIfEqual(u"Hamasaki, Ayumi & Keiko", util.translate_artist(u"浜崎あゆみ & KEIKO", u"Hamasaki, Ayumi & Keiko"))
コード例 #7
0
 def test_kanji(self):
     self.failUnlessEqual(u"Tetsuya Komuro", util.translate_artist(u"小室哲哉", u"Komuro, Tetsuya"))
     self.failIfEqual(u"Komuro, Tetsuya", util.translate_artist(u"小室哲哉", u"Komuro, Tetsuya"))
     self.failIfEqual(u"小室哲哉", util.translate_artist(u"小室哲哉", u"Komuro, Tetsuya"))
コード例 #8
0
 def test_latin(self):
     self.failUnlessEqual(u"Jean Michel Jarre", util.translate_artist(u"Jean Michel Jarre", u"Jarre, Jean Michel"))
     self.failIfEqual(u"Jarre, Jean Michel", util.translate_artist(u"Jean Michel Jarre", u"Jarre, Jean Michel"))
コード例 #9
0
 def test_cyrillic(self):
     self.failUnlessEqual(U"Pyotr Ilyich Tchaikovsky", util.translate_artist(u"Пётр Ильич Чайковский", u"Tchaikovsky, Pyotr Ilyich"))
     self.failIfEqual(u"Tchaikovsky, Pyotr Ilyich", util.translate_artist(u"Пётр Ильич Чайковский", u"Tchaikovsky, Pyotr Ilyich"))
     self.failIfEqual(u"Пётр Ильич Чайковский", util.translate_artist(u"Пётр Ильич Чайковский", u"Tchaikovsky, Pyotr Ilyich"))