Use AppleScript to find the currently playing song (and other metadata)
This is a very useful tool and I have a recommendation on the best place to learn how to use AppleScript to interact with media.

https://dougscripts.com/itunes/index.php

This is 100% possible and you might even find the exact script you need, already written. Worst case, you can see the code and hopefully adapt one to your needs.