Fix getUser

This commit is contained in:
self-similarity 2023-08-12 21:40:45 +02:00
parent 86ccb38362
commit b62f359ff2

View file

@ -16,6 +16,7 @@ import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mvvm.debugAssert 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.mvvm.suspendSafeApiCall
import com.lagradost.cloudstream3.syncproviders.AccountManager import com.lagradost.cloudstream3.syncproviders.AccountManager
import com.lagradost.cloudstream3.syncproviders.AuthAPI import com.lagradost.cloudstream3.syncproviders.AuthAPI
import com.lagradost.cloudstream3.syncproviders.SyncAPI import com.lagradost.cloudstream3.syncproviders.SyncAPI
@ -481,8 +482,10 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
} }
private suspend fun getUser(): SettingsResponse.User? { private suspend fun getUser(): SettingsResponse.User? {
return app.post("$mainUrl/users/settings", interceptor = interceptor) return suspendSafeApiCall {
.parsedSafe<SettingsResponse>()?.user app.post("$mainUrl/users/settings", interceptor = interceptor)
.parsedSafe<SettingsResponse>()?.user
}
} }
class SimklSyncStatus( class SimklSyncStatus(
@ -510,7 +513,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
if (foundItem != null) { if (foundItem != null) {
return SimklSyncStatus( return SimklSyncStatus(
status = foundItem.status?.let { SimklListStatusType.fromString(it)?.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,
@ -790,7 +794,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
} }
.mapNotNull { (status, list) -> .mapNotNull { (status, list) ->
val stringRes = val stringRes =
status?.let { SimklListStatusType.fromString(it)?.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()