Advertisement
jcunews

Bookmarklet to Save 181fm station history into CSV

Jul 5th, 2022
1,508
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.65 KB | None
  1. javascript: /* Save 181fm station history into CSV */
  2. fetch(cfg_historyURL + "?i=" + streams[0].id).then(r => r.json().then(j => {
  3.   (r = document.createElement("A")).href = URL.createObjectURL(new Blob([
  4.     "Time,Song,Title,Artist\n" +
  5.     j.map(o => `"${
  6.      Intl.DateTimeFormat(navigator.language, {month: "2-digit", day: "2-digit", year: "numeric", hour12: false, hour: "2-digit", minute: "2-digit", second: "2-digit"}).format(new Date(o.time))
  7.    }","${o.song.replace(/"/g, "'")}","${o.title.replace(/"/g, "'")}","${o.artist.replace(/"/g, "'")}"`).join("\n")
  8.  ], {type: "text/csv"}));
  9.  r.download = document.title + " history.csv";
  10.  r.click()
  11. }))
Advertisement
RAW Paste Data Copied
Advertisement