Beispiel #1
0
def process_release_labels(elem):
    labels = []
    master_id = None
    release_id = elem.attrib.get('id')
    if release_id is None:
        return
    for e in elem.iterchildren():
        if e.tag == 'master_id' and e.text is not None:
            master_id = e.text
        if e.tag == 'labels':
            for f in e.iterchildren(tag='label'):
                label = f.attrib.get('name')
                if label:
                    labels.append(label)
    if not labels:
        return
    if master_id is None:
        release = Release.get_by_release_id(release_id)
    else:
        release = Release.get_by_master_id(master_id)
    if release is None:
        return
    labels = list(set(labels))
    release.add_labels(labels)
Beispiel #2
0
def process_release_artists(elem):
    artists = []
    master_id = None
    release_id = elem.attrib.get('id')
    if release_id is None:
        return
    for e in elem.iterchildren():
        if e.tag == 'master_id' and e.text is not None:
            master_id = e.text
        if e.tag in ['artists', 'extraartists']:
            for f in e.iterchildren(tag='artist'):
                for g in g.iterchildren():
                    if g.tag == 'name' and g.text is not None:
                        artists.append(g.text)
    if not artists:
        return
    if master_id is None:
        release = Release.get_by_release_id(release_id)
    else:
        release = Release.get_by_master_id(master_id)
    if release is None:
        return
    artists = list(set(artists))
    release.add_artists(artists)