def short_id_from_s3_key(input):
    """
        Transform s3 keys to case or page short IDs used by volume XML:
            32044142600386_redacted/alto/32044142600386_redacted_ALTO_00009_0.xml  ->  alto_00009_0
            32044142600386_redacted/casemets/32044142600386_redacted_CASEMETS_0001.xml  -> casemets_0001
    """
    if ('CASEMETS' in input or 'ALTO' in input) and input.endswith("xml"):
        return input.split('/')[-1].split('.')[0].split('redacted_')[1].lower()
    raise Exception("Not an ALTO or CASEMETS s3_key")