I am curious as to why not just use:
playerctl metadata artist
playerctl metadata title
as provided by MPRIShttps://wiki.archlinux.org/title/MPRIS
> MPRIS (Media Player Remote Interfacing Specification) is a standard D-Bus interface which aims to provide a common programmatic API for controlling media players.
> It provides a mechanism for discovery, querying and basic playback control of compliant media players, as well as a track list interface which is used to add context to the active media item.