This AppleScript workflow detects if a song is being played on Apple Music or Spotify, then extracts the names of both the artist and the song, composes a string using a template and copies it to your clipboard.
This is the template used to compose the final string. The URL will only appear if the song is played on Spotify.
♬ <SONG_NAME> - <ARTIST_NAME> → <URL>
#Spotify|AppleMusic #NowPlaying
♬ Future World - Helloween → https://music.apple.com/es/album/future-world/1144728708?i=1144728856&uo=4
#AppleMusic #NowPlaying
♬ Royals - Lorde → http://open.spotify.com/track/4zztp85oS36ijgAWwyhX8p
#Spotify #NowPlaying
👉 Apps must be installed; the workflow is not compatible with their web version.
To obtain the Apple Music URL, I haven't found any other way than using an Apple shortcut that achieves the magic and copies the link to the clipboard. You can download it from this iCloud link.
🤦♂️ Apple Music doesn't always find the current track link because, you know, it's Apple.
- Download the linked shortcut and add it to your shortcuts library.
- Download the .alfredworkflow file or get it from the dist/ folder, double click it, and add it to your workflows.
- Link the appropriate script based on whether you are using Spotify or Apple Music.
- Check that the new shortcut is properly linked in the workflow, and that's it. You are good to go!
- Play some of your stuff on Apple Music or Spotify.
- Launch Alfred, type
now
, hit enter and as soon as you see the Done! alert, the composed string should be in your clipboard ;) - Enjoy!