Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ interface SyncAPI : OAuth2API {
var totalEpisodes: Int? = null,

var title: String? = null,
/**1-1000*/
var publicScore: Int? = null,
var publicScore: Score? = null,
/**In minutes*/
var duration: Int? = null,
var synopsis: String? = null,
Expand Down Expand Up @@ -154,7 +153,7 @@ interface SyncAPI : OAuth2API {
val episodesCompleted: Int?,
val episodesTotal: Int?,
/** Out of 100 */
val personalRating: Int?,
val personalRating: Int?, // TODO also update this to Score
val lastUpdatedUnixTime: Long?,
override val apiName: String,
override var type: TvType?,
Expand All @@ -164,7 +163,7 @@ interface SyncAPI : OAuth2API {
val releaseDate: Date?,
override var id: Int? = null,
val plot : String? = null,
val rating: Int? = null,
val rating: Score? = null,
val tags: List<String>? = null
) : SearchResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
}
)
},
publicScore = season.averageScore?.times(100),
publicScore = Score.from100(season.averageScore),
recommendations = season.recommendations?.edges?.mapNotNull { rec ->
val recMedia = rec.node.mediaRecommendation
SyncAPI.SyncSearchResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.Score
import com.lagradost.cloudstream3.ShowStatus
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.app
Expand Down Expand Up @@ -214,7 +215,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
id = internalId.toString(),
totalEpisodes = malAnime.numEpisodes,
title = malAnime.title,
publicScore = malAnime.mean?.toFloat()?.times(1000)?.toInt(),
publicScore = Score.from10(malAnime.mean),
duration = malAnime.averageEpisodeDuration,
synopsis = malAnime.synopsis,
airStatus = when (malAnime.status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class EpisodeAdapter(
season = card.season,
id = card.id,
parentId = card.parentId,
rating = card.rating,
score = card.score,
description = card.description,
cacheTime = System.currentTimeMillis(),
), null
Expand Down Expand Up @@ -230,9 +230,9 @@ class EpisodeAdapter(

episodePoster.loadImage(card.poster)

if (card.rating != null) {
if (card.score != null) {
episodeRating.text = episodeRating.context?.getString(R.string.rated_format)
?.format(card.rating.toFloat() / 10f)
?.format(card.score.toFloat(10)) // TODO Change rated_format to use card.score.toString()
} else {
episodeRating.text = ""
}
Expand Down Expand Up @@ -347,7 +347,7 @@ class EpisodeAdapter(
season = card.season,
id = card.id,
parentId = card.parentId,
rating = card.rating,
score = card.score,
description = card.description,
cacheTime = System.currentTimeMillis(),
), null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.DubStatus
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.Score
import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.ui.result.EpisodeAdapter.Companion.getPlayerAction
Expand Down Expand Up @@ -39,7 +40,7 @@ data class ResultEpisode(
val index: Int,
val position: Long, // time in MS
val duration: Long, // duration in MS
val rating: Int?,
val score: Score?,
val description: String?,
val isFiller: Boolean?,
val tvType: TvType,
Expand Down Expand Up @@ -81,7 +82,7 @@ fun buildResultEpisode(
apiName: String,
id: Int,
index: Int,
rating: Int? = null,
rating: Score? = null,
description: String? = null,
isFiller: Boolean? = null,
tvType: TvType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ open class ResultFragmentPhone : FullScreenPlayer() {
season = null,
id = ep.id,
parentId = ep.id,
rating = null,
description = null,
score = ep.score,
description = ep.description,
cacheTime = System.currentTimeMillis(),
),
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ fun LoadResponse.toResultData(repo: APIRepository): ResultData {
),
yearText = txt(year?.toString()),
apiName = txt(apiName),
ratingText = rating?.div(1000f)
?.let { if (it <= 0.1f) null else txt(R.string.rating_format, it) },
ratingText = score?.toStringNull(0.1, 10, 1, false, '.')
?.let { txt(R.string.rating_format, it) },
contentRatingText = txt(contentRating),
vpnText = txt(
when (repo.vpnStatus) {
Expand Down Expand Up @@ -738,7 +738,7 @@ class ResultViewModel2 : ViewModel() {
season = episode.season,
id = episode.id,
parentId = parentId,
rating = episode.rating,
score = episode.score,
description = episode.description,
cacheTime = System.currentTimeMillis(),
)
Expand Down Expand Up @@ -925,7 +925,7 @@ class ResultViewModel2 : ViewModel() {
response.syncData,
plot = response.plot,
tags = response.tags,
rating = response.rating
score = response.score
)
)
}
Expand Down Expand Up @@ -1022,7 +1022,7 @@ class ResultViewModel2 : ViewModel() {
response.year,
response.syncData,
plot = response.plot,
rating = response.rating,
score = response.score,
tags = response.tags
)
)
Expand Down Expand Up @@ -1093,7 +1093,7 @@ class ResultViewModel2 : ViewModel() {
response.year,
response.syncData,
plot = response.plot,
rating = response.rating,
score = response.score,
tags = response.tags
)
)
Expand Down Expand Up @@ -1404,7 +1404,7 @@ class ResultViewModel2 : ViewModel() {
},
isCasting = isCasting
)
} catch (e : CancellationException) {
} catch (e: CancellationException) {
// Do nothing
} catch (e: Exception) {
logError(e)
Expand Down Expand Up @@ -1660,13 +1660,14 @@ class ResultViewModel2 : ViewModel() {
// Show player selection dialog
val players = VideoClickActionHolder.getPlayers(ctx)
val options = mutableListOf<Pair<UiText, Int>>()

// Add internal player option
options.add(txt(R.string.episode_action_play_in_app) to ACTION_PLAY_EPISODE_IN_PLAYER)

// Add external player options
options.addAll(players.filter { it !is AlwaysAskAction }.map { player ->
player.name to (VideoClickActionHolder.uniqueIdToId(player.uniqueId()) ?: ACTION_PLAY_EPISODE_IN_PLAYER)
player.name to (VideoClickActionHolder.uniqueIdToId(player.uniqueId())
?: ACTION_PLAY_EPISODE_IN_PLAYER)
})

postPopup(
Expand Down Expand Up @@ -1723,7 +1724,7 @@ class ResultViewModel2 : ViewModel() {

if (meta != null) {
duration = duration ?: meta.duration
rating = rating ?: meta.publicScore
score = score ?: meta.publicScore
tags = tags ?: meta.genres
plot = if (plot.isNullOrBlank()) meta.synopsis else plot
posterUrl = posterUrl ?: meta.posterUrl ?: meta.backgroundPosterUrl
Expand Down Expand Up @@ -1942,8 +1943,8 @@ class ResultViewModel2 : ViewModel() {
return when (sorting) {
EpisodeSortType.NUMBER_ASC -> episodes.sortedBy { it.episode }
EpisodeSortType.NUMBER_DESC -> episodes.sortedByDescending { it.episode }
EpisodeSortType.RATING_HIGH_LOW -> episodes.sortedByDescending { it.rating ?: 0 }
EpisodeSortType.RATING_LOW_HIGH -> episodes.sortedBy { it.rating ?: 0 }
EpisodeSortType.RATING_HIGH_LOW -> episodes.sortedByDescending { it.score?.toDouble() ?: 0.0 }
EpisodeSortType.RATING_LOW_HIGH -> episodes.sortedBy { it.score?.toDouble() ?: 0.0 }
EpisodeSortType.DATE_NEWEST -> episodes.sortedByDescending { it.airDate }
EpisodeSortType.DATE_OLDEST -> episodes.sortedBy { it.airDate }
}
Expand Down Expand Up @@ -2022,7 +2023,7 @@ class ResultViewModel2 : ViewModel() {
return when (type) {
EpisodeSortType.NUMBER_ASC, EpisodeSortType.NUMBER_DESC -> true
EpisodeSortType.RATING_HIGH_LOW, EpisodeSortType.RATING_LOW_HIGH ->
episodes.any { it.rating != null }
episodes.any { it.score != null }

EpisodeSortType.DATE_NEWEST, EpisodeSortType.DATE_OLDEST ->
episodes.any { it.airDate != null }
Expand Down Expand Up @@ -2274,7 +2275,7 @@ class ResultViewModel2 : ViewModel() {
loadResponse.apiName,
id,
index,
i.rating,
i.score,
i.description,
fillers.getOrDefault(episode, false),
loadResponse.type,
Expand Down Expand Up @@ -2330,7 +2331,7 @@ class ResultViewModel2 : ViewModel() {
loadResponse.apiName,
id,
index,
episode.rating,
episode.score,
episode.description,
null,
loadResponse.type,
Expand Down Expand Up @@ -2620,7 +2621,7 @@ class ResultViewModel2 : ViewModel() {
override var posterUrl: String?,
override var year: Int? = null,
override var plot: String? = null,
override var rating: Int? = null,
override var score: Score? = null,
override var tags: List<String>? = null,
override var duration: Int? = null,
override var trailers: MutableList<TrailerData> = mutableListOf(),
Expand Down Expand Up @@ -2654,12 +2655,12 @@ class ResultViewModel2 : ViewModel() {
).apply {
if (searchResponse is SyncAPI.LibraryItem) {
this.plot = searchResponse.plot
this.rating = searchResponse.personalRating?.times(100) ?: searchResponse.rating
this.score = Score.from100(searchResponse.personalRating) ?: searchResponse.rating
this.tags = searchResponse.tags
}
if (searchResponse is DataStoreHelper.BookmarkedData) {
this.plot = searchResponse.plot
this.rating = searchResponse.rating
this.score = searchResponse.score
this.tags = searchResponse.tags
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object SearchHelper {
season = card.season,
id = id,
parentId = card.parentId ?: return,
rating = null,
score = null,
description = null,
cacheTime = System.currentTimeMillis(),
)
Expand Down
Loading