diff --git a/static/password/index.html b/static/password/index.html
index 2c1525f..91b3c74 100644
--- a/static/password/index.html
+++ b/static/password/index.html
@@ -10,7 +10,7 @@
-
+
diff --git a/templates/player.html b/templates/player.html
index 55fb8bd..ab11931 100644
--- a/templates/player.html
+++ b/templates/player.html
@@ -68,10 +68,14 @@
@@ -109,6 +113,7 @@
const songs = Array.from(document.getElementById("songs").children).map((c) => c.innerText);
let playable_songs = songs;
let played = [];
+ let history = []; //like played but with more info
let queue = [];
let queue_id_counter = 0;
let show_title = false;
@@ -120,6 +125,13 @@
//"ended" event
function next_song() {
+ if (audio_ele.currentSrc !== "") {
+ history.push({
+ name: played[played.length - 1],
+ length: audio_ele.duration,
+ ended: audio_ele.currentTime,
+ });
+ }
captions_box.innerHTML = "";
const not_played = playable_songs.filter((song) => !played.includes(song));
if (not_played.length === 0) return;
@@ -220,6 +232,44 @@
}
filter_select_all();
+
+ //playlist file format is just newline separated artist-song
+
+ function download_queue_as_playlist() {
+ let a = document.createElement("A");
+ a.href = `data:text/plain;charset=utf-8,${encodeURIComponent(queue.map((q) => q[0]).join("\n"))}`;
+ a.download = "queue.playlist";
+ a.style.display = "none";
+ document.body.appendChild(a);
+ a.click();
+ }
+
+ function upload_playlist() {
+ let reader = new FileReader();
+ reader.readAsText(document.getElementById("playlist-upload").files[0]);
+ reader.addEventListener("load", () => {
+ let playlist_songs = reader.result.split("\n");
+ let randomized = [];
+ while (randomized.length < playlist_songs.length) {
+ let rand = Math.floor(Math.random() * playlist_songs.length);
+ if (!randomized.includes(playlist_songs[rand])) {
+ randomized.push(playlist_songs[rand]);
+ }
+ }
+ for (const n of randomized) {
+ add_to_queue(n);
+ }
+ });
+ }
+
+ function download_history() {
+ let a = document.createElement("A");
+ a.href = `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(history))}`;
+ a.download = "queue.playlist";
+ a.style.display = "none";
+ document.body.appendChild(a);
+ a.click();
+ }