Found what I was looking for. I was a quarter of the way into building it myself when I stumbled upon the completed project. Props to Stefan Crowe for inventing the wheel for me.
https://pastebin.com/v49Kx5Lk
My problem is now solved. But it doesn’t seem like it would be too much trouble to build this right into ACF.