mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-10 05:39:38 +05:00
add api to get playlist tracks and just track
This commit is contained in:
12
docs/API.md
12
docs/API.md
@@ -26,6 +26,12 @@ Search for users, tracks or playlists. Query parameters are:
|
|||||||
|
|
||||||
For example: `/_/api/search?q=test&type=tracks` to search for `tracks` named `test`
|
For example: `/_/api/search?q=test&type=tracks` to search for `tracks` named `test`
|
||||||
|
|
||||||
|
## GET `/_/api/track/:id`
|
||||||
|
|
||||||
|
Get track by ID.
|
||||||
|
|
||||||
|
For example: `/_/api/track/2014143543` to get track with ID `2014143543`
|
||||||
|
|
||||||
## GET `/_/api/track/:id/related`
|
## GET `/_/api/track/:id/related`
|
||||||
|
|
||||||
Get related tracks by ID. Pagination is supported here. Initial request returns upto 20 tracks
|
Get related tracks by ID. Pagination is supported here. Initial request returns upto 20 tracks
|
||||||
@@ -44,6 +50,12 @@ Get playlist by permalinks.
|
|||||||
|
|
||||||
For example: `/_/api/playlistByPermalink/lucybedroque/sets/unmusique` to get `unmusique` playlist from `lucybedroque`
|
For example: `/_/api/playlistByPermalink/lucybedroque/sets/unmusique` to get `unmusique` playlist from `lucybedroque`
|
||||||
|
|
||||||
|
## GET `/_/api/playlistByPermalink/:author/sets/:playlist/tracks`
|
||||||
|
|
||||||
|
Get list of track IDs in playlist.
|
||||||
|
|
||||||
|
For example: `/_/api/playlistByPermalink/lucybedroque/sets/unmusique/tracks` to get all IDs of the tracks in playlist `unmusique` from `lucybedroque`
|
||||||
|
|
||||||
# Other automation
|
# Other automation
|
||||||
|
|
||||||
Doesn't require API to be enabled
|
Doesn't require API to be enabled
|
||||||
|
|||||||
@@ -79,6 +79,31 @@ func Load(a *fiber.App) {
|
|||||||
return c.JSON(p)
|
return c.JSON(p)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
r.Get("/playlistByPermalink/:author/sets/:playlist/tracks", func(c fiber.Ctx) error {
|
||||||
|
p, err := sc.GetPlaylist("", c.Params("author")+"/sets/"+c.Params("playlist"))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[API] error getting %s playlist tracks from %s: %s\n", c.Params("playlist"), c.Params("author"), err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tracks := make([]json.Number, len(p.Tracks))
|
||||||
|
for i, t := range p.Tracks {
|
||||||
|
tracks[i] = t.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.JSON(tracks)
|
||||||
|
})
|
||||||
|
|
||||||
|
r.Get("/track/:id", func(c fiber.Ctx) error {
|
||||||
|
t, err := sc.GetTrackByID("", c.Params("id"))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[API] error getting track %s: %s\n", c.Params("id"), err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.JSON(t)
|
||||||
|
})
|
||||||
|
|
||||||
r.Get("/tracks", func(c fiber.Ctx) error {
|
r.Get("/tracks", func(c fiber.Ctx) error {
|
||||||
ids := cfg.B2s(c.RequestCtx().QueryArgs().Peek("ids"))
|
ids := cfg.B2s(c.RequestCtx().QueryArgs().Peek("ids"))
|
||||||
t, err := sc.GetTracks("", ids)
|
t, err := sc.GetTracks("", ids)
|
||||||
|
|||||||
Reference in New Issue
Block a user