mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fixes
This commit is contained in:
parent
14d0f425c0
commit
86ccb38362
1 changed files with 20 additions and 13 deletions
|
@ -13,6 +13,7 @@ import com.lagradost.cloudstream3.BuildConfig
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.TvType
|
import com.lagradost.cloudstream3.TvType
|
||||||
import com.lagradost.cloudstream3.app
|
import com.lagradost.cloudstream3.app
|
||||||
|
import com.lagradost.cloudstream3.mvvm.debugAssert
|
||||||
import com.lagradost.cloudstream3.mvvm.debugPrint
|
import com.lagradost.cloudstream3.mvvm.debugPrint
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
||||||
|
@ -44,7 +45,9 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
override val createAccountUrl = "$mainUrl/signup"
|
override val createAccountUrl = "$mainUrl/signup"
|
||||||
override val syncIdName = SyncIdName.Simkl
|
override val syncIdName = SyncIdName.Simkl
|
||||||
private val token: String?
|
private val token: String?
|
||||||
get() = getKey(accountId, SIMKL_TOKEN_KEY)
|
get() = getKey<String>(accountId, SIMKL_TOKEN_KEY).also {
|
||||||
|
debugAssert({ it == null }) { "No ${this.name} token!" }
|
||||||
|
}
|
||||||
|
|
||||||
/** Automatically adds simkl auth headers */
|
/** Automatically adds simkl auth headers */
|
||||||
private val interceptor = HeaderInterceptor()
|
private val interceptor = HeaderInterceptor()
|
||||||
|
@ -354,7 +357,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
|
|
||||||
interface Metadata {
|
interface Metadata {
|
||||||
val last_watched_at: String?
|
val last_watched_at: String?
|
||||||
val status: String
|
val status: String?
|
||||||
val user_rating: Int?
|
val user_rating: Int?
|
||||||
val last_watched: String?
|
val last_watched: String?
|
||||||
val watched_episodes_count: Int?
|
val watched_episodes_count: Int?
|
||||||
|
@ -388,7 +391,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
getUnixTime(last_watched_at) ?: 0,
|
getUnixTime(last_watched_at) ?: 0,
|
||||||
"Simkl",
|
"Simkl",
|
||||||
TvType.Movie,
|
TvType.Movie,
|
||||||
getPosterUrl(this.movie.poster),
|
this.movie.poster?.let { getPosterUrl(it) },
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
movie.ids.simkl
|
movie.ids.simkl
|
||||||
|
@ -420,7 +423,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
getUnixTime(last_watched_at) ?: 0,
|
getUnixTime(last_watched_at) ?: 0,
|
||||||
"Simkl",
|
"Simkl",
|
||||||
TvType.Anime,
|
TvType.Anime,
|
||||||
getPosterUrl(this.show.poster),
|
this.show.poster?.let { getPosterUrl(it) },
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
show.ids.simkl
|
show.ids.simkl
|
||||||
|
@ -429,8 +432,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
|
|
||||||
data class Show(
|
data class Show(
|
||||||
val title: String,
|
val title: String,
|
||||||
val poster: String,
|
val poster: String?,
|
||||||
val year: Int,
|
val year: Int?,
|
||||||
val ids: Ids,
|
val ids: Ids,
|
||||||
) {
|
) {
|
||||||
data class Ids(
|
data class Ids(
|
||||||
|
@ -466,6 +469,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
**/
|
**/
|
||||||
private inner class HeaderInterceptor : Interceptor {
|
private inner class HeaderInterceptor : Interceptor {
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
debugPrint { "${this@SimklApi.name} made request to ${chain.request().url}" }
|
||||||
return chain.proceed(
|
return chain.proceed(
|
||||||
chain.request()
|
chain.request()
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
|
@ -506,7 +510,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
|
|
||||||
if (foundItem != null) {
|
if (foundItem != null) {
|
||||||
return SimklSyncStatus(
|
return SimklSyncStatus(
|
||||||
status = SimklListStatusType.fromString(foundItem.status)?.value ?: return null,
|
status = foundItem.status?.let { SimklListStatusType.fromString(it)?.value } ?: return null,
|
||||||
score = foundItem.user_rating,
|
score = foundItem.user_rating,
|
||||||
watchedEpisodes = foundItem.watched_episodes_count,
|
watchedEpisodes = foundItem.watched_episodes_count,
|
||||||
maxEpisodes = foundItem.total_episodes_count,
|
maxEpisodes = foundItem.total_episodes_count,
|
||||||
|
@ -707,7 +711,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getSyncListSince(since: Long?): AllItemsResponse? {
|
private suspend fun getSyncListSince(since: Long?): AllItemsResponse {
|
||||||
val params = getDateTime(since)?.let {
|
val params = getDateTime(since)?.let {
|
||||||
mapOf("date_from" to it)
|
mapOf("date_from" to it)
|
||||||
} ?: emptyMap()
|
} ?: emptyMap()
|
||||||
|
@ -716,7 +720,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
"$mainUrl/sync/all-items/",
|
"$mainUrl/sync/all-items/",
|
||||||
params = params,
|
params = params,
|
||||||
interceptor = interceptor
|
interceptor = interceptor
|
||||||
).parsedSafe()
|
).parsed()
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getActivities(): ActivitiesResponse? {
|
private suspend fun getActivities(): ActivitiesResponse? {
|
||||||
|
@ -761,6 +765,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
debugPrint { "Cached list update in ${this.name}." }
|
debugPrint { "Cached list update in ${this.name}." }
|
||||||
getSyncListCached()
|
getSyncListCached()
|
||||||
}
|
}
|
||||||
|
debugPrint { "List sizes: movies=${list?.movies?.size}, shows=${list?.shows?.size}, anime=${list?.anime?.size}" }
|
||||||
|
|
||||||
setKey(accountId, SIMKL_CACHED_LIST, list)
|
setKey(accountId, SIMKL_CACHED_LIST, list)
|
||||||
|
|
||||||
|
@ -772,9 +777,11 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
val list = getSyncListSmart() ?: return null
|
val list = getSyncListSmart() ?: return null
|
||||||
|
|
||||||
val baseMap =
|
val baseMap =
|
||||||
SimklListStatusType.values().filter { it.value >= 0 }.associate {
|
SimklListStatusType.values()
|
||||||
it.stringRes to emptyList<SyncAPI.LibraryItem>()
|
.filter { it.value >= 0 && it.value != SimklListStatusType.ReWatching.value }
|
||||||
}
|
.associate {
|
||||||
|
it.stringRes to emptyList<SyncAPI.LibraryItem>()
|
||||||
|
}
|
||||||
|
|
||||||
val syncMap = listOf(list.anime, list.movies, list.shows)
|
val syncMap = listOf(list.anime, list.movies, list.shows)
|
||||||
.flatten()
|
.flatten()
|
||||||
|
@ -783,7 +790,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
}
|
}
|
||||||
.mapNotNull { (status, list) ->
|
.mapNotNull { (status, list) ->
|
||||||
val stringRes =
|
val stringRes =
|
||||||
SimklListStatusType.fromString(status)?.stringRes ?: return@mapNotNull null
|
status?.let { SimklListStatusType.fromString(it)?.stringRes } ?: return@mapNotNull null
|
||||||
val libraryList = list.map { it.toLibraryItem() }
|
val libraryList = list.map { it.toLibraryItem() }
|
||||||
stringRes to libraryList
|
stringRes to libraryList
|
||||||
}.toMap()
|
}.toMap()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue