Fix NPEs in some sources (#1773)

* Siren Komik: fix NPE

* West Manga: fix NPE
This commit is contained in:
AwkwardPeak7 2024-03-09 16:07:26 +05:00 committed by Draff
parent e2e0d9b034
commit 2f4f7001ea
5 changed files with 88 additions and 32 deletions

View File

@ -1,9 +1,9 @@
ext { ext {
extName = 'Siren Komik' extName = 'Siren Komik'
extClass = '.MangKomik' extClass = '.SirenKomik'
themePkg = 'mangathemesia' themePkg = 'mangathemesia'
baseUrl = 'https://sirenkomik.my.id' baseUrl = 'https://sirenkomik.my.id'
overrideVersionCode = 2 overrideVersionCode = 3
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -1,29 +0,0 @@
package eu.kanade.tachiyomi.extension.id.mangkomik
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Page
import org.jsoup.nodes.Document
class MangKomik : MangaThemesia("Siren Komik", "https://sirenkomik.my.id", "id") {
override val id = 8457447675410081142
override val hasProjectPage = true
override fun pageListParse(document: Document): List<Page> {
// Get external JS for image urls
val scriptEl = document.selectFirst("script[data-minify]")
val scriptUrl = scriptEl?.attr("src")
if (scriptUrl.isNullOrEmpty()) {
return super.pageListParse(document)
}
val scriptResponse = client.newCall(
GET(scriptUrl, headers),
).execute()
// Inject external JS
scriptEl.text(scriptResponse.body.string())
return super.pageListParse(document)
}
}

View File

@ -0,0 +1,51 @@
package eu.kanade.tachiyomi.extension.id.mangkomik
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.util.Locale
class SirenKomik : MangaThemesia(
"Siren Komik",
"https://sirenkomik.my.id",
"id",
dateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale("id")),
) {
override val id = 8457447675410081142
override val hasProjectPage = true
override val seriesTitleSelector = "h1.judul-komik"
override val seriesThumbnailSelector = ".gambar-kecil img"
override val seriesGenreSelector = ".genre-komik a"
override val seriesAuthorSelector = ".keterangan-komik:contains(author) span"
override val seriesArtistSelector = ".keterangan-komik:contains(artist) span"
override fun chapterFromElement(element: Element) = SChapter.create().apply {
val urlElements = element.select("a")
setUrlWithoutDomain(urlElements.attr("href"))
name = element.select(".nomer-chapter").text().ifBlank { urlElements.first()!!.text() }
date_upload = element.selectFirst(".tgl-chapter")?.text().parseChapterDate()
}
override fun pageListParse(document: Document): List<Page> {
// Get external JS for image urls
val scriptEl = document.selectFirst("script[data-minify]")
val scriptUrl = scriptEl?.attr("src")
if (scriptUrl.isNullOrEmpty()) {
return super.pageListParse(document)
}
val scriptResponse = client.newCall(
GET(scriptUrl, headers),
).execute()
// Inject external JS
scriptEl.text(scriptResponse.body.string())
return super.pageListParse(document)
}
}

View File

@ -3,7 +3,7 @@ ext {
extClass = '.WestManga' extClass = '.WestManga'
themePkg = 'mangathemesia' themePkg = 'mangathemesia'
baseUrl = 'https://westmanga.fun' baseUrl = 'https://westmanga.fun'
overrideVersionCode = 3 overrideVersionCode = 4
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -2,7 +2,10 @@ package eu.kanade.tachiyomi.extension.id.westmanga
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.model.SManga
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.jsoup.nodes.Document
import java.util.Locale
class WestManga : MangaThemesia("West Manga", "https://westmanga.fun", "id") { class WestManga : MangaThemesia("West Manga", "https://westmanga.fun", "id") {
// Formerly "West Manga (WP Manga Stream)" // Formerly "West Manga (WP Manga Stream)"
@ -12,8 +15,39 @@ class WestManga : MangaThemesia("West Manga", "https://westmanga.fun", "id") {
.rateLimit(4) .rateLimit(4)
.build() .build()
override val seriesTitleSelector = "h1"
override val seriesDetailsSelector = ".seriestucontent" override val seriesDetailsSelector = ".seriestucontent"
override val seriesTypeSelector = ".infotable tr:contains(Type) td:last-child" override val seriesTypeSelector = ".infotable tr:contains(Type) td:last-child"
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
document.selectFirst(seriesDetailsSelector)!!.let { seriesDetails ->
title = document.selectFirst("div.postbody h1")!!.text()
artist = seriesDetails.selectFirst(seriesArtistSelector)?.ownText().removeEmptyPlaceholder()
author = seriesDetails.selectFirst(seriesAuthorSelector)?.ownText().removeEmptyPlaceholder()
description = seriesDetails.select(seriesDescriptionSelector).joinToString("\n") { it.text() }.trim()
// Add alternative name to manga description
val altName = document.selectFirst(".seriestualt")?.ownText().takeIf { it.isNullOrBlank().not() }
altName?.let {
description = "$description\n\n$altNamePrefix$altName".trim()
}
val genres = seriesDetails.select(seriesGenreSelector).map { it.text() }.toMutableList()
// Add series type (manga/manhwa/manhua/other) to genre
seriesDetails.selectFirst(seriesTypeSelector)?.ownText().takeIf { it.isNullOrBlank().not() }?.let { genres.add(it) }
genre = genres.map { genre ->
genre.lowercase(Locale.forLanguageTag(lang)).replaceFirstChar { char ->
if (char.isLowerCase()) {
char.titlecase(Locale.forLanguageTag(lang))
} else {
char.toString()
}
}
}
.joinToString { it.trim() }
status = seriesDetails.selectFirst(seriesStatusSelector)?.text().parseStatus()
thumbnail_url = seriesDetails.select(seriesThumbnailSelector).imgAttr()
}
}
override val hasProjectPage = true override val hasProjectPage = true
} }