2021-11-12 16:55:54 +00:00
|
|
|
package com.lagradost.cloudstream3.syncproviders
|
|
|
|
|
2022-04-18 00:26:13 +00:00
|
|
|
import com.lagradost.cloudstream3.*
|
2023-01-28 22:38:02 +00:00
|
|
|
import com.lagradost.cloudstream3.ui.library.ListSorting
|
|
|
|
import com.lagradost.cloudstream3.ui.result.UiText
|
|
|
|
import me.xdrop.fuzzywuzzy.FuzzySearch
|
|
|
|
|
|
|
|
enum class SyncIdName {
|
|
|
|
Anilist,
|
|
|
|
MyAnimeList,
|
|
|
|
Trakt,
|
|
|
|
Imdb,
|
2023-08-12 20:25:30 +00:00
|
|
|
Simkl,
|
|
|
|
LocalList,
|
2023-01-28 22:38:02 +00:00
|
|
|
}
|
2021-11-12 16:55:54 +00:00
|
|
|
|
2021-11-20 00:41:37 +00:00
|
|
|
interface SyncAPI : OAuth2API {
|
2023-01-28 22:38:02 +00:00
|
|
|
/**
|
|
|
|
* Set this to true if the user updates something on the list like watch status or score
|
|
|
|
**/
|
|
|
|
var requireLibraryRefresh: Boolean
|
2022-04-01 20:05:34 +00:00
|
|
|
val mainUrl: String
|
|
|
|
|
2023-01-28 22:38:02 +00:00
|
|
|
/**
|
|
|
|
* Allows certain providers to open pages from
|
|
|
|
* library links.
|
|
|
|
**/
|
|
|
|
val syncIdName: SyncIdName
|
|
|
|
|
2022-04-01 20:05:34 +00:00
|
|
|
/**
|
|
|
|
-1 -> None
|
|
|
|
0 -> Watching
|
|
|
|
1 -> Completed
|
|
|
|
2 -> OnHold
|
|
|
|
3 -> Dropped
|
|
|
|
4 -> PlanToWatch
|
|
|
|
5 -> ReWatching
|
|
|
|
*/
|
2023-08-12 20:25:30 +00:00
|
|
|
suspend fun score(id: String, status: AbstractSyncStatus): Boolean
|
2022-04-01 20:05:34 +00:00
|
|
|
|
2023-08-12 20:25:30 +00:00
|
|
|
suspend fun getStatus(id: String): AbstractSyncStatus?
|
2022-04-01 20:05:34 +00:00
|
|
|
|
|
|
|
suspend fun getResult(id: String): SyncResult?
|
|
|
|
|
|
|
|
suspend fun search(name: String): List<SyncSearchResult>?
|
|
|
|
|
2023-01-28 22:38:02 +00:00
|
|
|
suspend fun getPersonalLibrary(): LibraryMetadata?
|
|
|
|
|
|
|
|
fun getIdFromUrl(url: String): String
|
2022-04-18 00:26:13 +00:00
|
|
|
|
2021-11-12 16:55:54 +00:00
|
|
|
data class SyncSearchResult(
|
2022-04-18 00:26:13 +00:00
|
|
|
override val name: String,
|
|
|
|
override val apiName: String,
|
|
|
|
var syncId: String,
|
|
|
|
override val url: String,
|
|
|
|
override var posterUrl: String?,
|
|
|
|
override var type: TvType? = null,
|
|
|
|
override var quality: SearchQuality? = null,
|
|
|
|
override var posterHeaders: Map<String, String>? = null,
|
|
|
|
override var id: Int? = null,
|
|
|
|
) : SearchResponse
|
2021-11-12 16:55:54 +00:00
|
|
|
|
2023-08-12 20:25:30 +00:00
|
|
|
abstract class AbstractSyncStatus {
|
|
|
|
abstract var status: Int
|
|
|
|
|
|
|
|
/** 1-10 */
|
|
|
|
abstract var score: Int?
|
|
|
|
abstract var watchedEpisodes: Int?
|
|
|
|
abstract var isFavorite: Boolean?
|
|
|
|
abstract var maxEpisodes: Int?
|
|
|
|
}
|
|
|
|
|
2021-11-12 16:55:54 +00:00
|
|
|
data class SyncStatus(
|
2023-08-12 20:25:30 +00:00
|
|
|
override var status: Int,
|
2021-11-12 16:55:54 +00:00
|
|
|
/** 1-10 */
|
2023-08-12 20:25:30 +00:00
|
|
|
override var score: Int?,
|
|
|
|
override var watchedEpisodes: Int?,
|
|
|
|
override var isFavorite: Boolean? = null,
|
|
|
|
override var maxEpisodes: Int? = null,
|
|
|
|
) : AbstractSyncStatus()
|
2021-11-12 16:55:54 +00:00
|
|
|
|
|
|
|
data class SyncResult(
|
|
|
|
/**Used to verify*/
|
|
|
|
var id: String,
|
|
|
|
|
|
|
|
var totalEpisodes: Int? = null,
|
|
|
|
|
|
|
|
var title: String? = null,
|
|
|
|
/**1-1000*/
|
|
|
|
var publicScore: Int? = null,
|
|
|
|
/**In minutes*/
|
|
|
|
var duration: Int? = null,
|
|
|
|
var synopsis: String? = null,
|
|
|
|
var airStatus: ShowStatus? = null,
|
2022-06-20 13:17:34 +00:00
|
|
|
var nextAiring: NextAiring? = null,
|
2022-04-01 20:05:34 +00:00
|
|
|
var studio: List<String>? = null,
|
2021-11-12 16:55:54 +00:00
|
|
|
var genres: List<String>? = null,
|
2022-04-02 22:06:35 +00:00
|
|
|
var synonyms: List<String>? = null,
|
2022-06-17 20:43:42 +00:00
|
|
|
var trailers: List<String>? = null,
|
2023-01-28 22:38:02 +00:00
|
|
|
var isAdult: Boolean? = null,
|
2022-04-03 01:13:02 +00:00
|
|
|
var posterUrl: String? = null,
|
2023-01-28 22:38:02 +00:00
|
|
|
var backgroundPosterUrl: String? = null,
|
2021-11-12 16:55:54 +00:00
|
|
|
|
|
|
|
/** In unixtime */
|
|
|
|
var startDate: Long? = null,
|
|
|
|
/** In unixtime */
|
|
|
|
var endDate: Long? = null,
|
|
|
|
var recommendations: List<SyncSearchResult>? = null,
|
|
|
|
var nextSeason: SyncSearchResult? = null,
|
|
|
|
var prevSeason: SyncSearchResult? = null,
|
2022-04-03 17:11:18 +00:00
|
|
|
var actors: List<ActorData>? = null,
|
2021-11-12 16:55:54 +00:00
|
|
|
)
|
2023-01-28 22:38:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
data class Page(
|
|
|
|
val title: UiText, var items: List<LibraryItem>
|
|
|
|
) {
|
|
|
|
fun sort(method: ListSorting?, query: String? = null) {
|
|
|
|
items = when (method) {
|
|
|
|
ListSorting.Query ->
|
|
|
|
if (query != null) {
|
|
|
|
items.sortedBy {
|
|
|
|
-FuzzySearch.partialRatio(
|
|
|
|
query.lowercase(), it.name.lowercase()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else items
|
|
|
|
ListSorting.RatingHigh -> items.sortedBy { -(it.personalRating ?: 0) }
|
|
|
|
ListSorting.RatingLow -> items.sortedBy { (it.personalRating ?: 0) }
|
|
|
|
ListSorting.AlphabeticalA -> items.sortedBy { it.name }
|
|
|
|
ListSorting.AlphabeticalZ -> items.sortedBy { it.name }.reversed()
|
|
|
|
ListSorting.UpdatedNew -> items.sortedBy { it.lastUpdatedUnixTime?.times(-1) }
|
|
|
|
ListSorting.UpdatedOld -> items.sortedBy { it.lastUpdatedUnixTime }
|
|
|
|
else -> items
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data class LibraryMetadata(
|
|
|
|
val allLibraryLists: List<LibraryList>,
|
|
|
|
val supportedListSorting: Set<ListSorting>
|
|
|
|
)
|
|
|
|
|
|
|
|
data class LibraryList(
|
|
|
|
val name: UiText,
|
|
|
|
val items: List<LibraryItem>
|
|
|
|
)
|
|
|
|
|
|
|
|
data class LibraryItem(
|
|
|
|
override val name: String,
|
|
|
|
override val url: String,
|
|
|
|
/**
|
|
|
|
* Unique unchanging string used for data storage.
|
|
|
|
* This should be the actual id when you change scores and status
|
|
|
|
* since score changes from library might get added in the future.
|
|
|
|
**/
|
|
|
|
val syncId: String,
|
|
|
|
val episodesCompleted: Int?,
|
|
|
|
val episodesTotal: Int?,
|
|
|
|
/** Out of 100 */
|
|
|
|
val personalRating: Int?,
|
|
|
|
val lastUpdatedUnixTime: Long?,
|
|
|
|
override val apiName: String,
|
|
|
|
override var type: TvType?,
|
|
|
|
override var posterUrl: String?,
|
|
|
|
override var posterHeaders: Map<String, String>?,
|
|
|
|
override var quality: SearchQuality?,
|
|
|
|
override var id: Int? = null,
|
|
|
|
) : SearchResponse
|
2021-11-12 16:55:54 +00:00
|
|
|
}
|