feat(all/torrentioanime): Add "Show Upcoming Episodes" (#3101)
Co-authored-by: Secozzi <49240133+Secozzi@users.noreply.github.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Torrentio Anime (Torrent / Debrid)'
|
extName = 'Torrentio Anime (Torrent / Debrid)'
|
||||||
extClass = '.Torrentio'
|
extClass = '.Torrentio'
|
||||||
extVersionCode = 3
|
extVersionCode = 4
|
||||||
containsNsfw = false
|
containsNsfw = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import androidx.preference.EditTextPreference
|
|||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.MultiSelectListPreference
|
import androidx.preference.MultiSelectListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import eu.kanade.tachiyomi.animeextension.all.torrentioanime.dto.AnilistMeta
|
import eu.kanade.tachiyomi.animeextension.all.torrentioanime.dto.AnilistMeta
|
||||||
import eu.kanade.tachiyomi.animeextension.all.torrentioanime.dto.AnilistMetaLatest
|
import eu.kanade.tachiyomi.animeextension.all.torrentioanime.dto.AnilistMetaLatest
|
||||||
import eu.kanade.tachiyomi.animeextension.all.torrentioanime.dto.DetailsById
|
import eu.kanade.tachiyomi.animeextension.all.torrentioanime.dto.DetailsById
|
||||||
@ -361,9 +362,11 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
|
|
||||||
return when (episodeList.meta?.type) {
|
return when (episodeList.meta?.type) {
|
||||||
"series" -> {
|
"series" -> {
|
||||||
episodeList.meta.videos?.filter { video ->
|
episodeList.meta.videos
|
||||||
(video.released?.let { parseDate(it) } ?: 0L) <= System.currentTimeMillis()
|
?.let { videos ->
|
||||||
}?.map { video ->
|
if (preferences.getBoolean(UPCOMING_EP_KEY, UPCOMING_EP_DEFAULT)) { videos } else { videos.filter { video -> (video.released?.let { parseDate(it) } ?: 0L) <= System.currentTimeMillis() } }
|
||||||
|
}
|
||||||
|
?.map { video ->
|
||||||
SEpisode.create().apply {
|
SEpisode.create().apply {
|
||||||
episode_number = video.episode?.toFloat() ?: 0.0F
|
episode_number = video.episode?.toFloat() ?: 0.0F
|
||||||
url = "/stream/series/${video.videoId}.json"
|
url = "/stream/series/${video.videoId}.json"
|
||||||
@ -373,6 +376,7 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
?.replaceFirst("\\d+\\s*".toRegex(), "")
|
?.replaceFirst("\\d+\\s*".toRegex(), "")
|
||||||
?.trim()
|
?.trim()
|
||||||
}"
|
}"
|
||||||
|
scanlator = (video.released?.let { parseDate(it) } ?: 0L).takeIf { it > System.currentTimeMillis() }?.let { "Upcoming" } ?: ""
|
||||||
}
|
}
|
||||||
}.orEmpty().reversed()
|
}.orEmpty().reversed()
|
||||||
}
|
}
|
||||||
@ -424,7 +428,7 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
context.let {
|
context.let {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
it,
|
it,
|
||||||
"Kindly input the token in the extension settings.",
|
"Kindly input the debrid token in the extension settings.",
|
||||||
Toast.LENGTH_LONG,
|
Toast.LENGTH_LONG,
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
@ -488,7 +492,7 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
entries = PREF_DEBRID_ENTRIES
|
entries = PREF_DEBRID_ENTRIES
|
||||||
entryValues = PREF_DEBRID_VALUES
|
entryValues = PREF_DEBRID_VALUES
|
||||||
setDefaultValue("none")
|
setDefaultValue("none")
|
||||||
summary = "Select 'None' to use torrents. If you choose a Debrid provider, please enter your token key."
|
summary = "Choose 'None' for Torrent. If you select a Debrid provider, enter your token key. No token key is needed if 'None' is selected."
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
val selected = newValue as String
|
val selected = newValue as String
|
||||||
@ -588,6 +592,15 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
preferences.edit().putString(key, entry).commit()
|
preferences.edit().putString(key, entry).commit()
|
||||||
}
|
}
|
||||||
}.also(screen::addPreference)
|
}.also(screen::addPreference)
|
||||||
|
|
||||||
|
SwitchPreferenceCompat(screen.context).apply {
|
||||||
|
key = UPCOMING_EP_KEY
|
||||||
|
title = "Show Upcoming Episodes"
|
||||||
|
setDefaultValue(UPCOMING_EP_DEFAULT)
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
preferences.edit().putBoolean(key, newValue as Boolean).commit()
|
||||||
|
}
|
||||||
|
}.also(screen::addPreference)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -596,7 +609,7 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
// Token
|
// Token
|
||||||
private const val PREF_TOKEN_KEY = "token"
|
private const val PREF_TOKEN_KEY = "token"
|
||||||
private const val PREF_TOKEN_DEFAULT = ""
|
private const val PREF_TOKEN_DEFAULT = ""
|
||||||
private const val PREF_TOKEN_SUMMARY = "For temporary uses. Updating the extension will erase this setting."
|
private const val PREF_TOKEN_SUMMARY = "Exclusive to Debrid providers; not intended for Torrents."
|
||||||
|
|
||||||
// Debrid
|
// Debrid
|
||||||
private const val PREF_DEBRID_KEY = "debrid_provider"
|
private const val PREF_DEBRID_KEY = "debrid_provider"
|
||||||
@ -847,6 +860,9 @@ class Torrentio : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
"native",
|
"native",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private const val UPCOMING_EP_KEY = "upcoming_ep"
|
||||||
|
private const val UPCOMING_EP_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)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user