mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Update SimklApi.kt (#961)
This commit is contained in:
parent
1a380a3239
commit
809a38507b
1 changed files with 26 additions and 13 deletions
|
@ -440,9 +440,9 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
interceptor = interceptor
|
interceptor = interceptor
|
||||||
).isSuccessful
|
).isSuccessful
|
||||||
} else {
|
} else {
|
||||||
val statusResponse = status?.let { setStatus ->
|
val statusResponse = this.status?.let { setStatus ->
|
||||||
val newStatus =
|
val newStatus =
|
||||||
SimklListStatusType.values()
|
SimklListStatusType.entries
|
||||||
.firstOrNull { it.value == setStatus }?.originalName
|
.firstOrNull { it.value == setStatus }?.originalName
|
||||||
?: SimklListStatusType.Watching.originalName!!
|
?: SimklListStatusType.Watching.originalName!!
|
||||||
|
|
||||||
|
@ -479,9 +479,14 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
).isSuccessful
|
).isSuccessful
|
||||||
} ?: true
|
} ?: true
|
||||||
|
|
||||||
|
// You cannot rate if you are planning to watch it.
|
||||||
|
val shouldRate =
|
||||||
|
score != null && status != SimklListStatusType.Planning.value
|
||||||
|
val realScore = if (shouldRate) score else null
|
||||||
|
|
||||||
val historyResponse =
|
val historyResponse =
|
||||||
// Only post if there are episodes or score to upload
|
// Only post if there are episodes or score to upload
|
||||||
if (addEpisodes != null || score != null) {
|
if (addEpisodes != null || shouldRate) {
|
||||||
app.post(
|
app.post(
|
||||||
"${this.url}/sync/history",
|
"${this.url}/sync/history",
|
||||||
json = StatusRequest(
|
json = StatusRequest(
|
||||||
|
@ -492,8 +497,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
ids,
|
ids,
|
||||||
addEpisodes?.first,
|
addEpisodes?.first,
|
||||||
addEpisodes?.second,
|
addEpisodes?.second,
|
||||||
score,
|
realScore,
|
||||||
score?.let { time },
|
realScore?.let { time },
|
||||||
)
|
)
|
||||||
), movies = emptyList()
|
), movies = emptyList()
|
||||||
),
|
),
|
||||||
|
@ -827,7 +832,13 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
|
|
||||||
if (foundItem != null) {
|
if (foundItem != null) {
|
||||||
return SimklSyncStatus(
|
return SimklSyncStatus(
|
||||||
status = foundItem.status?.let { SyncWatchType.fromInternalId(SimklListStatusType.fromString(it)?.value) }
|
status = foundItem.status?.let {
|
||||||
|
SyncWatchType.fromInternalId(
|
||||||
|
SimklListStatusType.fromString(
|
||||||
|
it
|
||||||
|
)?.value
|
||||||
|
)
|
||||||
|
}
|
||||||
?: return null,
|
?: return null,
|
||||||
score = foundItem.user_rating,
|
score = foundItem.user_rating,
|
||||||
watchedEpisodes = foundItem.watched_episodes_count,
|
watchedEpisodes = foundItem.watched_episodes_count,
|
||||||
|
@ -839,7 +850,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return SimklSyncStatus(
|
return SimklSyncStatus(
|
||||||
status = SyncWatchType.fromInternalId(SimklListStatusType.None.value) ,
|
status = SyncWatchType.fromInternalId(SimklListStatusType.None.value),
|
||||||
score = 0,
|
score = 0,
|
||||||
watchedEpisodes = 0,
|
watchedEpisodes = 0,
|
||||||
maxEpisodes = if (searchResult.type == "movie") 0 else searchResult.total_episodes,
|
maxEpisodes = if (searchResult.type == "movie") 0 else searchResult.total_episodes,
|
||||||
|
@ -859,8 +870,10 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
val builder = SimklScoreBuilder.Builder()
|
val builder = SimklScoreBuilder.Builder()
|
||||||
.apiUrl(this.mainUrl)
|
.apiUrl(this.mainUrl)
|
||||||
.score(status.score, simklStatus?.oldScore)
|
.score(status.score, simklStatus?.oldScore)
|
||||||
.status(status.status.internalId, (status as? SimklSyncStatus)?.oldStatus?.let { oldStatus ->
|
.status(
|
||||||
SimklListStatusType.values().firstOrNull {
|
status.status.internalId,
|
||||||
|
(status as? SimklSyncStatus)?.oldStatus?.let { oldStatus ->
|
||||||
|
SimklListStatusType.entries.firstOrNull {
|
||||||
it.originalName == oldStatus
|
it.originalName == oldStatus
|
||||||
}?.value
|
}?.value
|
||||||
})
|
})
|
||||||
|
@ -996,7 +1009,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
val list = getSyncListSmart() ?: return null
|
val list = getSyncListSmart() ?: return null
|
||||||
|
|
||||||
val baseMap =
|
val baseMap =
|
||||||
SimklListStatusType.values()
|
SimklListStatusType.entries
|
||||||
.filter { it.value >= 0 && it.value != SimklListStatusType.ReWatching.value }
|
.filter { it.value >= 0 && it.value != SimklListStatusType.ReWatching.value }
|
||||||
.associate {
|
.associate {
|
||||||
it.stringRes to emptyList<SyncAPI.LibraryItem>()
|
it.stringRes to emptyList<SyncAPI.LibraryItem>()
|
||||||
|
|
Loading…
Reference in a new issue