Xkcd: throw an error on interactive comics (#15634)

This commit is contained in:
ObserverOfTime 2023-03-13 16:35:32 +02:00 committed by GitHub
parent 38e7e2347a
commit 4aeaba9548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 12 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'xkcd'
pkgNameSuffix = 'all.xkcd'
extClass = '.XkcdFactory'
extVersionCode = 12
extVersionCode = 13
}
apply from: "$rootDir/common.gradle"

View File

@ -30,8 +30,7 @@ open class Xkcd(
"A webcomic of romance, sarcasm, math and language."
protected open val interactiveText =
"To experience the interactive version of this comic," +
"\nopen it in WebView/browser."
"To experience the interactive version of this comic, open it in WebView/browser."
protected open val altTextUrl = LATIN_ALT_TEXT_URL
@ -98,7 +97,7 @@ open class Xkcd(
// if the img tag is empty or has siblings then it is an interactive comic
val img = response.asJsoup().selectFirst(imageSelector)?.takeIf {
it.nextElementSibling() == null
} ?: return listOf(Page(0, "", interactiveText.image()))
} ?: error(interactiveText)
// if an HD image is available it'll be the srcset attribute
val image = when {

View File

@ -11,8 +11,7 @@ class XkcdES : Xkcd("https://es.xkcd.com", "es") {
// Google translated, sorry
override val interactiveText =
"Para experimentar la versión interactiva de este cómic," +
"\nábralo en WebView/navegador."
"Para experimentar la versión interactiva de este cómic, ábralo en WebView/navegador."
override val chapterListSelector = "#archive-ul > ul > li > a"

View File

@ -13,7 +13,7 @@ class XkcdKO : Xkcd("https://xkcdko.com", "ko") {
// Google translated, sorry
override val interactiveText =
"이 만화의 대화형 버전을 경험하려면\nWebView/브라우저에서 엽니다."
"이 만화의 대화형 버전을 경험하려면 WebView/브라우저에서 엽니다."
override val altTextUrl = CJK_ALT_TEXT_URL
@ -33,8 +33,7 @@ class XkcdKO : Xkcd("https://xkcdko.com", "ko") {
override fun pageListParse(response: Response): List<Page> {
// if the img tag is empty then it is an interactive comic
val img = response.asJsoup().selectFirst(imageSelector)
?: return listOf(Page(0, "", interactiveText.image()))
val img = response.asJsoup().selectFirst(imageSelector) ?: error(interactiveText)
// if an HD image is available it'll be the srcset attribute
val image = when {

View File

@ -21,7 +21,7 @@ class XkcdZH : Xkcd("https://xkcd.tw", "zh", "yyyy-MM-dd HH:mm:ss") {
// Google translated, sorry
override val interactiveText =
"要體驗本漫畫的互動版\n請在WebView/瀏覽器中打開。"
"要體驗本漫畫的互動版請在WebView/瀏覽器中打開。"
override val altTextUrl = CJK_ALT_TEXT_URL
@ -49,8 +49,7 @@ class XkcdZH : Xkcd("https://xkcd.tw", "zh", "yyyy-MM-dd HH:mm:ss") {
override fun pageListParse(response: Response): List<Page> {
// if img tag is empty then it is an interactive comic
val img = response.asJsoup().selectFirst(imageSelector)
?: return listOf(Page(0, "", interactiveText.image()))
val img = response.asJsoup().selectFirst(imageSelector) ?: error(interactiveText)
val image = img.attr("abs:src")