Merge 20ad1b34d3
into 38368f56ac
This commit is contained in:
commit
6837f7cfd8
2 changed files with 68 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
extName = 'Torrentio Anime (Torrent / Debrid)'
|
||||
extClass = '.Torrentio'
|
||||
extVersionCode = 16
|
||||
extVersionCode = 17
|
||||
containsNsfw = false
|
||||
}
|
||||
|
||||
|
|
|
@ -456,18 +456,50 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||
}.orEmpty()
|
||||
}
|
||||
|
||||
override fun List<Video>.sort(): List<Video> {
|
||||
val isDub = preferences.getBoolean(IS_DUB_KEY, IS_DUB_DEFAULT)
|
||||
val isEfficient = preferences.getBoolean(IS_EFFICIENT_KEY, IS_EFFICIENT_DEFAULT)
|
||||
|
||||
return sortedWith(
|
||||
override fun List<Video>.sort(): List<Video> {
|
||||
val isDub = preferences.getBoolean(IS_DUB_KEY, IS_DUB_DEFAULT)
|
||||
val isEfficient = preferences.getBoolean(IS_EFFICIENT_KEY, IS_EFFICIENT_DEFAULT)
|
||||
val codecPreferences = preferences.getStringSet(PREF_CODEC_KEY, PREF_CODEC_DEFAULT) ?: setOf()
|
||||
|
||||
return if (codecPreferences.isNotEmpty()) {
|
||||
// Filter to only show videos matching selected codecs
|
||||
filter { video ->
|
||||
codecPreferences.any { codec ->
|
||||
when (codec) {
|
||||
"x264" -> video.quality.contains("264", true) ||
|
||||
(!video.quality.contains("265", true) &&
|
||||
!video.quality.contains("hevc", true) &&
|
||||
!video.quality.contains("av1", true) &&
|
||||
!video.quality.contains("vp9", true))
|
||||
"x265" -> video.quality.contains("265", true) ||
|
||||
video.quality.contains("hevc", true)
|
||||
"av1" -> video.quality.contains("av1", true)
|
||||
"vp9" -> video.quality.contains("vp9", true)
|
||||
"other" -> !video.quality.contains("264", true) &&
|
||||
!video.quality.contains("265", true) &&
|
||||
!video.quality.contains("hevc", true) &&
|
||||
!video.quality.contains("av1", true) &&
|
||||
!video.quality.contains("vp9", true)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}.sortedWith(
|
||||
compareBy(
|
||||
{ Regex("\\[(.+?) download]").containsMatchIn(it.quality) },
|
||||
{ isDub && !it.quality.contains("dubbed", true) }
|
||||
)
|
||||
)
|
||||
} else {
|
||||
// If no codec preferences, use old sorting logic
|
||||
sortedWith(
|
||||
compareBy(
|
||||
{ Regex("\\[(.+?) download]").containsMatchIn(it.quality) },
|
||||
{ isDub && !it.quality.contains("dubbed", true) },
|
||||
{ isEfficient && !arrayOf("hevc", "265", "av1").any { q -> it.quality.contains(q, true) } },
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchTrackers(): String {
|
||||
val request = Request.Builder()
|
||||
|
@ -616,6 +648,18 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||
}
|
||||
summary = "Codec: (HEVC / x265) & AV1. High-quality video with less data usage."
|
||||
}.also(screen::addPreference)
|
||||
MultiSelectListPreference(screen.context).apply {
|
||||
key = PREF_CODEC_KEY
|
||||
title = "Preferred Codecs"
|
||||
entries = PREF_CODEC
|
||||
entryValues = PREF_CODEC_VALUE
|
||||
setDefaultValue(PREF_CODEC_DEFAULT)
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
preferences.edit().putStringSet(key, newValue as Set<String>).commit()
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -897,7 +941,22 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||
|
||||
private const val IS_EFFICIENT_KEY = "efficient"
|
||||
private const val IS_EFFICIENT_DEFAULT = false
|
||||
|
||||
private const val PREF_CODEC_KEY = "codec_selection"
|
||||
private val PREF_CODEC = arrayOf(
|
||||
"x264",
|
||||
"x265/HEVC",
|
||||
"AV1",
|
||||
"VP9",
|
||||
"Other"
|
||||
)
|
||||
private val PREF_CODEC_VALUE = arrayOf(
|
||||
"x264",
|
||||
"x265",
|
||||
"av1",
|
||||
"vp9",
|
||||
"other"
|
||||
)
|
||||
private val PREF_CODEC_DEFAULT = setOf<String>() // Empty by default to show al
|
||||
private val DATE_TIME_FORMATTER by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
|
||||
}
|
||||
|
@ -905,5 +964,6 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||
private val DATE_FORMATTER by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue