fix crash in TMDBApiController when searchMovie() returns no title

* make title/name optional
* for movies use the movie search endpoint instead of multi

fixes #65
This commit is contained in:
Jannik 2022-09-21 21:06:52 +02:00
parent d3fe81224b
commit fa28eb35ab
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
2 changed files with 7 additions and 7 deletions

View File

@ -90,7 +90,7 @@ class TMDBApiController {
* NoneTMDBSearchMovie if nothing was found
*/
suspend fun searchMovie(query: String): TMDBSearch<TMDBSearchResultMovie> {
val searchEndpoint = "/search/multi"
val searchEndpoint = "/search/movie"
val parameters = listOf("query" to query, "include_adult" to false)
return try {

View File

@ -32,7 +32,7 @@ import kotlinx.serialization.Serializable
interface TMDBResult {
val id: Int
val name: String
val name: String? // for movies tmdb return string or null
val overview: String? // for movies tmdb return string or null
val posterPath: String?
val backdropPath: String?
@ -40,7 +40,7 @@ interface TMDBResult {
data class TMDBBase(
override val id: Int,
override val name: String,
override val name: String?,
override val overview: String?,
override val posterPath: String?,
override val backdropPath: String?
@ -59,7 +59,7 @@ data class TMDBSearch<T>(
@Serializable
data class TMDBSearchResultMovie(
@SerialName("id") override val id: Int,
@SerialName("title") override val name: String,
@SerialName("title") override val name: String?,
@SerialName("overview") override val overview: String?,
@SerialName("poster_path") override val posterPath: String?,
@SerialName("backdrop_path") override val backdropPath: String?,
@ -68,7 +68,7 @@ data class TMDBSearchResultMovie(
@Serializable
data class TMDBSearchResultTVShow(
@SerialName("id") override val id: Int,
@SerialName("name") override val name: String,
@SerialName("name") override val name: String?,
@SerialName("overview") override val overview: String?,
@SerialName("poster_path") override val posterPath: String?,
@SerialName("backdrop_path") override val backdropPath: String?,
@ -92,7 +92,7 @@ data class TMDBMovie(
@SerialName("release_date") val releaseDate: String,
@SerialName("runtime") val runtime: Int?,
@SerialName("status") val status: String,
// TODO generes
// TODO genres
) : TMDBResult
@Serializable
@ -105,7 +105,7 @@ data class TMDBTVShow(
@SerialName("first_air_date") val firstAirDate: String,
@SerialName("last_air_date") val lastAirDate: String,
@SerialName("status") val status: String,
// TODO generes
// TODO genres
) : TMDBResult
// use null for nullable types, the gui needs to handle/implement a fallback for null values