Last active
April 1, 2020 08:26
-
-
Save inlife/8ad44a77bf422fd6618f08386a49fbb4 to your computer and use it in GitHub Desktop.
Script allows you to copy tracklist with time frames, while listening to a mix on the Mixcloud.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
let guid = prompt("Paste in GUID"); | |
let cast = (data) => { | |
return data.results.result.map(obj => { | |
let tracks = obj.trackclients.trackclient | |
if (tracks.length == 0) { | |
tracks.push({ track_title: 'Unknown', track_mix_artist: 'Unknown' }) | |
} | |
let track = tracks[0] | |
let altartist = track.bundle_mirror_artists | |
? (track.bundle_mirror_artists.artist || ['Unknown'])[0] | |
: 'Unknown' | |
return { | |
start: obj.start, | |
end: obj.end, | |
title: track.track_title || 'Unknown', | |
artist: track.track_mix_artist || altartist || 'Unknown', | |
} | |
}) | |
} | |
const res2 = await fetch('https://www.mixcloud.com/tracklist/?guid=' + guid) | |
const data2 = await res2.json() | |
const tracks = cast(data2) | |
if (window.navigator.userAgent.indexOf("Chrom") !== -1) { | |
prompt("Copy the tracklist", JSON.stringify(tracks)); | |
} else { | |
alert(tracks); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment