当前位置: 首页>>代码示例>>Python>>正文


Python musicbrainzngs.search_artists函数代码示例

本文整理汇总了Python中musicbrainzngs.search_artists函数的典型用法代码示例。如果您正苦于以下问题:Python search_artists函数的具体用法?Python search_artists怎么用?Python search_artists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了search_artists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_artist_tracks_from_musicbrainz

def get_artist_tracks_from_musicbrainz(artist):
    """
    Create Album, Track, and Solo records for artists we find in the MusicBrainzNGS API

    :param artist: an artist's name as a string to search for
    :return: Queryset of Solos
    """
    search_results = mb.search_artists(artist)
    best_result = search_results['artist-list'][0]

    if 'jazz' not in [d['name'] for d in best_result['tag-list']]:
        return Solo.objects.none()

    instrument = Solo.get_instrument_from_musicbrainz_tags(best_result['tag-list'])

    for album_dict in mb.browse_releases(best_result['id'], includes=['recordings'])['release-list']:

        album = Album.objects.create(name=album_dict['title'], artist=artist, slug=slugify(album_dict['title']))

        for track_dict in album_dict['medium-list'][0]['track-list']:
            track = Track.objects.create(album=album, name=track_dict['recording']['title'],
                                         track_number=track_dict['position'],
                                         slug=slugify(track_dict['recording']['title']))

            Solo.objects.create(track=track, artist=artist, instrument=instrument, slug=slugify(artist))

    return Solo.objects.filter(artist=artist)
开发者ID:horace8,项目名称:jmad,代码行数:27,代码来源:tasks.py

示例2: find_artist_by_name

def find_artist_by_name(name, limit=10, wanted_keys=('name', 'id', 'country', 'ext:score', 'type')):
    with musicbrainz_lock:
        params = {'artist': name.lower(), 'alias': name.lower()}
        search_results = musicbrainzngs.search_artists(limit=limit, **params)['artist-list']
        sorted_by_score = sorted(search_results, cmp=lambda x, y: max(x, y), key=lambda d: int(d['ext:score']))
        # return a list of dicts containing only the wanted values
        return [{k: v for k, v in d.items() if k in wanted_keys} for d in sorted_by_score]
开发者ID:omerbenamram,项目名称:headphones2,代码行数:7,代码来源:musicbrainz.py

示例3: add_musicbrainz_artist

def add_musicbrainz_artist(cache, item):
    artist_name = item['artist']

    found, entry = cache.lookup('artist:{}'.format(artist_name))

    if found:
        log.debug("Found artist:{} in cache".format(artist_name))
    else:
        log.debug("Didn't find artist:{} in cache, running remote query".format(artist_name))
        result = musicbrainzngs.search_artists(artist=artist_name)['artist-list']
        if result:
            entry = result[0]
        else:
            entry = None

        cache.store('artist:{}'.format(artist_name), entry)

    if entry is None:
        warnings = item.get('musicbrainz.warnings', [])
        warnings += ["Unable to find artist on musicbrainz"]
        item['musicbrainz.warnings'] = warnings
    else:
        item['musicbrainz.artist'] = entry['id']
        if 'country' in entry:
            item['musicbrainz.artist.country'] = entry['country']

    return item
开发者ID:ssssam,项目名称:calliope,代码行数:27,代码来源:__init__.py

示例4: fetch_artist

def fetch_artist(artist_mbid, **kwarg):
    """fetch artist info from musicBrainz
    """
    result = musicbrainzngs.search_artists(query='', limit=1, offset=None, strict=False, arid = artist_mbid)
    artist_info = {};
    if 'artist-list' in result:
        if 'type' in result['artist-list'][0]:
            artist_info['artist_type'] = result['artist-list'][0]['type']
        else:
            artist_info['artist_type'] = ''
        if 'gender' in result['artist-list'][0]:
            artist_info['artist_gender'] = result['artist-list'][0]['gender']
        else:
            artist_info['artist_gender'] = ''
        if 'begin-area' in result['artist-list'][0]:
            artist_info['artist_begin_area'] = result['artist-list'][0]['begin-area']['name']
        else:
            artist_info['artist_begin_area'] = ''
        if 'country' in result['artist-list'][0]:
            artist_info['artist_country'] = result['artist-list'][0]['country']
        else:
            artist_info['artist_country'] = ''
        if 'life-span' in result['artist-list'][0] and 'begin' in result['artist-list'][0]['life-span']:
            artist_info['artist_begin_date'] = result['artist-list'][0]['life-span']['begin']
        else:
            artist_info['artist_begin_date'] = ''
        if 'tag-list' in result['artist-list'][0]:
            tag_list = result['artist-list'][0]['tag-list']
            artist_info['artist_tags'] = ';'.join([tag['name'] for tag in tag_list])
        else:
            artist_info['artist_tags'] = ''
    return artist_info
开发者ID:tonyhong272,项目名称:MusicML,代码行数:32,代码来源:recordingSearch.py

示例5: assign_songs

	def assign_songs(self, cleaned_tweets):
		print "Matching songs to tweets"
		cleaner_tweets = []
		tweets_used = 0
		for cleaned_tweet in cleaned_tweets:
			if " by " in cleaned_tweet['text']:
				split_text = cleaned_tweet['text'].split(' by ')
				artists_list = mbz.search_artists(split_text[0])
				try:
					mbID = artists_list['artist-list'][0]['id']
					works = mbz.search_recordings(query=split_text[0],
															arid=mbID)
					tweet = dict()	
					tweet['song'] = works['recording-list'][0]['title']
					tweet['text'] = cleaned_tweet['text']
					tweet['artist'] = artists_list['artist-list'][0]['name']
					tweet['musicbrainzID'] = works['recording-list'][0]['id']
					tweet['userID'] = cleaned_tweet['userID']
					cleaner_tweets.append(tweet)
					tweets_used += 1

				except (UnicodeEncodeError, IndexError):
					print "Unable to find song/artist"
		
		print "Tweets used: %s" % (tweets_used)
		return cleaner_tweets
开发者ID:zcarciu,项目名称:Python-Portfolio,代码行数:26,代码来源:MusicRecommender.py

示例6: findArtist

def findArtist(name, limit=1):
    artistlist = []
    artistResults = None

    chars = set('!?*-')
    if any((c in chars) for c in name):
        name = '"' + name + '"'

    criteria = {'artist': name.lower()}

    with mb_lock:
        try:
            artistResults = musicbrainzngs.search_artists(limit=limit, **criteria)['artist-list']
        except ValueError as e:
            if "at least one query term is required" in e.message:
                logger.error(
                    "Tried to search without a term, or an empty one. Provided artist (probably emtpy): %s",
                    name)
                return False
            else:
                raise
        except musicbrainzngs.WebServiceError as e:
            logger.warn('Attempt to query MusicBrainz for %s failed (%s)' % (name, str(e)))
            mb_lock.snooze(5)

    if not artistResults:
        return False
    for result in artistResults:
        if 'disambiguation' in result:
            uniquename = unicode(result['sort-name'] + " (" + result['disambiguation'] + ")")
        else:
            uniquename = unicode(result['sort-name'])
        if result['name'] != uniquename and limit == 1:
            logger.info(
                'Found an artist with a disambiguation: %s - doing an album based search' % name)
            artistdict = findArtistbyAlbum(name)
            if not artistdict:
                logger.info(
                    'Cannot determine the best match from an artist/album search. Using top match instead')
                artistlist.append({
                    # Just need the artist id if the limit is 1
                    #    'name':             unicode(result['sort-name']),
                    #    'uniquename':        uniquename,
                    'id': unicode(result['id']),
                    #    'url':                 unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed
                    #    'score':            int(result['ext:score'])
                })
            else:
                artistlist.append(artistdict)
        else:
            artistlist.append({
                'name': unicode(result['sort-name']),
                'uniquename': uniquename,
                'id': unicode(result['id']),
                'url': unicode("http://musicbrainz.org/artist/" + result['id']),
                # probably needs to be changed
                'score': int(result['ext:score'])
            })
    return artistlist
开发者ID:EliasDeVos,项目名称:headphones,代码行数:59,代码来源:mb.py

示例7: searchForArtistByName

def searchForArtistByName(name):
    initializeConnection()

    searchResults = mb.search_artists(artist=name)
    artists = []
    for artist in searchResults['artist-list']:
        artists.append(MusicBrainzArtist(artist['id'], artist['name']))
    return artists
开发者ID:sgottschalk,项目名称:fest_diviner,代码行数:8,代码来源:MusicBrainzDAO.py

示例8: go

 def go(self):
     query = self.query.lower() + '*'
     return {
         'results' : map(lambda artist: {
             'id'  : artist['id'],
             'name' : artist['sort-name']
         }, musicbrainzngs.search_artists(query.encode('utf-8'), limit=10).get('artist-list', []))
     }
开发者ID:mdgweb,项目名称:gigographics,代码行数:8,代码来源:search.py

示例9: search_artist

def search_artist(evt):
    result = m.search_artists(artist=mainwin['searchfield'].value)
    resultList = []
    print("steeb found %s artists" % colored.cyan(len(result["artist-list"])))
    for idx, artist in enumerate(result["artist-list"]):
        resultList.append([artist["name"], artist["id"]])

    lv = mainwin['artistslist']
    lv.items = resultList
开发者ID:napcae,项目名称:steeb,代码行数:9,代码来源:steeb.py

示例10: search_artist

def search_artist(queryArtistname):
    listArtists = mb.search_artists(artist=queryArtistname)['artist-list']
#    check that artists have correct name
    listArtistsRelevantNames = []
    for artist in listArtists:
        # check relevance of artist. TODO: break do offset and limit, not to miss artist 
        if artist['name'] == queryArtistname:
            listArtistsRelevantNames.append(artist)
     
    return listArtistsRelevantNames
开发者ID:georgid,项目名称:musicBrainzTools,代码行数:10,代码来源:Echonest2Abrainz.py

示例11: _request

    def _request(query, artist, album=None, track=None):
        results = None
        if track:
            results = musicbrainzngs.search_recordings(query=query)
        elif album:
            results = musicbrainzngs.search_releases(query=query)
        elif artist:
            results = musicbrainzngs.search_artists(query=query)

        return results
开发者ID:FructusCode,项目名称:website,代码行数:10,代码来源:music.py

示例12: GetMusicBrainz

	def GetMusicBrainz(self):
		mbrainz.set_useragent("Example music app", "0.1", "http://example.com/music")
		result = mbrainz.search_artists(self.name)['artist-list'][0]
		# for result in results:
		#   if int(result['ext:score']) > 75:
		#       break
		#print result
		self.musicbrainz_id = result['id']
		self.mbrainz_cache = mbrainz.get_artist_by_id(self.musicbrainz_id, ['artist-rels', 'url-rels'])['artist']
		if 'url-relation-list' in self.mbrainz_cache:
			self.social_media = self.mbrainz_cache.pop('url-relation-list')
		if 'artist-relation-list' in self.mbrainz_cache:
			self.aliases = self.mbrainz_cache.pop('artist-relation-list')
开发者ID:swist,项目名称:ripple,代码行数:13,代码来源:models.py

示例13: RetrieveArtistsList

def RetrieveArtistsList(outLoc,oset=0,query="type:person"):
    outDoc = open(outLoc,"a")
    art_list = "artist-list"
    art_count = "artist-count"
    alias_list = "alias-list"
    name = "name"
    artists = mb.search_artists(query=query,limit=100)
    offset = oset
    print artists[art_count]
    while offset < artists[art_count]:
        for artist in artists[art_list]:
            outDoc.write(artist[name].encode('UTF-8') + "\n")
            if alias_list in artist:
                for alias in artist[alias_list]:
                    if "alias" in alias:
                        outDoc.write(alias["alias"].encode('UTF-8') + "\n")
        time.sleep(3)
        offset += 100
        print offset
        artists = mb.search_artists(query="type:person",limit=100,offset=offset)
    outDoc.close()
    print "finished"
开发者ID:jackpay,项目名称:RetrieveArtistList,代码行数:22,代码来源:RetrieveArtistList.py

示例14: artist_mbid_find

def artist_mbid_find(artist_name):
    """
    Returns an artist MBID
    """
    artist_name = artist_name.decode('latin-1').encode('ascii', 'asciify')
    mb_artist_list = m.search_artists(artist_name)['artist-list'][0]
    mb_artist_name = mb_artist_list['name'].strip().encode('ascii', 'asciify')
    try: mb_artist_alias = mb_artist_list['alias-list']
    except: mb_artist_alias = ''
    mb_artist_id = mb_artist_list['id']

    
    if mb_artist_name and ((artist_name.lower() == mb_artist_name.lower()) or (artist_name in mb_artist_alias)):
        return mb_artist_id
开发者ID:vigliensoni,项目名称:bbdd_much,代码行数:14,代码来源:mbid_writer.py

示例15: get_artists_by_name

def get_artists_by_name(name):

    artists = dict()
    result = musicbrainzngs.search_artists(artist=name)

    for artist in result['artist-list']:

        artist_name = artist['name']
        artist_mbid = artist['id']

        if artist['ext:score'] == "100":
            artists.update({artist_mbid:artist_name})

    return artists
开发者ID:Sacknuss,项目名称:trollectoR,代码行数:14,代码来源:metadata.py


注:本文中的musicbrainzngs.search_artists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。