mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-11 14:19:38 +05:00
paginate large playlists
This commit is contained in:
13
main.go
13
main.go
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/compress"
|
||||
@@ -112,6 +113,18 @@ func main() {
|
||||
return err
|
||||
}
|
||||
|
||||
p := c.Query("pagination")
|
||||
if p != "" {
|
||||
tracks, next, err := sc.GetNextMissingTracks(p)
|
||||
if err != nil {
|
||||
fmt.Printf("error getting %s playlist tracks from %s: %s\n", c.Params("playlist"), c.Params("user"), err)
|
||||
return err
|
||||
}
|
||||
|
||||
playlist.Tracks = tracks
|
||||
playlist.MissingTracks = strings.Join(next, ",")
|
||||
}
|
||||
|
||||
c.Set("Content-Type", "text/html")
|
||||
return templates.Base(playlist.Title+" by "+playlist.Author.Username, templates.Playlist(playlist), templates.PlaylistEmbed(playlist)).Render(context.Background(), c)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user