argus-tmdb-core

Kotlin Multiplatform Argus Core

License

License

Categories

Categories

Data
GroupId

GroupId

com.pajato.argus
ArtifactId

ArtifactId

argus-tmdb-core-metadata
Last Version

Last Version

0.0.13
Release Date

Release Date

Type

Type

module
Description

Description

argus-tmdb-core
Kotlin Multiplatform Argus Core
Project URL

Project URL

https://github.com/pajato/argus-tmdb-core
Project Organization

Project Organization

Pajato Technologies LLC
Source Code Management

Source Code Management

https://github.com/pajato/argus-tmdb-core

Download argus-tmdb-core-metadata

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

argus-tmdb-core

TMDB PoweredBy Logo

license: LGPL v3 build: passing codecov: 100

Overview

A multi-platform Kotlin library providing access to The Movie Database (tmdb) dataset objects.

Support will be provided in the first release for Android and iOS.

Current release: (Maven Central)

Maven coordinates: com.pajato.argus:argus-tmdb-core:0.0.14

API

/** The wrapper class for TMDB dataset subclasses. */
sealed class TmdbData

/** Each TMDB subclass identifies a dataset list name and a create function. */
interface TmdbDataFactory {
    val listName: String
    fun create(json: String): TmdbData
}

/** The set of collections used in TMDB. */
@Serializable
data class Collection(val id: Int = 0, val name: String = "") : TmdbData() {
    companion object : TmdbDataFactory {
        override val listName = "collection_ids"
        override fun create(json: String): TmdbData = createFromJson(json, Collection())
    }
}

/** The set of keywords used in TMDB. */
@Serializable
data class Keyword(val id: Int = 0, val name: String = "") : TmdbData() {
    companion object : TmdbDataFactory {
        override val listName = "keyword_ids"
        override fun create(json: String): TmdbData = createFromJson(json, Keyword())
    }
}

/** The set of movies known to TMDB. */
@Serializable
data class Movie(
    val adult: Boolean = false,
    val id: Int = -1,
    val original_title: String = "",
    val popularity: Double = 0.0,
    val video: Boolean = false
) : TmdbData() {
    companion object : TmdbDataFactory {
        override val listName = "movie_ids"
        override fun create(json: String): TmdbData = createFromJson(json, Movie())
    }
}

/** The set of TV networks known to TMDB. */
@Serializable
data class Network(val id: Int = -1, val name: String = ""): TmdbData() {
    companion object : TmdbDataFactory {
        override val listName = "tv_network_ids"
        override fun create(json: String): TmdbData = createFromJson(json, Network())
    }
}

/** The set of people (cast, crew, etc.) known to TMDB. */
@Serializable
data class Person(
    val adult: Boolean = false,
    val id: Int = -1,
    val name: String = "",
    val popularity: Double = 0.0
) : TmdbData() {
    companion object : TmdbDataFactory {
        override val listName = "person_ids"
        override fun create(json: String): TmdbData = createFromJson(json, Person())
    }
}

/** The set of production companies known to TMDB. */
@Serializable
data class ProductionCompany(val id: Int = 0, val name: String = "") : TmdbData() {
    companion object : TmdbDataFactory {
        override val listName = "production_company_ids"
        override fun create(json: String): TmdbData = createFromJson(json, ProductionCompany())
    }
}

/** The set of TV shows known to TMDB. */
@Serializable
data class TvSeries(val id: Int = -1, val original_name: String = "", val popularity: Double = 0.0) : TmdbData() {
    companion object : TmdbDataFactory {
        override val listName = "tv_series_ids"
        override fun create(json: String): TmdbData = createFromJson(json, TvSeries())
    }
}

/** A special TMDB error class providing granular message data for errors. */
data class TmdbError(val message: String) : TmdbData()

/** The page wrapper class. */
class Page<T1 : TmdbData, T2: TmdbData>(val type: KClass<T1>, val pageSize: Int, val list: MutableList<T2>) {

    fun hasError(): Boolean = list.size == 1 && list[0] is TmdbError

    fun getError(): String {
        fun getErrorMessage(item: TmdbData): String = when (item) {
            is TmdbError -> item.message
            else -> ""
        }

        return if (list.size == 0) "" else getErrorMessage(list[0])
    }
}
com.pajato.argus

Versions

Version
0.0.13
0.0.12
0.0.11
0.0.10