Beispiel #1
0
def fetch_multiple_editors(editor_ids, includes=None):
    """Get info related to multiple editors using their editor IDs.
    Args:
        editor_ids (list): List of IDs of editors.
        includes (list): List of information to be included.
    Returns:
        Dictionary containing info of multiple editors keyed by their editor_id.
    """
    if includes is None:
        includes = []

    includes_data = defaultdict(dict)
    check_includes('editor', includes)
    with mb_session() as db:
        query = db.query(models.Editor)
        editors = get_entities_by_ids(
            query=query,
            entity_type='editor',
            ids=editor_ids,
        )
        editor_ids = [editor.id for editor in editors.values()]
        editors = {
            editor_id: serialize_editor(editors[editor_id], includes_data)
            for editor_id in editor_ids
        }

    return editors
Beispiel #2
0
def fetch_multiple_places(mbids, includes=None):
    """Get info related to multiple places using their MusicBrainz IDs.

    Args:
        mbids (list): List of MBIDs of places.
        includes (list): List of information to be included.

    Returns:
        Dictionary containing info of multiple places keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('place', includes)
    with mb_session() as db:
        query = db.query(models.Place).\
            options(joinedload("area")).\
            options(joinedload("type"))
        places = get_entities_by_gids(
            query=query,
            entity_type='place',
            mbids=mbids,
        )
        place_ids = [place.id for place in places.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='place',
                source_entity_ids=place_ids,
                includes_data=includes_data,
            )
        if 'place-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='place',
                source_type='place',
                source_entity_ids=place_ids,
                includes_data=includes_data,
            )
        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='place',
                source_entity_ids=place_ids,
                includes_data=includes_data,
            )

        for place in places.values():
            includes_data[place.id]['area'] = place.area
            includes_data[place.id]['type'] = place.type
        places = {
            str(mbid): serialize_places(places[mbid],
                                        includes_data[places[mbid].id])
            for mbid in mbids
        }
    return places
Beispiel #3
0
def fetch_multiple_places(mbids, includes=None):
    """Get info related to multiple places using their MusicBrainz IDs.

    Args:
        mbids (list): List of MBIDs of places.
        includes (list): List of information to be included.

    Returns:
        A dictionary containing info of multiple places keyed by their MBID.
        If an MBID doesn't exist in the database, it isn't returned.
        If an MBID is a redirect, the dictionary key will be the MBID given as an argument,
         but the returned object will contain the new MBID in the 'mbid' key.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('place', includes)
    with mb_session() as db:
        query = db.query(models.Place).\
            options(joinedload("area")).\
            options(joinedload("type"))
        places = get_entities_by_gids(
            query=query,
            entity_type='place',
            mbids=mbids,
        )
        place_ids = [place.id for place in places.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='place',
                source_entity_ids=place_ids,
                includes_data=includes_data,
            )
        if 'place-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='place',
                source_type='place',
                source_entity_ids=place_ids,
                includes_data=includes_data,
            )
        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='place',
                source_entity_ids=place_ids,
                includes_data=includes_data,
            )

        places = {
            str(mbid): serialize_places(place, includes_data[place.id])
            for mbid, place in places.items()
        }
    return places
def fetch_multiple_labels(mbids,
                          includes=None,
                          unknown_entities_for_missing=False):
    """Get info related to multiple labels using their MusicBrainz IDs.

    Args:
        mbids (list): List of MBIDs of labels.
        includes (list): List of information to be included.
    Returns:
        Dictionary containing info of multiple labels keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('label', includes)
    with mb_session() as db:
        query = db.query(models.Label).\
            options(joinedload("type")).\
            options(joinedload("area"))
        labels = get_entities_by_gids(
            query=query,
            entity_type='label',
            mbids=mbids,
            unknown_entities_for_missing=unknown_entities_for_missing,
        )
        label_ids = [label.id for label in labels.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='label',
                source_entity_ids=label_ids,
                includes_data=includes_data,
            )

        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='label',
                source_entity_ids=label_ids,
                includes_data=includes_data,
            )

        for label in labels.values():
            includes_data[label.id]['type'] = label.type
            includes_data[label.id]['area'] = label.area

    if 'rating' in includes:
        for label in labels.values():
            includes_data[label.id]['rating'] = label.rating

    return {
        str(mbid): serialize_labels(labels[mbid],
                                    includes_data[labels[mbid].id])
        for mbid in mbids
    }
Beispiel #5
0
def _fetch_multiple_recordings(mbids, includes=None):
    """ Fetch multiple recordings with MusicBrainz IDs.

    Args:
        mbids (list): list of uuid (MBID(gid)) of the recordings.
        includes (list): List of values to be included.
                        For list of possible values visit https://bitbucket.org/lalinsky/mbdata/wiki/API/v1/includes#!recording
    Returns:
        Dictionary containing the recording information with MBIDs as keys.
            - id: Recording mbid
            - name: Name of the recording
            - length: length of the recording
            - artists:
                - artist information: id, name, credited_name and join_phrase
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('recording', includes)

    with mb_session() as db:
        query = db.query(Recording)

        if 'artist' in includes or 'artists' in includes:
            query = query.options(joinedload("artist_credit", innerjoin=True))

        if 'artists' in includes:
            query = query.\
            options(subqueryload("artist_credit.artists")).\
            options(joinedload("artist_credit.artists.artist", innerjoin=True))

        recordings = get_entities_by_gids(
            query=query,
            entity_type='recording',
            mbids=mbids,
        )

        recording_ids = [recording.id for recording in recordings.values()]

        if 'artist' in includes:
            for recording in recordings.values():
                includes_data[recording.id]['artist'] = recording.artist_credit

        if 'artists' in includes:
            for recording in recordings.values():
                includes_data[
                    recording.id]['artists'] = recording.artist_credit.artists

        serial_recordings = {
            str(mbid): serialize_recording(recordings[mbid],
                                           includes_data[recordings[mbid].id])
            for mbid in mbids
        }

    return serial_recordings
Beispiel #6
0
def fetch_multiple_releases(mbids,
                            includes=None,
                            unknown_entities_for_missing=False):
    """Get info related to multiple releases using their MusicBrainz IDs.
    Args:
        mbids (list): List of MBIDs of releases.
        includes (list): List of information to be included.
    Returns:
        Dictionary containing info of multiple releases keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('release', includes)
    with mb_session() as db:
        query = db.query(models.Release)
        if 'release-groups' in includes:
            query = query.options(joinedload('release_group'))
        if 'media' in includes:
            # Fetch media with tracks
            query = query.options(joinedload('mediums')).\
                    options(joinedload('mediums.tracks')).\
                    options(joinedload('mediums.format')).\
                    options(joinedload('mediums.tracks.recording'))
        releases = get_entities_by_gids(
            query=query,
            entity_type='release',
            mbids=mbids,
            unknown_entities_for_missing=unknown_entities_for_missing,
        )
        release_ids = [release.id for release in releases.values()]

        if 'release-groups' in includes:
            for release in releases.values():
                includes_data[
                    release.id]['release-groups'] = release.release_group

        if 'media' in includes:
            for release in releases.values():
                includes_data[release.id]['media'] = release.mediums

        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='release',
                source_entity_ids=release_ids,
                includes_data=includes_data,
            )
        releases = {
            str(mbid): serialize_releases(releases[mbid],
                                          includes_data[releases[mbid].id])
            for mbid in mbids
        }
    return releases
Beispiel #7
0
def fetch_multiple_works(mbids, includes=None, unknown_entities_for_missing=False):
    """Get info related to multiple works using their MusicBrainz IDs.

    Args:
        mbids (list): List of MBIDs of works.
        includes (list): List of information to be included.

    Returns:
        Dictionary containing info of multiple works keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('work', includes)
    with mb_session() as db:
        query = db.query(models.Work).\
            options(joinedload("type"))
        works = get_entities_by_gids(
            query=query,
            entity_type='work',
            mbids=mbids,
            unknown_entities_for_missing=unknown_entities_for_missing,
        )
        work_ids = [work.id for work in works.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='work',
                source_entity_ids=work_ids,
                includes_data=includes_data,
            )

        if 'recording-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='recording',
                source_type='work',
                source_entity_ids=work_ids,
                includes_data=includes_data,
            )

        if 'rating' in includes:
            for work in works.values():
                includes_data[work.id]['rating'] = work.rating    

        for work in works.values():
            includes_data[work.id]['type'] = work.type
    return {str(mbid): serialize_works(works[mbid], includes_data[works[mbid].id]) for mbid in mbids}
def _fetch_multiple_recordings(mbids, includes=None):
    """ Fetch multiple recordings with MusicBrainz IDs.

    Args:
        mbids (list): list of uuid (MBID(gid)) of the recordings.
        includes (list): List of values to be included.
                        For list of possible values visit https://bitbucket.org/lalinsky/mbdata/wiki/API/v1/includes#!recording
    Returns:
        Dictionary containing the recording information with MBIDs as keys.
            - id: Recording mbid
            - name: Name of the recording
            - length: length of the recording
            - artists:
                - artist information: id, name, credited_name and join_phrase
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('recording', includes)

    with mb_session() as db:
        query = db.query(Recording)
        
        if 'artist' in includes or 'artists' in includes:
            query = query.options(joinedload("artist_credit", innerjoin=True))

        if 'artists' in includes:
            query = query.\
            options(subqueryload("artist_credit.artists")).\
            options(joinedload("artist_credit.artists.artist", innerjoin=True))

        recordings = get_entities_by_gids(
            query=query,
            entity_type='recording',
            mbids=mbids,
        )

        recording_ids = [recording.id for recording in recordings.values()]

        if 'artist' in includes:
            for recording in recordings.values():
                includes_data[recording.id]['artist'] = recording.artist_credit

        if 'artists' in includes:
            for recording in recordings.values():
                includes_data[recording.id]['artists'] = recording.artist_credit.artists

        serial_recordings = {str(mbid): serialize_recording(recordings[mbid], includes_data[recordings[mbid].id]) for mbid in mbids}

    return serial_recordings
def fetch_multiple_releases(mbids, includes=None):
    """Get info related to multiple releases using their MusicBrainz IDs.
    Args:
        mbids (list): List of MBIDs of releases.
        includes (list): List of information to be included.
    Returns:
        Dictionary containing info of multiple releases keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('release', includes)
    with mb_session() as db:
        query = db.query(models.Release)
        if 'release-groups' in includes:
            query = query.options(joinedload('release_group'))
        if 'media' in includes:
            # Fetch media with tracks
            query = query.options(joinedload('mediums')).\
                    options(joinedload('mediums.tracks')).\
                    options(joinedload('mediums.format')).\
                    options(joinedload('mediums.tracks.recording'))
        releases = get_entities_by_gids(
            query=query,
            entity_type='release',
            mbids=mbids,
        )
        release_ids = [release.id for release in releases.values()]

        if 'release-groups' in includes:
            for release in releases.values():
                includes_data[release.id]['release-groups'] = release.release_group

        if 'media' in includes:
            for release in releases.values():
                includes_data[release.id]['media'] = release.mediums

        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='release',
                source_entity_ids=release_ids,
                includes_data=includes_data,
            )
        releases = {str(mbid): serialize_releases(releases[mbid], includes_data[releases[mbid].id]) for mbid in mbids}
    return releases
Beispiel #10
0
def fetch_multiple_works(mbids, includes=None):
    """Get info related to multiple works using their MusicBrainz IDs.

    Args:
        mbids (list): List of MBIDs of works.
        includes (list): List of information to be included.

    Returns:
        A dictionary containing info of multiple works keyed by their MBID.
        If an MBID doesn't exist in the database, it isn't returned.
        If an MBID is a redirect, the dictionary key will be the MBID given as an argument,
         but the returned object will contain the new MBID in the 'mbid' key.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('work', includes)
    with mb_session() as db:
        query = db.query(models.Work).options(joinedload("type"))

        works = get_entities_by_gids(
            query=query,
            entity_type='work',
            mbids=mbids,
        )
        work_ids = [work.id for work in works.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='work',
                source_entity_ids=work_ids,
                includes_data=includes_data,
            )

        if 'recording-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='recording',
                source_type='work',
                source_entity_ids=work_ids,
                includes_data=includes_data,
            )

        return {str(mbid): serialize_works(work, includes_data[work.id]) for mbid, work in works.items()}
Beispiel #11
0
def fetch_multiple_artists(mbids, includes=None):
    """Get info related to multiple artists using their MusicBrainz IDs.
    Args:
        mbids (list): List of MBIDs of artists.
        includes (list): List of information to be included.
    Returns:
        Dictionary containing info of multiple artists keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('artist', includes)
    with mb_session() as db:
        query = db.query(models.Artist).\
                options(joinedload("type"))
        artists = get_entities_by_gids(
            query=query,
            entity_type='artist',
            mbids=mbids,
        )
        artist_ids = [artist.id for artist in artists.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='artist',
                source_entity_ids=artist_ids,
                includes_data=includes_data,
            )
        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='artist',
                source_entity_ids=artist_ids,
                includes_data=includes_data,
            )

    for artist in artists.values():
        includes_data[artist.id]['type'] = artist.type
    artists = {str(mbid): serialize_artists(artists[mbid], includes_data[artists[mbid].id]) for mbid in mbids}
    return artists
Beispiel #12
0
def fetch_multiple_editors(editor_ids, includes=None):
    """Get info related to multiple editors using their editor IDs.
    Args:
        editor_ids (list): List of IDs of editors.
        includes (list): List of information to be included.
    Returns:
        Dictionary containing info of multiple editors keyed by their editor_id.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('editor', includes)
    with mb_session() as db:
        query = db.query(models.Editor)
        editors = get_entities_by_ids(
            query=query,
            entity_type='editor',
            ids=editor_ids,
        )
        editor_ids = [editor.id for editor in editors.values()]
        editors = {editor_id: serialize_editor(editors[editor_id], includes_data) for editor_id in editor_ids}

    return editors
def fetch_multiple_events(mbids,
                          includes=None,
                          unknown_entities_for_missing=False):
    """Get info related to multiple events using their MusicBrainz IDs.

    Args:
        mbids (list): List of MBIDs of events.
        includes (list): List of information to be included.

    Returns:
        Dictionary containing info of multiple events keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('event', includes)
    with mb_session() as db:
        query = db.query(models.Event)
        events = get_entities_by_gids(
            query=query,
            entity_type='event',
            mbids=mbids,
            unknown_entities_for_missing=unknown_entities_for_missing,
        )
        event_ids = [event.id for event in events.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'place-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='place',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'series-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='series',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'release-group-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='release_group',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )

    if 'rating' in includes:
        for event in events.values():
            includes_data[event.id]['rating'] = event.rating

    return {
        str(mbid): serialize_events(events[mbid],
                                    includes_data[events[mbid].id])
        for mbid in mbids
    }
Beispiel #14
0
def fetch_multiple_release_groups(mbids, includes=None):
    """Get info related to multiple release groups using their MusicBrainz IDs.
    Args:
        mbids (list): List of MBIDs of releases groups.
        includes (list): List of information to be included.
    Returns:
        Dictionary containing info of multiple release groups keyed by their mbid.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('release_group', includes)
    with mb_session() as db:
        # Join table meta which contains release date for a release group
        query = db.query(models.ReleaseGroup).options(joinedload("meta")).\
                options(joinedload("type"))

        if 'artists' in includes:
            query = query.\
                options(joinedload("artist_credit")).\
                options(joinedload("artist_credit.artists")).\
                options(joinedload("artist_credit.artists.artist"))

        release_groups = get_entities_by_gids(
            query=query,
            entity_type='release_group',
            mbids=mbids,
        )
        release_group_ids = [
            release_group.id for release_group in release_groups.values()
        ]

        if 'artists' in includes:
            for release_group in release_groups.values():
                artist_credit_names = release_group.artist_credit.artists
                includes_data[release_group.
                              id]['artist-credit-names'] = artist_credit_names
                includes_data[release_group.id][
                    'artist-credit-phrase'] = release_group.artist_credit.name

        if 'releases' in includes:
            query = db.query(models.Release).filter(
                getattr(models.Release,
                        "release_group_id").in_(release_group_ids))
            for release in query:
                includes_data[release.release_group_id].setdefault(
                    'releases', []).append(release)

        if 'release-group-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='release_group',
                source_type='release_group',
                source_entity_ids=release_group_ids,
                includes_data=includes_data,
            )

        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='release_group',
                source_entity_ids=release_group_ids,
                includes_data=includes_data,
            )

        if 'work-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='work',
                source_type='release_group',
                source_entity_ids=release_group_ids,
                includes_data=includes_data,
            )

        if 'tags' in includes:
            release_group_tags = get_tags(
                db=db,
                entity_model=models.ReleaseGroup,
                tag_model=models.ReleaseGroupTag,
                foreign_tag_id=models.ReleaseGroupTag.release_group_id,
                entity_ids=release_group_ids,
            )
            for release_group_id, tags in release_group_tags:
                includes_data[release_group_id]['tags'] = tags

        for release_group in release_groups.values():
            includes_data[release_group.id]['meta'] = release_group.meta
            includes_data[release_group.id]['type'] = release_group.type
        release_groups = {
            str(mbid):
            serialize_release_groups(release_groups[mbid],
                                     includes_data[release_groups[mbid].id])
            for mbid in mbids
        }
        return release_groups
Beispiel #15
0
def fetch_multiple_releases(mbids, includes=None):
    """Get info related to multiple releases using their MusicBrainz IDs.
    Args:
        mbids (list): List of MBIDs of releases.
        includes (list): List of information to be included.
    Returns:
        A dictionary containing info of multiple releases keyed by their MBID.
        If an MBID doesn't exist in the database, it isn't returned.
        If an MBID is a redirect, the dictionary key will be the MBID given as an argument,
         but the returned object will contain the new MBID in the 'mbid' key.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('release', includes)
    with mb_session() as db:
        query = db.query(models.Release)
        if 'release-groups' in includes:
            query = query.options(joinedload('release_group'))
        if 'artists' in includes:
            query = query.\
                options(joinedload("artist_credit")).\
                options(joinedload("artist_credit.artists")).\
                options(joinedload("artist_credit.artists.artist"))
        if 'media' in includes:
            # Fetch media with tracks
            query = query.options(joinedload('mediums')).\
                    options(joinedload('mediums.tracks')).\
                    options(joinedload('mediums.format')).\
                    options(joinedload('mediums.tracks.recording')).\
                    options(joinedload('mediums.tracks.recording.artist_credit')).\
                    options(joinedload('mediums.tracks.recording.artist_credit.artists')).\
                    options(joinedload('mediums.tracks.recording.artist_credit.artists.artist'))
        releases = get_entities_by_gids(
            query=query,
            entity_type='release',
            mbids=mbids,
        )
        release_ids = [release.id for release in releases.values()]

        if 'release-groups' in includes:
            for release in releases.values():
                includes_data[
                    release.id]['release-groups'] = release.release_group

        if 'artists' in includes:
            for release in releases.values():
                artist_credit_names = release.artist_credit.artists
                includes_data[
                    release.id]['artist-credit-names'] = artist_credit_names
                includes_data[release.id][
                    'artist-credit-phrase'] = release.artist_credit.name

        if 'media' in includes:
            for release in releases.values():
                includes_data[release.id]['media'] = release.mediums

        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='release',
                source_entity_ids=release_ids,
                includes_data=includes_data,
            )

        releases = {
            str(mbid): serialize_releases(release, includes_data[release.id])
            for mbid, release in releases.items()
        }
    return releases
Beispiel #16
0
def fetch_multiple_events(mbids, includes=None):
    """Get info related to multiple events using their MusicBrainz IDs.

    Args:
        mbids (list): List of MBIDs of events.
        includes (list): List of information to be included.

    Returns:
        A dictionary containing info of multiple events keyed by their MBID.
        If an MBID doesn't exist in the database, it isn't returned.
        If an MBID is a redirect, the dictionary key will be the MBID given as an argument,
         but the returned object will contain the new MBID in the 'mbid' key.
    """
    if includes is None:
        includes = []
    includes_data = defaultdict(dict)
    check_includes('event', includes)
    with mb_session() as db:
        query = db.query(models.Event).options(joinedload('type'))
        events = get_entities_by_gids(
            query=query,
            entity_type='event',
            mbids=mbids,
        )
        event_ids = [event.id for event in events.values()]

        if 'artist-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='artist',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'place-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='place',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'series-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='series',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'url-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='url',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )
        if 'release-group-rels' in includes:
            get_relationship_info(
                db=db,
                target_type='release_group',
                source_type='event',
                source_entity_ids=event_ids,
                includes_data=includes_data,
            )

        return {
            str(mbid): serialize_events(event, includes_data[event.id])
            for mbid, event in events.items()
        }