mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-27 06:02:17 +03:00
Add getVideos() call.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
parent
c5bf541c45
commit
d26b6dce7d
@ -0,0 +1,37 @@
|
|||||||
|
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 [SubsonicAPIDefinition.getVideos] call.
|
||||||
|
*/
|
||||||
|
class SubsonicApiGetVideosListTest : SubsonicAPIClientTest() {
|
||||||
|
@Test
|
||||||
|
fun `Should handle error response`() {
|
||||||
|
val response = checkErrorCallParsed(mockWebServerRule) {
|
||||||
|
client.api.getVideos().execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
response.videosList `should equal` emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Should handle ok response`() {
|
||||||
|
mockWebServerRule.enqueueResponse("get_videos_ok.json")
|
||||||
|
|
||||||
|
val response = client.api.getVideos().execute()
|
||||||
|
|
||||||
|
assertResponseSuccessful(response)
|
||||||
|
with(response.body().videosList) {
|
||||||
|
size `should equal to` 1
|
||||||
|
this[0] `should equal` MusicDirectoryChild(id = 10402, parent = 10401, isDir = false,
|
||||||
|
title = "MVI_0512", album = "Incoming", size = 21889646,
|
||||||
|
contentType = "video/avi", suffix = "avi", transcodedContentType = "video/x-flv",
|
||||||
|
transcodedSuffix = "flv", path = "Incoming/MVI_0512.avi", isVideo = true,
|
||||||
|
playCount = 0, created = parseDate("2017-11-19T12:34:33.000Z"), type = "video")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"subsonic-response" : {
|
||||||
|
"status" : "ok",
|
||||||
|
"version" : "1.15.0",
|
||||||
|
"videos" : {
|
||||||
|
"video" : [ {
|
||||||
|
"id" : "10402",
|
||||||
|
"parent" : "10401",
|
||||||
|
"isDir" : false,
|
||||||
|
"title" : "MVI_0512",
|
||||||
|
"album" : "Incoming",
|
||||||
|
"size" : 21889646,
|
||||||
|
"contentType" : "video/avi",
|
||||||
|
"suffix" : "avi",
|
||||||
|
"transcodedContentType" : "video/x-flv",
|
||||||
|
"transcodedSuffix" : "flv",
|
||||||
|
"path" : "Incoming/MVI_0512.avi",
|
||||||
|
"isVideo" : true,
|
||||||
|
"playCount" : 0,
|
||||||
|
"created" : "2017-11-19T12:34:33.000Z",
|
||||||
|
"type" : "video"
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,7 @@ import org.moire.ultrasonic.api.subsonic.response.SearchThreeResponse
|
|||||||
import org.moire.ultrasonic.api.subsonic.response.SearchTwoResponse
|
import org.moire.ultrasonic.api.subsonic.response.SearchTwoResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.SharesResponse
|
import org.moire.ultrasonic.api.subsonic.response.SharesResponse
|
||||||
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
import org.moire.ultrasonic.api.subsonic.response.SubsonicResponse
|
||||||
|
import org.moire.ultrasonic.api.subsonic.response.VideosResponse
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.Header
|
import retrofit2.http.Header
|
||||||
@ -233,4 +234,7 @@ interface SubsonicAPIDefinition {
|
|||||||
|
|
||||||
@GET("deleteBookmark.view")
|
@GET("deleteBookmark.view")
|
||||||
fun deleteBookmark(@Query("id") id: Int): Call<SubsonicResponse>
|
fun deleteBookmark(@Query("id") id: Int): Call<SubsonicResponse>
|
||||||
|
|
||||||
|
@GET("getVideos.view")
|
||||||
|
fun getVideos(): Call<VideosResponse>
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.moire.ultrasonic.api.subsonic.response
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicAPIVersions
|
||||||
|
import org.moire.ultrasonic.api.subsonic.SubsonicError
|
||||||
|
import org.moire.ultrasonic.api.subsonic.models.MusicDirectoryChild
|
||||||
|
|
||||||
|
class VideosResponse(
|
||||||
|
status: Status,
|
||||||
|
version: SubsonicAPIVersions,
|
||||||
|
error: SubsonicError?) : SubsonicResponse(status, version, error) {
|
||||||
|
@JsonProperty("videos") private val videosWrapper = VideosWrapper()
|
||||||
|
|
||||||
|
val videosList: List<MusicDirectoryChild> get() = videosWrapper.videosList
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class VideosWrapper(
|
||||||
|
@JsonProperty("video") val videosList: List<MusicDirectoryChild> = emptyList())
|
Loading…
x
Reference in New Issue
Block a user