Query currently playing media URI

I have a script that I’ve used to skip the currently playing track when the Spotify API says that the the track is explicit. The script works by monitoring the local Sonos server and making a lookup based on the Spotify track ID.

Source: https://github.com/rbdixon/stfu

I’d like to port this to Home Assistant but I can’t find an easy way to get the currently playing media URI from either the Sonos or media player components. I plan on implementing this as a python-based sensor at first so if there is an internal API for this that’s great.

Thanks,

Brad