From b71b5d4ba994f00cdc84bec8147e40940db5a519 Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 1 Jul 2024 03:21:27 +0300 Subject: [PATCH 1/9] fix(popover-up): close for different screen sizes --- app/static/js/utils.js | 2 +- app/views/components/menus/popover_up.templ | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/static/js/utils.js b/app/static/js/utils.js index ce384e7..a987ab2 100644 --- a/app/static/js/utils.js +++ b/app/static/js/utils.js @@ -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; diff --git a/app/views/components/menus/popover_up.templ b/app/views/components/menus/popover_up.templ index fc06b92..7c98125 100644 --- a/app/views/components/menus/popover_up.templ +++ b/app/views/components/menus/popover_up.templ @@ -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"; From 980f9eed8746e1bf96684836760701ba3da25bf5 Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 1 Jul 2024 13:27:23 +0300 Subject: [PATCH 2/9] fix(playlist): download files issue --- app/services/playlists/playlists.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/services/playlists/playlists.go b/app/services/playlists/playlists.go index 5c65a96..f769b28 100644 --- a/app/services/playlists/playlists.go +++ b/app/services/playlists/playlists.go @@ -317,7 +317,10 @@ func (p *Service) Download(playlistPubId string, ownerId uint) (io.Reader, error fmt.Sprintf("%s/%d-%s.mp3", config.Env().YouTube.MusicDir, i+1, song.Title), os.O_WRONLY|os.O_CREATE, 0644, ) - io.Copy(newShit, ogFile) + if err != nil { + return nil, err + } + _, _ = io.Copy(newShit, ogFile) fileNames[i] = newShit.Name() _ = newShit.Close() _ = ogFile.Close() From 22ab02446478426719979a2d2ebbe504b243362c Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 1 Jul 2024 14:32:08 +0300 Subject: [PATCH 3/9] fix(playlist): file name in downloaded playlists --- app/services/playlists/playlists.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/services/playlists/playlists.go b/app/services/playlists/playlists.go index f769b28..e8d2b80 100644 --- a/app/services/playlists/playlists.go +++ b/app/services/playlists/playlists.go @@ -11,6 +11,8 @@ import ( "fmt" "io" "os" + "path/filepath" + "strings" "time" ) @@ -314,13 +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, ) if err != nil { + _ = ogFile.Close() + return nil, err + } + _, err = io.Copy(newShit, ogFile) + if err != nil { + _ = ogFile.Close() return nil, err } - _, _ = io.Copy(newShit, ogFile) fileNames[i] = newShit.Name() _ = newShit.Close() _ = ogFile.Close() From a24956b402bb5bc48be50b739823ecd6171cfd2b Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Tue, 2 Jul 2024 15:51:47 +0300 Subject: [PATCH 4/9] fix(player): add source for webkit :) --- app/static/js/player.js | 3 ++- app/views/components/player/player.templ | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/static/js/player.js b/app/static/js/player.js index 2ec13fb..1b550e7 100644 --- a/app/static/js/player.js +++ b/app/static/js/player.js @@ -615,7 +615,8 @@ async function playSong(song) { await downloadSong(song.yt_id).then(() => { stopMuzikk(); - audioPlayerEl.src = `/muzikkx/${song.yt_id}.mp3`; + audioPlayerEl.children.item(0).src = + `${location.protocol}//${location.host}/muzikkx/${song.yt_id}.mp3`; audioPlayerEl.load(); }); diff --git a/app/views/components/player/player.templ b/app/views/components/player/player.templ index fcef289..b3b681e 100644 --- a/app/views/components/player/player.templ +++ b/app/views/components/player/player.templ @@ -31,13 +31,14 @@ templ PlayerSticky() { - + ///