Is there a way to execute a script or automation if a specific YouTube video is played

The title. New here first time posting. Tried to google this but I couldn’t find an answer. Thank you.

What is youtube being played on? Is that device integrated with HA such that it has a media_player entity that shows you the media title?