def convert_release_relation(obj): relation = convert_relation(obj) release_obj = obj.release release = models.release(id=release_obj.gid, title=release_obj.name) if release_obj.comment: release.set_disambiguation(release_obj.comment) relation.set_release(release) return relation
def convert_release_list_for_release_groups(obj): """ :type obj: :class:`[mbdata.models.Release]` """ release_list = models.release_list(count=len(obj)) for r in obj: release = models.release() release.set_id(r.gid) release.set_title(r.name) if r.status is not None: release.set_status(convert_release_status(r.status)) release_list.add_release(release) return release_list
def convert_release_list_for_release_groups(obj): """ :type obj: :class:`[mbdata.models.Release]` """ release_list = models.release_list(count=len(obj)) for r in obj: release = models.release() release.set_id(r.gid) release.set_title(r.name) if r.status is not None: release.set_status(r.status.name) release_list.add_release(release) return release_list
def convert_release_from_track(obj): """ :type obj: :class:`mbdata.models.Track` """ medium = obj.medium rel = medium.release release = models.release() release.set_id(rel.gid) release.set_title(rel.name) # The lucene search server skips this if the release artist credit is the # same as the recording artist credit, but we've already built it so just # set it release.set_artist_credit( convert_artist_credit(rel.artist_credit, include_aliases=True)) if rel.comment is not None and rel.comment != "": release.set_disambiguation(rel.comment) if len(rel.country_dates) > 0: release.set_release_event_list( convert_release_event_list(rel.country_dates)) first_release = release.release_event_list.release_event[0] if first_release.date is not None: release.set_date(first_release.date) if (first_release.area is not None and first_release.area.iso_3166_1_code_list is not None and len(first_release.area.iso_3166_1_code_list.iso_3166_1_code) > 0): release.set_country( first_release.area.iso_3166_1_code_list.iso_3166_1_code[0]) release.set_medium_list(convert_medium_list_from_track(obj)) release.set_release_group( convert_release_group_for_release(rel.release_group)) if rel.status is not None: release.set_status(rel.status.name) return release
def convert_release_from_track(obj): """ :type obj: :class:`mbdata.models.Track` """ medium = obj.medium rel = medium.release release = models.release(id=rel.gid, title=rel.name) # The lucene search server skips this if the release artist credit is the # same as the recording artist credit, but we've already built it so just # set it release.set_artist_credit(convert_artist_credit(rel.artist_credit, include_aliases=True)) if rel.comment is not None and rel.comment != "": release.set_disambiguation(rel.comment) if len(rel.country_dates) > 0: release.set_release_event_list( convert_release_event_list(rel.country_dates)) first_release = release.release_event_list.release_event[0] if first_release.date is not None: release.set_date(first_release.date) if (first_release.area is not None and first_release.area.iso_3166_1_code_list is not None and len(first_release.area.iso_3166_1_code_list.iso_3166_1_code) > 0): release.set_country( first_release.area.iso_3166_1_code_list.iso_3166_1_code[0]) release.set_medium_list(convert_medium_list_from_track(obj)) release.set_release_group( convert_release_group_for_release(rel.release_group)) if rel.status is not None: release.set_status(rel.status.name) return release
def convert_release(obj): """ :type obj: :class:`mbdata.models.Release` """ # TODO: ASIN release = models.release() release.set_id(obj.gid) release.set_title(obj.name) release.set_artist_credit(convert_artist_credit(obj.artist_credit)) if obj.barcode is not None: if obj.barcode != "": release.set_barcode(obj.barcode) else: release.set_barcode(BARCODE_NONE) else: release.set_barcode(BARCODE_UNKOWN) if obj.comment is not None and obj.comment != "": release.set_disambiguation(obj.comment) if obj.packaging is not None: release.set_packaging(obj.packaging.name) if len(obj.country_dates) > 0: release.set_release_event_list( convert_release_event_list(obj.country_dates)) first_release = release.release_event_list.release_event[0] if first_release.date is not None: release.set_date(first_release.date) if (first_release.area is not None and first_release.area.iso_3166_1_code_list is not None and len(first_release.area.iso_3166_1_code_list.iso_3166_1_code) > 0): release.set_country( first_release.area.iso_3166_1_code_list.iso_3166_1_code[0]) if len(obj.labels) > 0: release.set_label_info_list(convert_label_info_list(obj.labels)) if len(obj.mediums) > 0: release.set_medium_list(convert_medium_list(obj.mediums)) release.set_release_group( convert_release_group_for_release(obj.release_group)) if obj.status is not None: release.set_status(obj.status.name) if obj.tags is not None: release.set_tag_list(convert_tag_list(obj.tags)) tr = None if obj.language is not None: tr = models.text_representation() tr.set_language(obj.language.iso_code_3) if obj.script is not None: if tr is None: tr = models.text_representation() tr.set_script(obj.script.iso_code) if tr is not None: release.set_text_representation(tr) return release
def convert_release(obj): """ :type obj: :class:`mbdata.models.Release` """ release = models.release(id=obj.gid, title=obj.name, artist_credit=convert_artist_credit( obj.artist_credit, include_aliases=False)) if obj.barcode is not None: release.set_barcode(obj.barcode) if obj.comment: release.set_disambiguation(obj.comment) if obj.packaging is not None: release.set_packaging(convert_release_packaging(obj.packaging)) if len(obj.country_dates) > 0: release.set_release_event_list( convert_release_event_list(obj.country_dates)) first_release = release.release_event_list.release_event[0] if first_release.date is not None: release.set_date(first_release.date) if (first_release.area is not None and first_release.area.iso_3166_1_code_list is not None and len(first_release.area.iso_3166_1_code_list.iso_3166_1_code) > 0): release.set_country( first_release.area.iso_3166_1_code_list.iso_3166_1_code[0]) if len(obj.labels) > 0: release.set_label_info_list(convert_label_info_list(obj.labels)) if len(obj.mediums) > 0: release.set_medium_list(convert_medium_list(obj.mediums)) release.set_release_group( convert_release_group_for_release(obj.release_group)) if obj.status is not None: release.set_status(convert_release_status(obj.status)) if obj.tags is not None: release.set_tag_list(convert_tag_list(obj.tags)) tr = None if obj.language is not None: tr = models.text_representation() tr.set_language(obj.language.iso_code_3) if obj.script is not None: if tr is None: tr = models.text_representation() tr.set_script(obj.script.iso_code) if tr is not None: release.set_text_representation(tr) if obj.meta.amazon_asin is not None: release.set_asin(obj.meta.amazon_asin) return release
def convert_release(obj): """ :type obj: :class:`mbdata.models.Release` """ release = models.release(id=obj.gid, title=obj.name, artist_credit=convert_artist_credit(obj.artist_credit)) # noqa if obj.barcode is not None: if obj.barcode != "": release.set_barcode(obj.barcode) else: release.set_barcode(BARCODE_NONE) else: release.set_barcode(BARCODE_UNKOWN) if obj.comment is not None and obj.comment != "": release.set_disambiguation(obj.comment) if obj.packaging is not None: release.set_packaging(obj.packaging.name) if len(obj.country_dates) > 0: release.set_release_event_list( convert_release_event_list(obj.country_dates)) first_release = release.release_event_list.release_event[0] if first_release.date is not None: release.set_date(first_release.date) if (first_release.area is not None and first_release.area.iso_3166_1_code_list is not None and len(first_release.area.iso_3166_1_code_list.iso_3166_1_code) > 0): release.set_country( first_release.area.iso_3166_1_code_list.iso_3166_1_code[0]) if len(obj.labels) > 0: release.set_label_info_list(convert_label_info_list(obj.labels)) if len(obj.mediums) > 0: release.set_medium_list(convert_medium_list(obj.mediums)) release.set_release_group( convert_release_group_for_release(obj.release_group)) if obj.status is not None: release.set_status(obj.status.name) if obj.tags is not None: release.set_tag_list(convert_tag_list(obj.tags)) tr = None if obj.language is not None: tr = models.text_representation() tr.set_language(obj.language.iso_code_3) if obj.script is not None: if tr is None: tr = models.text_representation() tr.set_script(obj.script.iso_code) if tr is not None: release.set_text_representation(tr) return release