Skip to content

Commit 4270f15

Browse files
authored
Make old rating system use DeprecationLevel.ERROR (#2041)
It's been deprecated for about 3 months now. This also deprecated `fromOld` and `toOld` since in theory those should never have been used in extensions and also `toRatingInt()` since again, in theory, wouldn't be used once converting to use the new score API.
1 parent 5b1400e commit 4270f15

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ object DataStoreHelper {
272272
var rating: Int? = null
273273
set(value) {
274274
if (value != null) {
275+
@Suppress("DEPRECATION_ERROR")
275276
score = Score.fromOld(value)
276277
}
277278
}

app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadHelper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ object VideoDownloadHelper {
2828
var rating: Int? = null
2929
set(value) {
3030
if (value != null) {
31+
@Suppress("DEPRECATION_ERROR")
3132
score = Score.fromOld(value)
3233
}
3334
}

library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@ class Score private constructor(
832832
override fun hashCode(): Int = this.data.hashCode()
833833
override fun equals(other: Any?): Boolean = other is Score && this.data == other.data
834834

835+
@Deprecated(
836+
"toOld() is deprecated. Use other Score methods instead.",
837+
level = DeprecationLevel.ERROR
838+
)
835839
fun toOld(): Int = toInt(10000)
836840

837841
fun toByte(maxScore: Int): Byte = toLong(maxScore).toByte()
@@ -930,6 +934,10 @@ class Score private constructor(
930934
const val MAX_ZEROS: Int = 9
931935
private const val TAG: String = "Score"
932936

937+
@Deprecated(
938+
"Score.fromOld is deprecated. Use other Score.from* methods instead.",
939+
level = DeprecationLevel.ERROR
940+
)
933941
fun fromOld(value: Int?): Score? {
934942
if (value == null) return null
935943
if (value < 0 || value > 10000) {
@@ -1744,12 +1752,14 @@ interface LoadResponse {
17441752
@Deprecated(
17451753
"`rating` is the old scoring system, use score instead",
17461754
replaceWith = ReplaceWith("score"),
1747-
level = DeprecationLevel.WARNING
1755+
level = DeprecationLevel.ERROR
17481756
)
17491757
var rating: Int?
17501758
set(value) {
1759+
@Suppress("DEPRECATION_ERROR")
17511760
this.score = Score.fromOld(value)
17521761
}
1762+
@Suppress("DEPRECATION_ERROR")
17531763
get() = score?.toOld()
17541764

17551765
companion object {
@@ -1983,7 +1993,7 @@ interface LoadResponse {
19831993
@Deprecated(
19841994
"Use addScore",
19851995
replaceWith = ReplaceWith("addScore"),
1986-
level = DeprecationLevel.WARNING
1996+
level = DeprecationLevel.ERROR
19871997
)
19881998
fun LoadResponse.addRating(text: String?) {
19891999
this.score = Score.from10(text)
@@ -1992,9 +2002,10 @@ interface LoadResponse {
19922002
@Deprecated(
19932003
"Use addScore",
19942004
replaceWith = ReplaceWith("addScore"),
1995-
level = DeprecationLevel.WARNING
2005+
level = DeprecationLevel.ERROR
19962006
)
19972007
fun LoadResponse.addRating(value: Int?) {
2008+
@Suppress("DEPRECATION_ERROR")
19982009
this.score = Score.fromOld(value)
19992010
}
20002011

@@ -2696,7 +2707,7 @@ constructor(
26962707
@Deprecated(
26972708
"`rating` is the old scoring system, use score instead",
26982709
replaceWith = ReplaceWith("score"),
2699-
level = DeprecationLevel.WARNING
2710+
level = DeprecationLevel.ERROR
27002711
)
27012712
var rating: Int?
27022713
set(value) {
@@ -2924,6 +2935,10 @@ fun fetchUrls(text: String?): List<String> {
29242935
return linkRegex.findAll(text).map { it.value.trim().removeSurrounding("\"") }.toList()
29252936
}
29262937

2938+
@Deprecated(
2939+
"toRatingInt() is deprecated. Use new score API instead.",
2940+
level = DeprecationLevel.ERROR
2941+
)
29272942
fun String?.toRatingInt(): Int? =
29282943
this?.replace(" ", "")?.trim()?.toDoubleOrNull()?.absoluteValue?.times(1000f)?.toInt()
29292944

0 commit comments

Comments
 (0)