本文整理汇总了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
示例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)
示例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