def getUserRating(self, entityUri): """Return the rating a user has applied to an entity. The given parameter has to be a fully qualified MusicBrainz ID, as returned by other library functions. Note that this method only works if a valid user name and password have been set. Only the rating the authenticated user applied to the entity will be returned. If username and/or password are incorrect, an AuthenticationError is raised. This method will return a L{Rating <musicbrainz2.model.Rating>} object. @param entityUri: a string containing an absolute MB ID @raise ValueError: invalid entityUri @raise ConnectionError: couldn't connect to server @raise RequestError: invalid ID or entity @raise AuthenticationError: invalid user name and/or password """ entity = mbutils.extractEntityType(entityUri) uuid = mbutils.extractUuid(entityUri, entity) params = { 'entity': entity, 'id': uuid } stream = self._ws.get('rating', '', filter=params) try: parser = MbXmlParser() result = parser.parse(stream) except ParseError, e: raise ResponseError(str(e), e)
def getTrack(self, filter): params = filter.createParameters() stream = self._ws.post("track", "", urllib.urlencode(params, True)) try: parser = MbXmlParser() return parser.parse(stream).getTrack() except ParseError, e: raise ResponseError(str(e), e)
def _getFromWebService(self, entity, id_, include=None, filter=None): if filter is None: filterParams = [ ] else: filterParams = filter.createParameters() if include is None: includeParams = [ ] else: includeParams = include.createIncludeTags() stream = self._ws.get(entity, id_, includeParams, filterParams) try: parser = MbXmlParser() return parser.parse(stream) except ParseError, e: raise ResponseError(str(e), e)
def getUserCollection(self, offset=0, maxitems=100): """Get the releases that are in a user's collection A maximum of 100 items will be returned for any one call to this method. To fetch more than 100 items, use the offset parameter. @param offset: the offset to start fetching results from @param maxitems: the upper limit on items to return @return: a list of L{musicbrainz2.wsxml.ReleaseResult} objects @raise ConnectionError: couldn't connect to server @raise AuthenticationError: invalid user name and/or password """ params = { 'offset': offset, 'maxitems': maxitems } stream = self._ws.get('collection', '', filter=params) try: parser = MbXmlParser() result = parser.parse(stream) except ParseError, e: raise ResponseError(str(e), e)