def get_contributors(raw):
    """
    Extract contributors.

    Only contributors tagged as belonging
    to any of the valid roles will be extracted.

    @param raw: json object of a Libris edition
    @type raw: dictionary
    """
    valid_roles = ["author", "editor",
                   "translator", "illustrator"]
    agents = {"author": [], "editor": [],
              "translator": [], "illustrator": []}
    contribution = raw["mainEntity"]["instanceOf"].get("contribution")
    for agent in contribution:
        raw_role = agent.get("role")
        if not raw_role:
            ag_role = "author"
        else:
            ag_role = agent["role"][0]["@id"].split("/")[-1]
        if ag_role in valid_roles:
            ag_id = agent["agent"].get("@id") or ""
            ag_first = agent["agent"].get("givenName") or ""
            ag_last = agent["agent"].get("familyName") or ""
            ag_full = "{} {}".format(ag_first, ag_last)
            agents[ag_role].append({"name": ag_full, "id": ag_id})
    return agents