create a template sensor
the sensor value will be the media_player attribute that gives you the name of what you’re watching.
You’ve not provided any code/example so it’s a bit difficult to give you detailed guidance on what you need to do…
For the 2nd part of the question, you’d need an automation to triggers when that template sensor changes, and use a service that publishes the sensor value to whatever online service you’re using.
Having had a quick look, it doesn’t seem that Trakt is already integrated in HA so you will need to find an alternative way to publish.