sphd-shairport-meta.py will only work with Shairport-Sync, since it uses Shairport's metadata to extract the currently playing songs.
To get it working with Mopidy would require a similar, but different, example.
Looks like the key is in the Mopidy WebSocket API documented here: https://docs.mopidy.com/en/latest/api/http/#websocket-api
Making a client connection to this API will result in any change on the Mopidy end being pushed as a notification to the client, so Python could connect to the WebSocket API.
sudo pip install websocket-client on your Mopdify Pi and then run the below example to see what data you get out of your Mopidy install:
def on_message(ws, message):
def on_error(ws, error):
print("### closed ###")
if __name__ == "__main__":
ws = websocket.WebSocketApp("ws://127.0.0.1:6680/mopidy/ws",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
It's looking promising, though, although in my experience getting Python's WebSocket to run alongside anything else is tricky.