From a22a33cc025b93b49ae0e5bff9e16809120b6d51 Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 20 May 2024 00:21:38 +0300 Subject: [PATCH 01/13] chore(download): download the first 5 songs in a search results --- services/youtube/download/download.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/youtube/download/download.go b/services/youtube/download/download.go index 1775277..7223c3f 100644 --- a/services/youtube/download/download.go +++ b/services/youtube/download/download.go @@ -8,6 +8,7 @@ import ( "dankmuzikk/models" "errors" "fmt" + "math" "net/http" "os" ) @@ -99,5 +100,12 @@ func (d *Service) DownloadYoutubeSongsMetadata(songs []entities.Song) error { } } + for i := 0; i < int(math.Min(float64(len(newSongs)), 5)); i++ { + err := d.DownloadYoutubeSongQueue(newSongs[i].YtId) + if err != nil { + log.Errorln(err) + } + } + return nil } From d451d8002d1eb7037d9c1d718123158cc2d814c2 Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 20 May 2024 00:22:15 +0300 Subject: [PATCH 02/13] fix(mobile-view): safe check is mobile --- views/components/header/header.templ | 2 +- views/components/player/player.templ | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/views/components/header/header.templ b/views/components/header/header.templ index d0d313c..ec821db 100644 --- a/views/components/header/header.templ +++ b/views/components/header/header.templ @@ -82,7 +82,7 @@ templ desktopHeader() { templ Header() {
// mobiles are usually shitty at rendering, so this prevents mobiles from rendering two blocks and choosing one using CSS. - if ctx.Value("is-mobile").(bool) { + if isMobile, ok := ctx.Value("is-mobile").(bool); ok && isMobile { @mobileHeader() } else {
diff --git a/views/components/player/player.templ b/views/components/player/player.templ index 539aa2d..9846def 100644 --- a/views/components/player/player.templ +++ b/views/components/player/player.templ @@ -2,7 +2,7 @@ package player templ PlayerSticky() {
- @popover.Popover(song.YtId, "Options", songOptionsToggle(), songOptions(song, pl.PublicId)) + if isMobile, ok := ctx.Value("is-mobile").(bool); ok && isMobile { + @popover.Popover(song.YtId, "Options", songOptionsToggle(), songOptionsMobile(song, pl.PublicId)) + } else { + @popover.Popover(song.YtId, "Options", songOptionsToggle(), songOptions(song, pl.PublicId)) + }
@@ -98,23 +104,50 @@ templ songOptionsToggle() { } +//if isMobile, ok := ctx.Value("is-mobile").(bool); ok && isMobile { templ songOptions(song entities.Song, playlistId string) {
+

Options

+ +
+} + +templ songOptionsMobile(song entities.Song, playlistId string) { +
-

Song's options

+

Details and options

+

Added on { song.AddedAt }

+ if song.PlayTimes == 1 { +

Played once

+ } else if song.PlayTimes > 1 { +

Played { fmt.Sprint( song.PlayTimes) } times

+ } + >Remove from playlist
} From d64ddd848597e8c3f37663ffdc9b297a2729d480 Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 20 May 2024 01:06:21 +0300 Subject: [PATCH 04/13] haha lol --- services/youtube/download/download.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/youtube/download/download.go b/services/youtube/download/download.go index 7223c3f..62b1d44 100644 --- a/services/youtube/download/download.go +++ b/services/youtube/download/download.go @@ -100,8 +100,8 @@ func (d *Service) DownloadYoutubeSongsMetadata(songs []entities.Song) error { } } - for i := 0; i < int(math.Min(float64(len(newSongs)), 5)); i++ { - err := d.DownloadYoutubeSongQueue(newSongs[i].YtId) + for i := 0; i < int(math.Min(float64(len(songs)), 5)); i++ { + err := d.DownloadYoutubeSongQueue(songs[i].YtId) if err != nil { log.Errorln(err) } From 8e623969e7471590f943d4a30cc6523e249e9b09 Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 20 May 2024 02:11:13 +0300 Subject: [PATCH 05/13] chore(playlist): update song's details max width --- views/pages/playlist.templ | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/views/pages/playlist.templ b/views/pages/playlist.templ index 3d9f074..8d840ca 100644 --- a/views/pages/playlist.templ +++ b/views/pages/playlist.templ @@ -66,14 +66,14 @@ templ Playlist(pl entities.Playlist) { class={ "cursor-pointer", "flex", "flex-col", "lg:gap-2" } onClick={ playSongFromPlaylist(song.YtId, pl) } > -

{ song.Title }

-

{ song.Artist }

+

{ song.Title }

+

{ song.Artist }

if isMobile, ok := ctx.Value("is-mobile").(bool); ok && !isMobile {

Added on { song.AddedAt }

if song.PlayTimes == 1 { -

Played once

+

Played once

} else if song.PlayTimes > 1 { -

Played { fmt.Sprint( song.PlayTimes) } times

+

Played { fmt.Sprint( song.PlayTimes) } times

} } @@ -135,9 +135,9 @@ templ songOptionsMobile(song entities.Song, playlistId string) {

Details and options

Added on { song.AddedAt }

if song.PlayTimes == 1 { -

Played once

+

Played once

} else if song.PlayTimes > 1 { -

Played { fmt.Sprint( song.PlayTimes) } times

+

Played { fmt.Sprint( song.PlayTimes) } times

}