From b9a255e13acab4b182f9499a6d943385349cd85b Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Mon, 5 Dec 2022 03:43:35 +0530 Subject: Adds Playlist Download * Removed unusable history.json * Adds legit m3u playlist download so that users can load it into mpd or other music players --- player.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/player.js b/player.js index d2326d5..43408aa 100644 --- a/player.js +++ b/player.js @@ -200,12 +200,21 @@ function downloadHistory() { const historyArray = getHistory(); 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( "href", - "data:application/json;charset=utf-8," + - encodeURIComponent(JSON.stringify(historyArray)) + "data:audio/x-mpegurl;;charset=utf-8," + + encodeURIComponent(playListData) ); - element.setAttribute("download", "history.json"); + element.setAttribute("download", "retrowave_playlist.m3u"); element.style.display = "none"; document.body.appendChild(element); -- cgit v1.2.3