Backup and restore Apple Music Playlist.
Put token in config file ~/.amp.json:
{
"developer_token": "eyJhb...",
"user_token": "AiGUK..."
}
Backup playlists to current directory:
amp backup
2023/07/13 14:17:16 found 2 playlists
2023/07/13 14:17:17 writing playlist FAVORITES to playlist.p.EYWrg35c4DOAgv.json
2023/07/13 14:17:18 writing playlist Replay 2022 to playlist.p.B0A8vz3h0A58RK.json
Restore specific playlist:
amp restore playlist.p.EYWrg35c4DOAgv.json TEST
2023/07/13 14:17:43 created playlist [ name: TEST , id: p.dl0k4dDhWZkrEN ] with 17 tracks
- Copy the Team ID in Apple Developer Account page.
- Create MusicKit identifier.
- Create and download MusicKit key file, copy the key ID.
- Generate developer token with team ID, key file and key ID.
- In any Chrome page, use DevTools console. Enter following script, log in and copy the user token:
var script = document.createElement('script')
script.src = 'https://js-cdn.music.apple.com/musickit/v1/musickit.js'
script.onload = function () {
const button = document.createElement('button')
button.addEventListener('click', function () {
MusicKit.configure({
developerToken: 'YOUR_DEVELOPER_TOKEN',
}).authorize().then(function (token) {
console.log(token)
})
})
button.click()
}
document.head.appendChild(script)