• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python musicbrainzngs.search_artists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

def main(*argv):
	m.set_useragent("applicatiason", "0.201", "http://recabal.com")
	m.set_hostname("localhost:8080")
	m.auth("vm", "musicbrainz")
	
	f = open(sys.argv[1],'r')
	for line in f.xreadlines():
		
		line = line.strip();
		lifeSpanString = "false,false"

		art_dict = m.search_artists(artist=line,limit=1,strict=True,tag="jazz")
		
		if art_dict['artist-count']!=0:
			lifeSpanString = getLifeSpan(art_dict)
			
		else:
			art_dict = m.search_artists(artist=line,limit=1,strict=True)
			if art_dict['artist-count']!=0:
				lifeSpanString = getLifeSpan(art_dict)			

		print line+","+lifeSpanString
				
	f.close()
开发者ID:precabal,项目名称:musiclopedia,代码行数:24,代码来源:retrieveArtist.py


示例17: searchMusicBrainzArtist

def searchMusicBrainzArtist(artist):
	"""searchMusicBrainzArtist takes an artist name as a string and returns a list of artists
	that match the searched name."""
	
	result = musicbrainzngs.search_artists(artist=artist, limit=5)
	# On success, result is a dictionary with a single key:
	# "artist-list", which is a list of dictionaries.
	results = []
	if not result['artist-list']:
		return results
	for artist in result['artist-list']:
		
		# If we haven't seen this artist name yet, add it to the return list
		if artist['name'] not in results:
			results.append(artist['name'])
	return results
开发者ID:keagon3,项目名称:greymatterreview,代码行数:16,代码来源:main.py


示例18: bulk_import_artist

def bulk_import_artist():
    terms = [
        # 'bb king',
        # 'elvis',
        # 'black sabbath',
        # 'fugazi',
        # 'minor threat',
        # 'converge',
        # '\'68',
        # 'old man gloom',
        # 'citizen',
        # 'blues brothers',
        # 'cult of luna',
        # 'our lady',
        # 'so long forgotten',
        # 'cash',
        # 'z',
        # 'ramones',
        # 'kesha',
        # 'nine inch nails',
        # 'bill nye',
        # 'my bloody valentine',
        # 'ride',
        # 'slabdragger',
        # 'slowdive',
        #  'oasis',
        # 'reo',
        # 'cloakroom',
        # 'underoath',
        # 'brand new',
        # 'taking back sunday',
        # 'the cure',
        # 'jesu',
        # 'jesus and the mary chain',
        # 'zozobra',
        # 'cave in',
        # 'led zeppelin',
        'pity sex',
        'looming', 
        'our lady',
    ]
    for search in terms:
        print 'searching {}'.format(search)
        result = mb.search_artists(artist=search, type="group", country="US")
        for artist in result['artist-list']:
            import_artist(artist)
开发者ID:francisng0201,项目名称:recordstore,代码行数:46,代码来源:import.py


示例19: get_artists_for_city

def get_artists_for_city(location):
    #TODO add celery here
    city = location.name
    musicbrainzngs.set_useragent("CultureRadio", 1)
    response = musicbrainzngs.search_artists(area=city, beginarea=city, endarea=city)
    response_artist_list = response.get('artist-list')
    for artist in response_artist_list:
        spotify_artists = get_spotify_artists_for_name(artist.get('name'))
        if len(spotify_artists) == 0:
            continue
        for spotify_artist in spotify_artists:
            uri, created = SpotifyData.objects.get_or_create(uri=spotify_artist.get('uri'))
            uri.save()
            a, created = Artist.objects.get_or_create(name=spotify_artist.get('name'), spotifyUri=uri)
            a.location.add(location)
            a.save()
            get_tracks_for_artist(a)
开发者ID:Scriptkiddi,项目名称:CultureRadio,代码行数:17,代码来源:views.py


示例20: test_search_artists

    def test_search_artists(self):
        musicbrainzngs.search_artists("Dynamo Go")
        self.assertEqual("http://musicbrainz.org/ws/2/artist/?query=Dynamo+Go", self.opener.get_url())

        musicbrainzngs.search_artists(artist="Dynamo Go")
        expected_query = 'artist:(dynamo go)'
        expected = 'http://musicbrainz.org/ws/2/artist/?query=%s' % musicbrainzngs.compat.quote_plus(expected_query)
        self.assertEquals(expected, self.opener.get_url())

        # Invalid query field
        with self.assertRaises(musicbrainzngs.InvalidSearchFieldError):
            musicbrainzngs.search_artists(foo="value")
开发者ID:alastair,项目名称:python-musicbrainzngs,代码行数:12,代码来源:test_search.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python musicbrainzngs.search_recordings函数代码示例发布时间:2022-05-27
下一篇:
Python musicbrainzngs.get_release_by_id函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap