feat(all/torrentio): Dubbed and efficient video toggles in settings (#3169)
This commit is contained in:
parent
2009c1363d
commit
24f5c51c9d
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Torrentio Anime (Torrent / Debrid)'
|
extName = 'Torrentio Anime (Torrent / Debrid)'
|
||||||
extClass = '.Torrentio'
|
extClass = '.Torrentio'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
containsNsfw = false
|
containsNsfw = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,10 +480,23 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
val trackerList = animeTrackers.split(",").map { it.trim() }.filter { it.isNotBlank() }.joinToString("&tr=")
|
val trackerList = animeTrackers.split(",").map { it.trim() }.filter { it.isNotBlank() }.joinToString("&tr=")
|
||||||
"magnet:?xt=urn:btih:${stream.infoHash}&dn=${stream.infoHash}&tr=$trackerList&index=${stream.fileIdx}"
|
"magnet:?xt=urn:btih:${stream.infoHash}&dn=${stream.infoHash}&tr=$trackerList&index=${stream.fileIdx}"
|
||||||
} else stream.url ?: ""
|
} else stream.url ?: ""
|
||||||
Video(urlOrHash, stream.title ?: "", urlOrHash)
|
Video(urlOrHash, ((stream.name?.replace("Torrentio\n", "") ?: "") + "\n" + stream.title), urlOrHash)
|
||||||
}.orEmpty()
|
}.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(
|
||||||
|
compareBy(
|
||||||
|
{ !Regex("\\[(.+?) download]").containsMatchIn(it.quality) },
|
||||||
|
{ isDub && it.quality.contains("dubbed", true) },
|
||||||
|
{ isEfficient && arrayOf("hevc", "265", "av1").any { q -> it.quality.contains(q, true) } },
|
||||||
|
),
|
||||||
|
).reversed()
|
||||||
|
}
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
// Debrid provider
|
// Debrid provider
|
||||||
ListPreference(screen.context).apply {
|
ListPreference(screen.context).apply {
|
||||||
@ -601,6 +614,25 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
preferences.edit().putBoolean(key, newValue as Boolean).commit()
|
preferences.edit().putBoolean(key, newValue as Boolean).commit()
|
||||||
}
|
}
|
||||||
}.also(screen::addPreference)
|
}.also(screen::addPreference)
|
||||||
|
|
||||||
|
SwitchPreferenceCompat(screen.context).apply {
|
||||||
|
key = IS_DUB_KEY
|
||||||
|
title = "Dubbed Video Priority"
|
||||||
|
setDefaultValue(IS_DUB_DEFAULT)
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
preferences.edit().putBoolean(key, newValue as Boolean).commit()
|
||||||
|
}
|
||||||
|
}.also(screen::addPreference)
|
||||||
|
|
||||||
|
SwitchPreferenceCompat(screen.context).apply {
|
||||||
|
key = IS_EFFICIENT_KEY
|
||||||
|
title = "Efficient Video Priority"
|
||||||
|
setDefaultValue(IS_EFFICIENT_DEFAULT)
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
preferences.edit().putBoolean(key, newValue as Boolean).commit()
|
||||||
|
}
|
||||||
|
summary = "Codec: (HEVC / x265) & AV1. High-quality video with less data usage."
|
||||||
|
}.also(screen::addPreference)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -863,6 +895,12 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
private const val UPCOMING_EP_KEY = "upcoming_ep"
|
private const val UPCOMING_EP_KEY = "upcoming_ep"
|
||||||
private const val UPCOMING_EP_DEFAULT = false
|
private const val UPCOMING_EP_DEFAULT = false
|
||||||
|
|
||||||
|
private const val IS_DUB_KEY = "dubbed"
|
||||||
|
private const val IS_DUB_DEFAULT = false
|
||||||
|
|
||||||
|
private const val IS_EFFICIENT_KEY = "efficient"
|
||||||
|
private const val IS_EFFICIENT_DEFAULT = false
|
||||||
|
|
||||||
private val DATE_FORMATTER by lazy {
|
private val DATE_FORMATTER by lazy {
|
||||||
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
|
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user