Add getPlaylist call to subsonic api.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
35e74a758e
commit
b73cc0f816
|
@ -0,0 +1,57 @@
|
|||
package org.moire.ultrasonic.api.subsonic
|
||||
|
||||
import org.amshove.kluent.`should equal to`
|
||||
import org.amshove.kluent.`should equal`
|
||||
import org.junit.Test
|
||||
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
|
||||
|
||||
/**
|
||||
* Integration test for [SubsonicAPIClient] for getPlaylist call.
|
||||
*/
|
||||
class SubsonicApiGetPlaylistTest : SubsonicAPIClientTest() {
|
||||
@Test
|
||||
fun `Should parse error response`() {
|
||||
checkErrorCallParsed(mockWebServerRule) {
|
||||
client.api.getPlaylist(10).execute()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should parse ok response`() {
|
||||
mockWebServerRule.enqueueResponse("get_playlist_ok.json")
|
||||
|
||||
val response = client.api.getPlaylist(4).execute()
|
||||
|
||||
assertResponseSuccessful(response)
|
||||
with(response.body().playlist) {
|
||||
id `should equal to` 0
|
||||
name `should equal to` "Aug 27, 2017 11:17 AM"
|
||||
owner `should equal to` "admin"
|
||||
public `should equal to` false
|
||||
songCount `should equal to` 16
|
||||
duration `should equal to` 3573
|
||||
created `should equal` parseDate("2017-08-27T11:17:26.216Z")
|
||||
changed `should equal` parseDate("2017-08-27T11:17:26.218Z")
|
||||
coverArt `should equal to` "pl-0"
|
||||
entriesList.size `should equal to` 2
|
||||
entriesList[1] `should equal` MusicDirectoryChild(id = 4215, parent = 4186,
|
||||
isDir = false, title = "Going to Hell", album = "Going to Hell",
|
||||
artist = "The Pretty Reckless", track = 2, year = 2014,
|
||||
genre = "Hard Rock", coverArt = "4186", size = 11089627,
|
||||
contentType = "audio/mpeg", suffix = "mp3", duration = 277, bitRate = 320,
|
||||
path = "The Pretty Reckless/Going to Hell/02 Going to Hell.mp3",
|
||||
isVideo = false, playCount = 0, discNumber = 1,
|
||||
created = parseDate("2016-10-23T21:30:41.000Z"),
|
||||
albumId = 388, artistId = 238, type = "music")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Should pass id as request param`() {
|
||||
val playlistId = 453L
|
||||
mockWebServerRule.assertRequestParam(responseResourceName = "get_playlist_ok.json",
|
||||
apiRequest = {
|
||||
client.api.getPlaylist(playlistId).execute()
|
||||
}, expectedParam = "id=$playlistId")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"subsonic-response" : {
|
||||
"status" : "ok",
|
||||
"version" : "1.15.0",
|
||||
"playlist" : {
|
||||
"id" : "0",
|
||||
"name" : "Aug 27, 2017 11:17 AM",
|
||||
"owner" : "admin",
|
||||
"public" : false,
|
||||
"songCount" : 16,
|
||||
"duration" : 3573,
|
||||
"created" : "2017-08-27T11:17:26.216Z",
|
||||
"changed" : "2017-08-27T11:17:26.218Z",
|
||||
"coverArt" : "pl-0",
|
||||
"entry" : [ {
|
||||
"id" : "4209",
|
||||
"parent" : "4186",
|
||||
"isDir" : false,
|
||||
"title" : "Follow Me Down",
|
||||
"album" : "Going to Hell",
|
||||
"artist" : "The Pretty Reckless",
|
||||
"track" : 1,
|
||||
"year" : 2014,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "4186",
|
||||
"size" : 11229681,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 280,
|
||||
"bitRate" : 320,
|
||||
"path" : "The Pretty Reckless/Going to Hell/01 Follow Me Down.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 1,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T21:30:43.000Z",
|
||||
"albumId" : "388",
|
||||
"artistId" : "238",
|
||||
"type" : "music"
|
||||
}, {
|
||||
"id" : "4215",
|
||||
"parent" : "4186",
|
||||
"isDir" : false,
|
||||
"title" : "Going to Hell",
|
||||
"album" : "Going to Hell",
|
||||
"artist" : "The Pretty Reckless",
|
||||
"track" : 2,
|
||||
"year" : 2014,
|
||||
"genre" : "Hard Rock",
|
||||
"coverArt" : "4186",
|
||||
"size" : 11089627,
|
||||
"contentType" : "audio/mpeg",
|
||||
"suffix" : "mp3",
|
||||
"duration" : 277,
|
||||
"bitRate" : 320,
|
||||
"path" : "The Pretty Reckless/Going to Hell/02 Going to Hell.mp3",
|
||||
"isVideo" : false,
|
||||
"playCount" : 0,
|
||||
"discNumber" : 1,
|
||||
"created" : "2016-10-23T21:30:41.000Z",
|
||||
"albumId" : "388",
|
||||
"artistId" : "238",
|
||||
"type" : "music"
|
||||
} ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,11 +5,12 @@ import org.moire.ultrasonic.api.subsonic.response.GetArtistResponse
|
|||
import org.moire.ultrasonic.api.subsonic.response.GetArtistsResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetIndexesResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetMusicDirectoryResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.GetPlaylistResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.LicenseResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.MusicFoldersResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.SearchTwoResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.SearchResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.SearchThreeResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.SearchTwoResponse
|
||||
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
||||
import retrofit2.Call
|
||||
import retrofit2.http.GET
|
||||
|
@ -83,4 +84,7 @@ interface SubsonicAPIDefinition {
|
|||
@Query("albumOffset") albumOffset: Int? = null,
|
||||
@Query("songCount") songCount: Int? = null,
|
||||
@Query("musicFolderId") musicFolderId: Long? = null): Call<SearchThreeResponse>
|
||||
|
||||
@GET("getPlaylist.view")
|
||||
fun getPlaylist(@Query("id") id: Long): Call<GetPlaylistResponse>
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.moire.ultrasonic.api.subsonic.models
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import java.util.Calendar
|
||||
|
||||
data class Playlist(
|
||||
val id: Long = -1,
|
||||
val name: String = "",
|
||||
val owner: String = "",
|
||||
val public: Boolean = false,
|
||||
val songCount: Int = 0,
|
||||
val duration: Long = 0,
|
||||
val created: Calendar? = null,
|
||||
val changed: Calendar? = null,
|
||||
val coverArt: String = "",
|
||||
@JsonProperty("entry") val entriesList: List<MusicDirectoryChild> = emptyList()
|
||||
)
|
|
@ -0,0 +1,11 @@
|
|||
package org.moire.ultrasonic.api.subsonic.response
|
||||
|
||||
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
|
||||
import org.moire.ultrasonic.api.subsonic.SubsonicError
|
||||
import org.moire.ultrasonic.api.subsonic.models.Playlist
|
||||
|
||||
class GetPlaylistResponse(
|
||||
status: Status,
|
||||
version: SubsonicAPIVersions,
|
||||
error: SubsonicError?,
|
||||
val playlist: Playlist = Playlist()) : SubsonicResponse(status, version, error)
|
Loading…
Reference in New Issue