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:
15
player.js
15
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);
|
||||
|
||||
Reference in New Issue
Block a user