Adds Playlist Download

* Removed unusable history.json
* Adds legit m3u playlist download so that users can load it
into mpd or other music players
This commit is contained in:
Indrajith K L
2022-12-05 03:43:35 +05:30
parent af7303fc62
commit b9a255e13a

View File

@@ -200,12 +200,21 @@
function downloadHistory() { function downloadHistory() {
const historyArray = getHistory(); const historyArray = getHistory();
let element = document.createElement("a"); let element = document.createElement("a");
let playListData = '#EXTM3U';
historyArray.forEach((musicData) => {
playListData = `${playListData}
#EXTINF:${(musicData.duration/60000).toFixed(2)}, ${musicData.title}
https://retrowave.ru/${musicData.streamUrl}
`;
});
element.setAttribute( element.setAttribute(
"href", "href",
"data:application/json;charset=utf-8," + "data:audio/x-mpegurl;;charset=utf-8," +
encodeURIComponent(JSON.stringify(historyArray)) encodeURIComponent(playListData)
); );
element.setAttribute("download", "history.json"); element.setAttribute("download", "retrowave_playlist.m3u");
element.style.display = "none"; element.style.display = "none";
document.body.appendChild(element); document.body.appendChild(element);