Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v0.1.51 #88

Merged
merged 9 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app/services/playlists/playlists.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"time"
)

Expand Down Expand Up @@ -314,10 +316,22 @@ func (p *Service) Download(playlistPubId string, ownerId uint) (io.Reader, error
return nil, err
}
newShit, err := os.OpenFile(
fmt.Sprintf("%s/%d-%s.mp3", config.Env().YouTube.MusicDir, i+1, song.Title),
filepath.Clean(
fmt.Sprintf("%s/%d-%s.mp3", config.Env().YouTube.MusicDir, i+1,
strings.ReplaceAll(song.Title, "/", "|"),
),
),
os.O_WRONLY|os.O_CREATE, 0644,
)
io.Copy(newShit, ogFile)
if err != nil {
_ = ogFile.Close()
return nil, err
}
_, err = io.Copy(newShit, ogFile)
if err != nil {
_ = ogFile.Close()
return nil, err
}
fileNames[i] = newShit.Name()
_ = newShit.Close()
_ = ogFile.Close()
Expand Down
29 changes: 22 additions & 7 deletions app/static/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ function playPauser(audioEl) {
*/
function stopper(audioEl) {
return () => {
audioEl.pause();
audioEl.currentTime = 0;
if (!audioEl.paused) {
audioEl.pause();
audioEl.currentTime = 0;
}
const songEl = document.getElementById(
"song-" + playerState.playlist.songs[playerState.currentSongIdx].yt_id,
);
Expand Down Expand Up @@ -613,11 +615,18 @@ async function playSong(song) {
setLoading(true);
show();

await downloadSong(song.yt_id).then(() => {
stopMuzikk();
audioPlayerEl.src = `/muzikkx/${song.yt_id}.mp3`;
audioPlayerEl.load();
});
const resp = await downloadSong(song.yt_id);
if (!resp.ok) {
alert("Something went wrong when downloading the song...");
return;
}
stopMuzikk();
if (audioPlayerEl.childNodes.length > 0) {
audioPlayerEl.removeChild(audioPlayerEl.childNodes.item(0));
}
const src = document.createElement("source");
src.src = `${location.protocol}//${location.host}/muzikkx/${song.yt_id}.mp3`;
audioPlayerEl.appendChild(src);

// song's details setting, yada yada
{
Expand Down Expand Up @@ -659,6 +668,12 @@ async function playSong(song) {
songImageExpandedEl.innerHTML = "";
}
}
{
setTimeout(75);
audioPlayerEl.load();
setTimeout(75);
audioPlayerEl.load();
}
setMediaSessionMetadata(song);
playMuzikk();
await updateSongPlays();
Expand Down
2 changes: 1 addition & 1 deletion app/static/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function menuer() {
e.clientX < rect.left ||
e.clientX > rect.right ||
e.clientY + parentRect.height + 5 < rect.top ||
e.clientY > rect.bottom
e.clientY > rect.bottom + parentRect.height + 5
) {
lastEl.style.display = "none";
lastEl = null;
Expand Down
1 change: 1 addition & 0 deletions app/views/components/menus/popover_up.templ
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ css top(topVal string) {

script toggleTheThingUp(id string) {
id = `popover-${id}`;
Utils.registerPopover(id);
const popover = document.getElementById(id);
if (popover.style.display !== "block") {
popover.style.display = "block";
Expand Down
13 changes: 6 additions & 7 deletions app/views/components/player/player.templ
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ templ PlayerSticky() {
</div>
</div>
</div>
<div class="hidden">
<audio
id="audio-player"
controls
preload="none"
></audio>
</div>
<audio
class="hidden"
id="audio-player"
controls
preload="none"
></audio>
///
<style>
.collapsed {
Expand Down