Change metadata.title in Update

Im working on a set of some much improved music agents and they’re mostly done with fetching lots of information, from several diffrent sources but I have one MAJOR problem with it…



So ok. When searching, I have a result list of quite often multiple artists with the EXACT same name. Like, 666 as artist. The only way I’ve found to diffrentiate between these, is to apply text to their names for identification. That means that the artist name is initially set wrong, which isnt a problem for any of the agents Im making as they do not in any way rely on names for anything except that initial search. After that it relies entirely on MBID and relation links. But it looks quite annoying that after matching is done, the name is now wrong, so in the Update function, I have a line saying essentially metadata.title = ‘new_title’… This as I understand it, SHOULD change the title, but it doesnt. Is there something more I have to do that Im missing or is this not at all possible? Other agents seems to be atleast trying to do this as well, but Im not sure if they actually succeed or not. It’s not updating in my case though atleast. The primary agent is coded as:



BASE_URL        = 'http://musicbrainz.org/ws/2'<br />
<br />
ARTIST_SEARCH = BASE_URL + '/artist/?query=%s'<br />
ALBUM_SEARCH = BASE_URL + '/release/?query=arid:%s AND release:%s'<br />
<br />
ARTIST_INFO = BASE_URL +'/artist/%s?inc=tags+ratings+url-rels'<br />
<br />
def Start():<br />
  HTTP.CacheTime = CACHE_1WEEK<br />
  <br />
class MusicbrainzAgent(Agent.Artist):<br />
  name = 'Musicbrainz'<br />
  languages = [Locale.Language.English]<br />
  primary_provider = True<br />
<br />
  def search(self, results, media, lang):<br />
    try:<br />
      searchResponse = XML.ElementFromURL(ARTIST_SEARCH % (String.Quote(media.artist)))<br />
    except:<br />
      return<br />
<br />
    mbns = {'mb':'http://musicbrainz.org/ns/mmd-2.0#',<br />
            'ext':'http://musicbrainz.org/ns/ext#-2.0'}<br />
<br />
    for a in searchResponse.xpath('//mb:artist', namespaces=mbns ):<br />
      #Make sure never to auto match against artist of diffrent name<br />
      if a.find('{http://musicbrainz.org/ns/mmd-2.0#}name').text == media.artist:<br />
        hit_score = int(a.get('{http://musicbrainz.org/ns/ext#-2.0}score')) + 10<br />
      else:<br />
        hit_score = int(a.get('{http://musicbrainz.org/ns/ext#-2.0}score')) /2<br />
<br />
      #Add disambiguation information to Artist name<br />
      if a.find('{http://musicbrainz.org/ns/mmd-2.0#}disambiguation') is not None:<br />
        hit_name = a.find('{http://musicbrainz.org/ns/mmd-2.0#}name').text + ' ' + a.find('{http://musicbrainz.org/ns/mmd-2.0#}disambiguation').text<br />
      else:<br />
        hit_name = a.find('{http://musicbrainz.org/ns/mmd-2.0#}name').text<br />
<br />
      results.Append(MetadataSearchResult(<br />
        id = a.get('id'),<br />
        name = hit_name,<br />
        lang = lang,<br />
        score = hit_score<br />
      ))<br />
<br />
  def update(self, metadata, media, lang):<br />
    try:<br />
      LookupResponse = XML.ElementFromURL(ARTIST_INFO % (String.Quote(metadata.id[0:36])))<br />
    except:<br />
      return<br />
<br />
    mbns = {'mb':'http://musicbrainz.org/ns/mmd-2.0#',<br />
            'ext':'http://musicbrainz.org/ns/ext#-2.0'}<br />
<br />
    Log(LookupResponse.xpath('//mb:artist/mb:name', namespaces=mbns )[0].text)<br />
    metadata.title = LookupResponse.xpath('//mb:artist/mb:name', namespaces=mbns )[0].text<br />
    Log(metadata.title)<br />
<br />
    DiscogURL = ''<br />
    for a in LookupResponse.xpath('//mb:target', namespaces=mbns ):<br />
      if 'discogs.com' in a.text:<br />
        DiscogURL = a.text.replace('www', 'api')<br />
        metadata.id = metadata.id + DiscogURL<br />
<br />
    for genre in LookupResponse.xpath('//mb:artist/mb:tag-list/mb:tag/mb:name', namespaces=mbns ):<br />
      if genre.text.capitalize() not in metadata.genres:<br />
        metadata.genres.add(genre.text.capitalize())<br />
<br />
    if metadata.rating is not None:<br />
      metadata.rating = float(LookupResponse.xpath('//mb:artist/mb:rating', namespaces=mbns )[0].text) * 2<br />




Would greatly appriciate if anyone knows how to get it to change the title after matching.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.