Skip to content

Commit

Permalink
Merge pull request lavalink-devs#478 from TopiSenpai/feature/source-n…
Browse files Browse the repository at this point in the history
…ame-in-track-info

source name in track info
  • Loading branch information
freyacodes authored Apr 20, 2021
2 parents 8155ac2 + 73c4c4d commit 97424f0
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
62 changes: 61 additions & 1 deletion IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ Response:
"isStream": false,
"position": 0,
"title": "Rick Astley - Never Gonna Give You Up",
"uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
"uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"sourceName": "youtube"
}
}
]
Expand Down Expand Up @@ -426,6 +427,65 @@ A severity level of `COMMON` indicates that the error is non-fatal and that the
}
```

### Track Decoding API

Decode a single track into its info
```
GET /decodetrack?track=QAAAjQIAJVJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXAADlJpY2tBc3RsZXlWRVZPAAAAAAADPCAAC2RRdzR3OVdnWGNRAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9ZFF3NHc5V2dYY1EAB3lvdXR1YmUAAAAAAAAAAA== HTTP/1.1
Host: localhost:8080
Authorization: youshallnotpass
```

Response:
```json
{
"identifier": "dQw4w9WgXcQ",
"isSeekable": true,
"author": "RickAstleyVEVO",
"length": 212000,
"isStream": false,
"position": 0,
"title": "Rick Astley - Never Gonna Give You Up",
"uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"sourceName": "youtube"
}
```

Decode multiple tracks into info their info
```
POST /decodetracks HTTP/1.1
Host: localhost:8080
Authorization: youshallnotpass
```

Request:
```json
[
"QAAAjQIAJVJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXAADlJpY2tBc3RsZXlWRVZPAAAAAAADPCAAC2RRdzR3OVdnWGNRAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9ZFF3NHc5V2dYY1EAB3lvdXR1YmUAAAAAAAAAAA==",
...
]
```

Response:
```json
[
{
"track": "QAAAjQIAJVJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXAADlJpY2tBc3RsZXlWRVZPAAAAAAADPCAAC2RRdzR3OVdnWGNRAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9ZFF3NHc5V2dYY1EAB3lvdXR1YmUAAAAAAAAAAA==",
"info": {
"identifier": "dQw4w9WgXcQ",
"isSeekable": true,
"author": "RickAstleyVEVO",
"length": 212000,
"isStream": false,
"position": 0,
"title": "Rick Astley - Never Gonna Give You Up",
"uri": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"sourceName": "youtube"
}
},
...
]
```
---

### RoutePlanner API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private JSONObject trackToJSON(AudioTrack audioTrack) {
.put("uri", trackInfo.uri)
.put("isStream", trackInfo.isStream)
.put("isSeekable", audioTrack.isSeekable())
.put("position", audioTrack.getPosition());
.put("position", audioTrack.getPosition())
.put("sourceName", audioTrack.getSourceManager() == null ? null : audioTrack.getSourceManager().getSourceName());
}

private JSONObject encodeLoadResult(LoadResult result) {
Expand Down

0 comments on commit 97424f0

Please sign in to comment.