Yomiroll: Fix crash when using new pref (#1353)
UHDMovies: add blank check
This commit is contained in:
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'Yomiroll'
|
extName = 'Yomiroll'
|
||||||
pkgNameSuffix = 'all.kamyroll'
|
pkgNameSuffix = 'all.kamyroll'
|
||||||
extClass = '.Yomiroll'
|
extClass = '.Yomiroll'
|
||||||
extVersionCode = 17
|
extVersionCode = 18
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class AccessTokenInterceptor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TOKEN_PREF_KEY = "access_token_data"
|
private const val TOKEN_PREF_KEY = "access_token_data"
|
||||||
private const val LOCAL_TOKEN_PREF_KEY = "local_access_token_data_test_adwa"
|
private const val LOCAL_TOKEN_PREF_KEY = "local_access_token_data"
|
||||||
private const val PREF_FETCH_LOCAL_SUBS = "preferred_local_subs"
|
private const val PREF_FETCH_LOCAL_SUBS = "preferred_local_subs"
|
||||||
|
|
||||||
private val DateFormatter by lazy {
|
private val DateFormatter by lazy {
|
||||||
|
@ -19,6 +19,7 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.awaitAll
|
import kotlinx.coroutines.awaitAll
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
@ -71,6 +72,7 @@ class Yomiroll : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
private const val PREF_AUD = "preferred_audio"
|
private const val PREF_AUD = "preferred_audio"
|
||||||
private const val PREF_SUB = "preferred_sub"
|
private const val PREF_SUB = "preferred_sub"
|
||||||
private const val PREF_SUB_TYPE = "preferred_sub_type"
|
private const val PREF_SUB_TYPE = "preferred_sub_type"
|
||||||
|
|
||||||
// there is one in AccessTokenInterceptor too for below
|
// there is one in AccessTokenInterceptor too for below
|
||||||
private const val PREF_FETCH_LOCAL_SUBS = "preferred_local_subs"
|
private const val PREF_FETCH_LOCAL_SUBS = "preferred_local_subs"
|
||||||
}
|
}
|
||||||
@ -548,38 +550,24 @@ class Yomiroll : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
this.apply {
|
this.apply {
|
||||||
key = PREF_FETCH_LOCAL_SUBS
|
key = PREF_FETCH_LOCAL_SUBS
|
||||||
title = "Fetch Local Subs (Don't Spam this please!)"
|
title = "Fetch Local Subs (Don't Spam this please!)"
|
||||||
Thread {
|
runBlocking {
|
||||||
summary = try {
|
withContext(Dispatchers.IO) { summary = getTokenDetail() }
|
||||||
val storedToken = tokenInterceptor.getLocalToken()
|
}
|
||||||
"""Token location: ${storedToken?.bucket?.substringAfter("/")?.substringBefore("/")}
|
|
||||||
|Expires: ${storedToken?.policyExpire?.let { DateFormatter.format(it) } ?: "---"}
|
|
||||||
""".trimMargin()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
setDefaultValue(false)
|
setDefaultValue(false)
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
val new = newValue as Boolean
|
val new = newValue as Boolean
|
||||||
if (new) {
|
Thread {
|
||||||
Thread {
|
runBlocking {
|
||||||
summary = try {
|
if (new) {
|
||||||
val storedToken = tokenInterceptor.getLocalToken(true)!!
|
withContext(Dispatchers.IO) { summary = getTokenDetail(true) }
|
||||||
"""Token location: ${storedToken.bucket?.substringAfter("/")?.substringBefore("/") ?: ""}
|
} else {
|
||||||
|Expires: ${storedToken.policyExpire?.let { DateFormatter.format(it) } ?: ""}
|
tokenInterceptor.removeLocalToken()
|
||||||
|
summary = """Token location:
|
||||||
|
|Expires:
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
} catch (e: Exception) {
|
|
||||||
""
|
|
||||||
}
|
}
|
||||||
}.start()
|
}
|
||||||
} else {
|
}.start()
|
||||||
Thread {
|
|
||||||
tokenInterceptor.removeLocalToken()
|
|
||||||
summary = """Token location:
|
|
||||||
|Expires:""".trimMargin()
|
|
||||||
}.start()
|
|
||||||
}
|
|
||||||
preferences.edit().putBoolean(key, new).commit()
|
preferences.edit().putBoolean(key, new).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -592,4 +580,15 @@ class Yomiroll : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
runBlocking {
|
runBlocking {
|
||||||
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getTokenDetail(force: Boolean = false): String {
|
||||||
|
return try {
|
||||||
|
val storedToken = tokenInterceptor.getLocalToken(force)
|
||||||
|
"""Token location: ${storedToken?.bucket?.substringAfter("/")?.substringBefore("/") ?: ""}
|
||||||
|
|Expires: ${storedToken?.policyExpire?.let { DateFormatter.format(it) } ?: ""}
|
||||||
|
""".trimMargin()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'UHD Movies'
|
extName = 'UHD Movies'
|
||||||
pkgNameSuffix = 'en.uhdmovies'
|
pkgNameSuffix = 'en.uhdmovies'
|
||||||
extClass = '.UHDMovies'
|
extClass = '.UHDMovies'
|
||||||
extVersionCode = 9
|
extVersionCode = 10
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
urlJson.urls.parallelMap { url ->
|
urlJson.urls.parallelMap { url ->
|
||||||
runCatching {
|
runCatching {
|
||||||
val (videos, mediaUrl) = extractVideo(url)
|
val (videos, mediaUrl) = extractVideo(url)
|
||||||
if (videos.isEmpty()) failedMediaUrl.add(Pair(mediaUrl, url.quality))
|
if (videos.isEmpty() && mediaUrl.isNotBlank()) failedMediaUrl.add(Pair(mediaUrl, url.quality))
|
||||||
return@runCatching videos
|
return@runCatching videos
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user