Added avoid param to next

This commit is contained in:
Shiny Nematoda
2023-04-07 15:40:40 +00:00
parent 01be66bd7f
commit c1c8e86d7c
4 changed files with 13 additions and 6 deletions
+2 -1
View File
@@ -26,9 +26,10 @@ https://codeberg.org/Hyperpipe/Hyperpipe
### `GET` `/charts?params=${id}&code=${code}`
### `GET` `/next/:id`
### `GET` `/next/:id?queue=${queue}`
- `:id` -> `song id (same as /watch?v=:id)`
- `$queue` -> `avoid` (optional)
### `GET` `/lyrics/:id`
+4
View File
@@ -128,6 +128,10 @@ func GetArtist(id string) (Artist, int) {
func GetArtistNext(id, params, ct, v string) (ArtistNext, int) {
if id == "" || params == "" || ct == "" || v == "" {
return ArtistNext{}, 404
}
context := utils.TypeBrowse(id, params, []string{ct, v})
raw, status := utils.FetchBrowse(context)
+6 -4
View File
@@ -82,7 +82,7 @@ func parseNext(raw string) Next {
}
}
func GetNext(id string) (Next, int) {
func GetNext(id, queue string) (Next, int) {
pldata, err := json.Marshal(utils.TypeNext(id, ""))
if err != nil {
@@ -94,6 +94,10 @@ func GetNext(id string) (Next, int) {
return Next{Err: err}, plstatus
}
if queue == "avoid" {
return parseNext(plraw), plstatus
}
pl := gjson.Parse(plraw).Get(
"contents.singleColumnMusicWatchNextResultsRenderer." +
"tabbedRenderer.watchNextTabbedResultsRenderer.tabs.0.tabRenderer.content." +
@@ -112,7 +116,5 @@ func GetNext(id string) (Next, int) {
return Next{Err: err}, 500
}
res := parseNext(raw)
return res, status
return parseNext(raw), status
}
+1 -1
View File
@@ -32,7 +32,7 @@ func HandleExplore(c *fiber.Ctx) error {
}
func HandleNext(c *fiber.Ctx) error {
res, status := lib.GetNext(c.Params("id"))
res, status := lib.GetNext(c.Params("id"), c.Query("queue"))
return c.Status(status).JSON(res)
}