File: getartist.py

package info (click to toggle)
python-musicbrainz2 0.3.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 428 kB
  • ctags: 527
  • sloc: python: 2,301; xml: 724; makefile: 10
file content (66 lines) | stat: -rwxr-xr-x 1,543 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /usr/bin/env python
#
# Retrieve an artist by ID and display all official albums.
#
# Usage:
#	python getartist.py artist-id
#
# $Id: getartist.py 201 2006-03-27 14:43:13Z matt $
#
import sys
import logging
import musicbrainz2.webservice as ws
import musicbrainz2.model as m

logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)


if len(sys.argv) < 2:
	print "Usage: getartist.py artist-id"
	sys.exit(1)

q = ws.Query()

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


print "Id         :", artist.id
print "Name       :", artist.name
print "SortName   :", artist.sortName
print "UniqueName :", artist.getUniqueName()
print "Type       :", artist.type
print "BeginDate  :", artist.beginDate
print "EndDate    :", artist.endDate
print


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

for release in artist.getReleases():
	print
	print "Id        :", release.id
	print "Title     :", release.title
	print "ASIN      :", release.asin
	print "Text      :", release.textLanguage, '/', release.textScript
	print "Types     :", release.types

#
# Using the release IDs and Query.getReleaseById(), you could now request 
# those releases, including the tracks, release events, the associated
# DiscIDs, and more. The 'getrelease.py' example shows how this works.
#

# EOF