These metadata fields are user-defined and are guaranteed to change project-by-project. Can you make the script discover them dynamically?

N.B.: This is pretty much the only substantive comment I've had to make here.