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


Python Query.getArtistById方法代码示例

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


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

示例1: main

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtistById [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

示例2: len

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtistById [as 别名]
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(
				releases=(m.Release.TYPE_OFFICIAL, rtype),
				tags=True))
	
		releases.extend(artist.getReleases())

	for release in releases:
		sleep(1) # respect TOS
		release = q.getReleaseById(release.id, ReleaseIncludes(artist = True, tracks = True))
		for track in release.tracks:
			name = track.artist.name if track.artist else release.artist.name
			full_title = (name + u" — " + track.title).lower()
			if not full_title in tracks_ids:
				print name, track.title
				if not sys.stdout.isatty():
					print >> sys.stderr, full_title
				tracks_ids.append(full_title)
开发者ID:DuloT34,项目名称:Talho,代码行数:33,代码来源:dsp.py

示例3: len

# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getArtistById [as 别名]
#
#
# Now that you have artist IDs, you can request an artist in more detail, for
# example to display all official albums by that artist. See the 'getartist.py'
# example on how achieve that.
#

q = ws.Query()

try:
	# The result should include all official albums.
	#
	inc = ws.ArtistIncludes(
		releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM),
		tags=True)
	artist = q.getArtistById(result.artist.id, inc)
except ws.WebServiceError, e:
	print 'Error:', e
	sys.exit(1)


print


if len(artist.getReleases()) == 0:
	print "No releases found."

i = 0
releasearr = artist.getReleases()

import re
开发者ID:bh0085,项目名称:programming,代码行数:33,代码来源:artistreleases.py


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