From 9f9d66afebc59c6c265c4424f7b8fb36d8876541 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Thu, 26 Oct 2023 16:39:03 +0200 Subject: Updated 34 files and added 146 files (automated) --- app/download.php | 74 ++++++++++++++++++++ app/explore.php | 23 ++++++- app/index.php | 46 +++++++++---- app/info.php | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++ app/listing.php | 24 ------- app/lyrics.php | 8 ++- app/modal.php | 48 +++++++++++++ app/navigation.php | 3 + app/player-mobile.php | 2 +- app/queue.php | 78 +++++++++++++++++++++ app/search.php | 91 ++++++++++++++++++++++++ app/settings.php | 2 +- 12 files changed, 542 insertions(+), 43 deletions(-) create mode 100644 app/download.php create mode 100644 app/info.php create mode 100644 app/modal.php create mode 100644 app/queue.php create mode 100644 app/search.php (limited to 'app') diff --git a/app/download.php b/app/download.php new file mode 100644 index 0000000..dd1321c --- /dev/null +++ b/app/download.php @@ -0,0 +1,74 @@ +", ":", "\"", "\\", "|", "?", "*"], "-", $song["artist"] . " - " . $song["title"]); + +function getSize($bytes) { + if ($bytes < 1024) { + return $bytes; + } + + if ($bytes < 1024**2) { + return round($bytes / 1024, 1) . " KB"; + } + + if ($bytes < 1024**3) { + return round($bytes / 1024**2, 1) . " MB"; + } + + return round($bytes / 1024**3, 1) . " GB"; +} + +?> + + + + + + + download + + + + + + + + + + + +
+

+
+ +

+ +

Select the version of the song you would like to download:

+ +
+ + + + \ No newline at end of file diff --git a/app/explore.php b/app/explore.php index a51731b..4887022 100644 --- a/app/explore.php +++ b/app/explore.php @@ -1,4 +1,4 @@ - + @@ -25,7 +25,26 @@

-

Explore

+

Explore

+ +
+
+ + +
+
+ +
+ + +
+
+ +

Upload music to this server

+

Add millions of songs and let your users play them whenever they want.

+
+
+
- +class="web"> @@ -182,8 +182,8 @@ } if (playlist[currentPlaylistPosition + 1]) { - playSong(playlist[currentPlaylistPosition + 1], "keep"); currentPlaylistPosition++; + playSong(playlist[currentPlaylistPosition], "keep", false); } else { stop(); } @@ -307,18 +307,18 @@ playerDocument.getElementById("badge-lossy").style.display = "none"; playerDocument.getElementById("badge-cd").style.display = "none"; playerDocument.getElementById("badge-hires").style.display = "inline"; - playerDocument.getElementById("badge-hires").innerHTML = "Hi-Res Lossless" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000).toFixed(1) + " kHz"; + playerDocument.getElementById("badge-hires").innerHTML = "Hi-Res Lossless" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000) + " kHz"; playerDocumentMobile.getElementById("badge-lossy").style.display = "none"; playerDocumentMobile.getElementById("badge-cd").style.display = "none"; playerDocumentMobile.getElementById("badge-hires").style.display = "inline"; } else if (window.currentSong) { - playerDocument.getElementById("badge-lossy").style.display = "inline"; + playerDocument.getElementById("badge-lossy").style.display = "none"; playerDocument.getElementById("badge-cd").style.display = "inline"; playerDocument.getElementById("badge-hires").style.display = "none"; - playerDocumentMobile.getElementById("badge-lossy").style.display = "inline"; + playerDocumentMobile.getElementById("badge-lossy").style.display = "none"; playerDocumentMobile.getElementById("badge-cd").style.display = "inline"; playerDocumentMobile.getElementById("badge-hires").style.display = "none"; - playerDocument.getElementById("badge-cd").innerHTML = "'>Lossless" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000).toFixed(1) + " kHz"; + playerDocument.getElementById("badge-cd").innerHTML = "Lossless" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000) + " kHz"; } } @@ -347,30 +347,34 @@ } } - window.redownloadFavorite = async () => { + window.redownloadFavorites = async () => { document.getElementById("loading-text").innerText = "Downloading favorites..."; - window.favorites = await (await fetch("/api/getFavorites.php")).json(); + window.favorites = await (await fetch("/api/getFavorites.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json(); } window.redownloadLibrary = async () => { document.getElementById("loading-text").innerText = "Downloading library..."; - window.favorites = await (await fetch("/api/getLibrary.php")).json(); + window.library = await (await fetch("/api/getLibrary.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json(); } (async () => { document.getElementById("loading-text").innerText = "Downloading list of songs..."; - window.songs = await (await fetch("/assets/content/songs.json")).json(); + window.songs = await (await fetch("/assets/content/songs.json?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json(); document.getElementById("loading-text").innerText = "Downloading list of albums..."; - window.albums = await (await fetch("/assets/content/albums.json")).json(); + window.albums = await (await fetch("/assets/content/albums.json?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json(); document.getElementById("loading-text").innerText = "Downloading favorites..."; - window.favorites = await (await fetch("/api/getFavorites.php")).json(); + window.favorites = await (await fetch("/api/getFavorites.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json(); + + document.getElementById("loading-text").innerText = "Downloading library..."; + window.library = await (await fetch("/api/getLibrary.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json(); document.getElementById("loading-text").innerText = "Saving database..."; await localforage.setItem("albums", window.albums); await localforage.setItem("songs", window.songs); await localforage.setItem("favorites", window.favorites); + await localforage.setItem("library", window.library); document.getElementById("loading-text").innerText = "Done loading."; document.getElementById("loading").style.display = "none"; @@ -455,7 +459,7 @@ window.currentPlaylistID = null; - window.playSong = async (id, playlistID) => { + window.playSong = async (id, playlistID, updatePosition) => { playerDocument.getElementById("player-audio").pause(); playerDocument.getElementById("player-audio").currentTime = 0; @@ -471,6 +475,8 @@ } else if (playlistID !== "keep") { window.playlist = [id]; window.currentPlaylistPosition = 0; + } else if (typeof updatePosition !== "boolean" || updatePosition) { + window.currentPlaylistPosition = window.playlist.indexOf(id) ?? 0; } } else { window.currentPlaylistID = null; @@ -481,6 +487,7 @@ window.currentSong = songs[id]; window.currentSongID = id; updateDisplay(); + if (document.getElementById("ui").contentWindow.refreshQueue) document.getElementById("ui").contentWindow.refreshQueue(); if (!window.preloaded[id]) { if (localStorage.getItem("data-saving") === "true") { @@ -547,5 +554,16 @@ } } + + + \ No newline at end of file diff --git a/app/info.php b/app/info.php new file mode 100644 index 0000000..cfc7bc2 --- /dev/null +++ b/app/info.php @@ -0,0 +1,186 @@ +", ":", "\"", "\\", "|", "?", "*"], "-", $song["artist"] . " - " . $song["title"]); + +function getSize($bytes) { + if ($bytes < 1024) { + return $bytes; + } + + if ($bytes < 1024**2) { + return round($bytes / 1024, 1) . " KB"; + } + + if ($bytes < 1024**3) { + return round($bytes / 1024**2, 1) . " MB"; + } + + return round($bytes / 1024**3, 1) . " GB"; +} + +function timeToDuration($seconds) { + $hours = floor($seconds / 3600); + $minutes = floor($seconds / 60) - ($hours * 60); + $seconds = floor($seconds) - ($hours * 3600) - ($minutes * 60); + $parts = []; + + if ($hours > 0) $parts[] = $hours . " hour" . ($hours > 1 ? "s" : ""); + if ($minutes > 0) $parts[] = $minutes . " minute" . ($minutes > 1 ? "s" : ""); + if ($seconds > 0) $parts[] = $seconds . " second" . ($seconds > 1 ? "s" : ""); + + return implode(", ", $parts); +} + +function getBitRate($bits) { + $bitsValue = $bits . " bps"; + + if ($bits > 1000) { + if ($bits > 1000000) { + if ($bits > 1000000000) { + $bitsValue = round($bits / 1000000000, 2) . " Gbps"; + } else { + $bitsValue = round($bits / 1000000, 2) . " Mbps"; + } + } else { + $bitsValue = round($bits / 1000, 2) . " kbps"; + } + } + + $bytesValue = ($bits / 8) . " B/s"; + + if (($bits / 8) > 1000) { + if (($bits / 8) > 1000000) { + if (($bits / 8) > 1000000000) { + $bytesValue = round(($bits / 8) / 1000000000, 2) . " GB/s"; + } else { + $bytesValue = round(($bits / 8) / 1000000, 2) . " MB/s"; + } + } else { + $bytesValue = round(($bits / 8) / 1000, 2) . " kB/s"; + } + } + + return $bitsValue . " (" . $bytesValue . ")"; +} + +function getChannelConfiguration($c) { + if ($c === 1) return " (Mono)"; + if ($c === 2) return " (Stereo)"; + if ($c === 3) return " (Stereo+1)"; + if ($c === 4) return " (3.1)"; + if ($c === 5) return " (4.1 or 5.0 Surround)"; + if ($c === 6) return " (5.1 Surround)"; + if ($c === 7) return " (6.1 or 7.0 Surround)"; + if ($c === 8) return " (7.1 Surround)"; + if ($c === 9) return " (9.0 or 7.2 Spatial Audio)"; + if ($c === 10) return " (9.1 Spatial Audio)"; + if ($c >= 11) return " (Dolby Atmos)"; + return ""; +} + +?> + + + + + + + info + + + + + + + + + + + +
+
+ .jpg" style="aspect-ratio: 1; width: 96px;"> +
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TrackDisc , track 0 ? $song["track"] : "-" ?>
Duration
Bit rate
Sample rate Hz
Bits per sample bits
Channels
Year
High-resolution
Mist StellaNo
Copyright
File size (lossless)
File size (AAC-LC)
+
+ + + + \ No newline at end of file diff --git a/app/listing.php b/app/listing.php index 8ea25d4..9d50178 100644 --- a/app/listing.php +++ b/app/listing.php @@ -148,30 +148,6 @@ if (!$presetList) { } - async function favoriteSong(id) { - document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-on.svg"; - document.getElementById("btn-favorite-" + id).onclick = () => { - unfavoriteSong(id); - } - await fetch("/api/addFavorite.php?i=" + id); - - window.parent.redownloadFavorites(); - } - - async function unfavoriteSong(id) { - document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-off.svg"; - document.getElementById("btn-favorite-" + id).onclick = () => { - favoriteSong(id); - } - await fetch("/api/removeFavorite.php?i=" + id); - - - location.reload(); - - - window.parent.redownloadFavorites(); - } - let items = Array.from(document.getElementsByClassName("track")).map(i => { return { title: i.getAttribute("data-item-track"), artist: i.getAttribute("data-item-artist"), id: i.id } }); const fuse = new Fuse(items, { diff --git a/app/lyrics.php b/app/lyrics.php index fbdca1d..4a7537d 100644 --- a/app/lyrics.php +++ b/app/lyrics.php @@ -59,7 +59,7 @@
- +
@@ -88,6 +88,10 @@ document.getElementById("not-playing").style.display = "none"; if (!window.lyrics[lastID]) { + window.lyricsLoadTimeout = setTimeout(() => { + location.reload(); + }, 10000); + try { window.lyrics[lastID] = await (await fetch("/api/lyrics.php?id=" + lastID)).json() } catch (e) { @@ -97,6 +101,8 @@ } } + clearTimeout(window.lyricsLoadTimeout); + if (window.lyrics[lastID] && window.lyrics[lastID].payload) { if (window.lyrics[lastID].synced) { document.getElementById("lyrics-synced").style.display = ""; diff --git a/app/modal.php b/app/modal.php new file mode 100644 index 0000000..b939996 --- /dev/null +++ b/app/modal.php @@ -0,0 +1,48 @@ + + + + + + + modal + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/navigation.php b/app/navigation.php index f07c38f..00d1457 100644 --- a/app/navigation.php +++ b/app/navigation.php @@ -51,6 +51,9 @@ + diff --git a/app/player-mobile.php b/app/player-mobile.php index cab8ada..8308eda 100644 --- a/app/player-mobile.php +++ b/app/player-mobile.php @@ -26,7 +26,7 @@
-
+
diff --git a/app/queue.php b/app/queue.php new file mode 100644 index 0000000..86fda0e --- /dev/null +++ b/app/queue.php @@ -0,0 +1,78 @@ + + + + + + + + queue + + + + + + + + + + + +
+
+

Queue

+
+ +
+ + + +

+ + \ No newline at end of file diff --git a/app/search.php b/app/search.php new file mode 100644 index 0000000..2f5f164 --- /dev/null +++ b/app/search.php @@ -0,0 +1,91 @@ + + + + + + + + search + + + + + + + + + + + +
+
+

Search results for ""

+ 0; + }); + + uasort($albums, function ($a, $b) { + return strcmp($a["title"], $b["title"]); + }); + + uasort($albums, function ($a, $b) { + return strcmp($a["artist"], $b["artist"]); + }); + + uasort($albums, function ($a, $b) { + return getMatches($b) - getMatches($a); + }); + + $songs = array_filter($songs, function ($i) { + return getMatches($i) > 0; + }); + + uasort($songs, function ($a, $b) { + return getMatches($b) - getMatches($a); + }); + + ?> + + + +
+ +

+ + \ No newline at end of file diff --git a/app/settings.php b/app/settings.php index 4c2a287..a80fad1 100644 --- a/app/settings.php +++ b/app/settings.php @@ -60,7 +60,7 @@
- Mist version (build ) · © Equestria.dev + Mist version (build ) · © Equestria.dev
-- cgit