mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-13 05:52:48 +01:00
MangaUpdates tweaks (#7205)
* MangaUpdates tweaks * Review changes Co-authored-by: arkon <4098258+arkon@users.noreply.github.com> * Use built in functions instead of Jsoup Co-authored-by: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
parent
3c40010aff
commit
c8468c29f1
@ -52,11 +52,18 @@ class MangaUpdates(private val context: Context, id: Int) : TrackService(id) {
|
|||||||
|
|
||||||
override fun getCompletionStatus(): Int = COMPLETE_LIST
|
override fun getCompletionStatus(): Int = COMPLETE_LIST
|
||||||
|
|
||||||
override fun getScoreList(): List<String> = (0..10).map(Int::toString)
|
private val _scoreList = (0..9).flatMap { i -> (0..9).map { j -> "$i.$j" } } + listOf("10.0")
|
||||||
|
|
||||||
override fun displayScore(track: Track): String = track.score.toInt().toString()
|
override fun getScoreList(): List<String> = _scoreList
|
||||||
|
|
||||||
|
override fun indexToScore(index: Int): Float = _scoreList[index].toFloat()
|
||||||
|
|
||||||
|
override fun displayScore(track: Track): String = track.score.toString()
|
||||||
|
|
||||||
override suspend fun update(track: Track, didReadChapter: Boolean): Track {
|
override suspend fun update(track: Track, didReadChapter: Boolean): Track {
|
||||||
|
if (track.status != COMPLETE_LIST && didReadChapter) {
|
||||||
|
track.status = READING_LIST
|
||||||
|
}
|
||||||
api.updateSeriesListItem(track)
|
api.updateSeriesListItem(track)
|
||||||
return track
|
return track
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ class MangaUpdatesApi(
|
|||||||
suspend fun updateSeriesRating(track: Track) {
|
suspend fun updateSeriesRating(track: Track) {
|
||||||
if (track.score != 0f) {
|
if (track.score != 0f) {
|
||||||
val body = buildJsonObject {
|
val body = buildJsonObject {
|
||||||
put("rating", track.score.toInt())
|
put("rating", track.score)
|
||||||
}
|
}
|
||||||
authClient.newCall(
|
authClient.newCall(
|
||||||
PUT(
|
PUT(
|
||||||
|
@ -5,11 +5,11 @@ import kotlinx.serialization.Serializable
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Rating(
|
data class Rating(
|
||||||
val rating: Int? = null,
|
val rating: Float? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun Rating.copyTo(track: Track): Track {
|
fun Rating.copyTo(track: Track): Track {
|
||||||
return track.apply {
|
return track.apply {
|
||||||
this.score = rating?.toFloat() ?: 0f
|
this.score = rating ?: 0f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.data.track.mangaupdates.dto
|
package eu.kanade.tachiyomi.data.track.mangaupdates.dto
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||||
|
import eu.kanade.tachiyomi.util.lang.htmlDecode
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -25,10 +26,10 @@ data class Record(
|
|||||||
fun Record.toTrackSearch(id: Int): TrackSearch {
|
fun Record.toTrackSearch(id: Int): TrackSearch {
|
||||||
return TrackSearch.create(id).apply {
|
return TrackSearch.create(id).apply {
|
||||||
media_id = this@toTrackSearch.seriesId ?: 0L
|
media_id = this@toTrackSearch.seriesId ?: 0L
|
||||||
title = this@toTrackSearch.title ?: ""
|
title = this@toTrackSearch.title?.htmlDecode() ?: ""
|
||||||
total_chapters = 0
|
total_chapters = 0
|
||||||
cover_url = this@toTrackSearch.image?.url?.original ?: ""
|
cover_url = this@toTrackSearch.image?.url?.original ?: ""
|
||||||
summary = this@toTrackSearch.description ?: ""
|
summary = this@toTrackSearch.description?.htmlDecode() ?: ""
|
||||||
tracking_url = this@toTrackSearch.url ?: ""
|
tracking_url = this@toTrackSearch.url ?: ""
|
||||||
publishing_status = ""
|
publishing_status = ""
|
||||||
publishing_type = this@toTrackSearch.type.toString()
|
publishing_type = this@toTrackSearch.type.toString()
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.util.lang
|
package eu.kanade.tachiyomi.util.lang
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
|
import android.text.Html
|
||||||
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
@ -57,3 +59,14 @@ fun String.takeBytes(n: Int): String {
|
|||||||
bytes.decodeToString(endIndex = n).replace("\uFFFD", "")
|
bytes.decodeToString(endIndex = n).replace("\uFFFD", "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML-decode the string
|
||||||
|
*/
|
||||||
|
fun String.htmlDecode(): String {
|
||||||
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY).toString()
|
||||||
|
} else {
|
||||||
|
Html.fromHtml(this).toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user