Last active
November 3, 2023 09:05
-
-
Save 17xande/26be241620988891e247d878ccd467f8 to your computer and use it in GitHub Desktop.
Deno script for printing track data for some specific 8tracks mixes
This file contains hidden or 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
// Betsyrae's mixes from 8tracks. | |
const mixes = [420692,427734,449791,459125,605181,1026789,1199423,1339489,1511768,2395459,3203484,3203484,7337283]; | |
type track = { | |
name: string, | |
performer: string, | |
year: string, | |
release_name: string, | |
} | |
function getUrl(id: number): string { | |
return `https://8tracks.com/mixes/${id}/tracks_for_international.jsonh` | |
} | |
async function getTracks(mixID: number): Promise<track[]> { | |
const url = getUrl(mixID) | |
const res = await fetch(url) | |
const jso = await res.json() | |
const tracks = jso.tracks.map(t => { | |
const track: track = { | |
name: t.name, | |
performer: t.performer, | |
year: t.year, | |
release_name: t.release_name, | |
} | |
return track | |
}) | |
return tracks | |
} | |
function stringTrack(t: track): string { | |
return `${t.name} ${t.performer} - ${t.release_name}` | |
} | |
async function printMix(id: number) { | |
const tracks = await getTracks(id) | |
tracks.forEach(t => console.log(stringTrack(t))) | |
} | |
const i = <number>Deno.args[0] | |
printMix(mixes[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment