Like many in the Sonos community, I struggled with the right recipe to get playlists from a former macOS iTunes app library that had been migrated to the Music app library on a macOS upgrade to Catalina to import and be recognized by Sonos players from a remote network-attached storage (NAS) volume, such as QNAP or Synology.
After experimentation, I believe I have developed a script that handles both iTunes app (prior to Catalina) and Music app (Catalina and later) that successfully allows the Sonos players (or at least Play:5 (Gen 2)) to import and play tracks from media and playlists on NAS volumes exported by those macOS apps.
It is available at:
https://github.com/gerickson/nas-sonos-itunes-sync
This script can either be run manually, one-demand from the command line or automatically, on a schedule as a LaunchAgent (see included example in the project).
I have also been apprised of an app on the App Store that will do something similar, but with a nice UI/UX:
https://apps.apple.com/us/app/music-library-exporter/id1553648567