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


Python Query.getArtists方法代码示例

本文整理汇总了Python中musicbrainz2.webservice.Query.getArtists方法的典型用法代码示例。如果您正苦于以下问题:Python Query.getArtists方法的具体用法?Python Query.getArtists怎么用?Python Query.getArtists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在musicbrainz2.webservice.Query的用法示例。


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

示例1: __init__

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtists [as 别名]
class mbzAPI:
    def __init__(self):
        self.q = Query()

    def findArtists(self, artist, limit = 20):
        try:
            aFilter = ArtistFilter(artist, limit)
            return self.q.getArtists(aFilter)
        except WebServiceError, e:
            # Logging Need
            return None
开发者ID:masterx2,项目名称:VKD,代码行数:13,代码来源:mbrainzApi.py

示例2: getArtists

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtists [as 别名]
	def getArtists(self,filter=filter) :
		p = md5.new(pickle.dumps(filter)).hexdigest()
		cache_file = os.path.join(CACHE_DIR,'artist_q',p)
		if os.path.exists(cache_file) :
			instream = open(cache_file,"r")
			toret = pickle.loads(instream.read())
			instream.close()
			return toret
		else :
			self.throttle()
			toret = Query.getArtists(self,filter=filter)
			outstream = open(cache_file,"w")
			outstream.write(pickle.dumps(toret))
			outstream.close()
			return toret
开发者ID:apassant,项目名称:motools,代码行数:17,代码来源:CachedMBZQuery.py

示例3: main

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtists [as 别名]
def main(argv=None):
	if argv==None:
		argv=sys.argv
	
	q = Query()
	
	conn = sqlite3.connect('db/mu_trumps.sqlite3')
	c = conn.cursor()
	insert_cursor = conn.cursor()
	c.execute('select * from artists')
	
	for artist_id, created, modified, artist_name, artist_url in c:
		try:
			# Search for all artists matching the given name. Limit the results
			# to the best match. 
			f = ArtistFilter(name=artist_name, limit=5)
			artistResults = q.getArtists(f)
		except WebServiceError, e:
			print 'Error:', e
			if "HTTP Error 503" in str(e):
				print "taking a rest..."
				sleep(SLEEP_TIME*10)
			continue
		try:
			mbz_id = artistResults[0].artist.id
		except IndexError:
			print "Could not find a musicbrainz id for the artist", artist_name, "moving on..."
			continue
		if VERBOSE:
			print "For artist", artist_name, "found id", artist_id
		try:
			# The result should include all official albums.
			#
			inc = ws.ArtistIncludes(
				releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM),
				tags=True, releaseGroups=True)
			artist = q.getArtistById(mbz_id, inc)
		except ws.WebServiceError, e:
			print 'Error:', e
			if "HTTP Error 503" in str(e):
				print "taking a rest..."
				sleep(SLEEP_TIME*10)
			continue
开发者ID:jcoglan,项目名称:mu_trumps,代码行数:45,代码来源:populate_release_data.py

示例4: get_musicbrainz_id

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtists [as 别名]
 def get_musicbrainz_id(self):
     """
     Retrieve the MusicBrainz id for this artist and save it on the
     model.
     """
     # Make sure the useful bits of the musicbrainz2 package have been
     # imported.
     try:
         Query, ArtistFilter
     except NameError:
         return False
     # Query MusicBrainz.
     artist_filter = ArtistFilter(name=self.name)
     query = Query()
     try:
         artist = query.getArtists(artist_filter)[0].artist
         self.mbid = artist.id.rsplit("/", 1)[1]
         self.save()
     except (IndexError, AttributeError):
         return False
开发者ID:flother,项目名称:gigs,代码行数:22,代码来源:models.py

示例5: getArtists

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtists [as 别名]
    def getArtists(self, name, date = None, disambiguation = None):
        q = Query()

        if disambiguation:
            disPattern = re.compile(disambiguation, re.I)
        else:
            disPattern = None

        offset = 0
        limit = 100
        artistResults = set()
        while True:
            try:
                f = ArtistFilter(name = name, offset = offset, limit = limit)
                results = q.getArtists(f)
            except WebServiceError, e:
                raise SourceError

            results = filter(lambda res: res.getScore() == 100, results)
            # use filtered count because resulsts are score-ordered
            count = len(results)

            results = filter(lambda res: 
                    (not date or res.getArtist().getBeginDate() == date)
                    and ( not disPattern or
                        disPattern.search(res.getArtist().getDisambiguation()) ),
                    results)

            for r in results:
                ar = ArtistResult(name = r.getArtist().getName(),
                        date = r.getArtist().getBeginDate(),
                        disambiguation = disambiguation)
                        # use original disambiguation cause it'll be used in 
                        # artist's comparation

                ar.setKey(MusicbrainzSource._sourceName, r.getArtist().getId())
                artistResults.add(ar)

            if count < limit:
                break
            offset += count
开发者ID:xffox,项目名称:relcol,代码行数:43,代码来源:musicbrainz_source.py

示例6: len

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtists [as 别名]
logger.setLevel(logging.ERROR)
sys.stdout = codecs.getwriter('utf8')(sys.stdout) # workaround for pipes

if len(sys.argv) < 2:
	print "Usage:", os.path.basename(sys.argv[0]), "'artist name' [offset]"
	sys.exit(1)

q = Query()

try:
	# Search for all artists matching the given name. Limit the results
	# to the 5 best matches. The offset parameter could be used to page
	# through the results.
	#
	f = ArtistFilter(name=sys.argv[1], limit=10)
	artistResults = q.getArtists(f)
except WebServiceError, e:
	print 'Error:', e
	sys.exit(1)

if len(sys.argv) > 2:
	artistResults = [artistResults[int(sys.argv[2])]]
else:
	artistResults = [artistResults[0]]
	
tracks_ids = []
for result in artistResults:
	artist_name = result.artist
	releases = []
	for rtype in [m.Release.TYPE_ALBUM, m.Release.TYPE_SINGLE, m.Release.TYPE_COMPILATION, m.Release.TYPE_REMIX]:
		artist = q.getArtistById(artist_name.id, ArtistIncludes(
开发者ID:DuloT34,项目名称:Talho,代码行数:33,代码来源:dsp.py

示例7: Query

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtists [as 别名]
import musicbrainz2.webservice as ws
import musicbrainz2.model as model

# Notifo API settings
USERNAME = ""
API_KEY = ""

# NZBMatrix Account Details
#API_URL = "http://api.nzbmatrix.com/v1.1/search.php?search=" + searchTerm + #"&catid=22&age=800&username=burningfire&apikey=75390295cf99a1db49c9314c86061405"

connection = sqlite3.connect('musicSearch.db')
cursor = connection.cursor()

q = Query()
query = ArtistFilter("Streetlight Manifesto", limit = 2)
artistResults = q.getArtists(query)

path = "C:\Users\Mongo\Music\iTunes\iTunes Media\Music"
unknown = ".+unknown.+"

itunesArtist = os.listdir(path)
artistExists = 0

def findArtist():
    artistName = cursor.execute('SELECT ArtistName FROM Artists')
    
    for i in itunesArtist:
        try:
            filter = ArtistFilter(i, limit = 2)
            artistResults = q.getArtists(filter)
        except WebServiceError, e:
开发者ID:mongo527,项目名称:MusicSearch,代码行数:33,代码来源:musicSearch.py


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