MangaGun: Fix page list parse and update domain (#10593)
* MangaGun: Fix page list parse and update domain * MangaGun: add comments. * MangaGun: Update icon and source name. * Update src/ja/mangagun/src/eu/kanade/tachiyomi/extension/ja/mangagun/MangaGun.kt Co-authored-by: Luqman <16263232+Riztard@users.noreply.github.com> * Update extension name --------- Co-authored-by: Luqman <16263232+Riztard@users.noreply.github.com>
@ -1,9 +1,9 @@
|
||||
ext {
|
||||
extName = 'MangaGun'
|
||||
extName = 'NihonKuni'
|
||||
extClass = '.MangaGun'
|
||||
themePkg = 'fmreader'
|
||||
baseUrl = 'https://mangagun.net'
|
||||
overrideVersionCode = 4
|
||||
baseUrl = 'https://nihonkuni.com'
|
||||
overrideVersionCode = 5
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 23 KiB |
@ -1,6 +1,5 @@
|
||||
package eu.kanade.tachiyomi.extension.ja.mangagun
|
||||
|
||||
import android.util.Base64
|
||||
import eu.kanade.tachiyomi.multisrc.fmreader.FMReader
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
@ -8,17 +7,23 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.Request
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
import java.util.Calendar
|
||||
|
||||
private const val DOMAIN = "mangagun.net"
|
||||
private const val DOMAIN = "nihonkuni.com"
|
||||
|
||||
/**
|
||||
* This plugin is for the website originally named MangaGun(漫画軍), which was later renamed to NihonKuni(日本国). Please do not be confused by the names.
|
||||
*/
|
||||
class MangaGun : FMReader("NihonKuni", "https://$DOMAIN", "ja") {
|
||||
|
||||
// Formerly "MangaGun(漫画軍)"
|
||||
override val id = 3811800324362294701
|
||||
|
||||
class MangaGun : FMReader("MangaGun", "https://$DOMAIN", "ja") {
|
||||
override val infoElementSelector = "div.row div.row"
|
||||
|
||||
// source is picky about URL format
|
||||
@ -31,17 +36,6 @@ class MangaGun : FMReader("MangaGun", "https://$DOMAIN", "ja") {
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request = mangaRequest("views", page)
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga {
|
||||
return SManga.create().apply {
|
||||
element.select(headerSelector).let {
|
||||
setUrlWithoutDomain(it.attr("abs:href"))
|
||||
title = it.text()
|
||||
}
|
||||
thumbnail_url = element.select("img, .thumb-wrapper .img-in-ratio").attr("style")
|
||||
.substringAfter("background-image:url(").substringBefore(")")
|
||||
}
|
||||
}
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request = mangaRequest("last_update", page)
|
||||
|
||||
override fun getImgAttr(element: Element?): String? {
|
||||
@ -51,15 +45,21 @@ class MangaGun : FMReader("MangaGun", "https://$DOMAIN", "ja") {
|
||||
element.hasAttr("data-src") -> element.attr("abs:data-src")
|
||||
element.hasAttr("data-bg") -> element.attr("abs:data-bg")
|
||||
element.hasAttr("data-srcset") -> element.attr("abs:data-srcset")
|
||||
element.hasAttr("style") -> element.attr("style").substringAfter("('")
|
||||
.substringBefore("')")
|
||||
element.hasAttr("style") -> element.attr("style").substringAfter("url(")
|
||||
.substringBefore(")").trim('\'', '"')
|
||||
|
||||
else -> element.attr("abs:src")
|
||||
}
|
||||
}
|
||||
|
||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
||||
val slug = manga.url.substringAfter("raw-").substringBefore(".html")
|
||||
val index = manga.url.indexOf("manga-")
|
||||
// Handling version compatibility, previous version used the 'raw-' prefix.
|
||||
val slug = if (index >= 0) {
|
||||
manga.url.substring(index + 6)
|
||||
} else {
|
||||
manga.url.substringAfter("raw-")
|
||||
}.substringBefore(".html")
|
||||
|
||||
return client.newCall(
|
||||
GET(
|
||||
@ -99,39 +99,14 @@ class MangaGun : FMReader("MangaGun", "https://$DOMAIN", "ja") {
|
||||
return chapterDate.timeInMillis
|
||||
}
|
||||
|
||||
private fun handleDdosProtect(document: Document): Document {
|
||||
val key = document.select("script:containsData(document.cookie)").first()?.html()
|
||||
?.substringAfter("escape('")?.substringBefore("'")
|
||||
if (key != null) {
|
||||
// save cookie ct_anti_ddos_key
|
||||
client.cookieJar.saveFromResponse(
|
||||
baseUrl.toHttpUrl(),
|
||||
listOf(
|
||||
Cookie.Builder()
|
||||
.name("ct_anti_ddos_key")
|
||||
.value(key)
|
||||
.domain(DOMAIN)
|
||||
.path("/")
|
||||
.build(),
|
||||
),
|
||||
)
|
||||
}
|
||||
return document.select("noscript div a").attr("abs:href").let { url ->
|
||||
client.newCall(GET(url, headers)).execute().asJsoup()
|
||||
}
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val ddosProtect = document.select("title").first()?.text()
|
||||
?.contains("Manga Gun - DDoS protection") ?: false
|
||||
return if (ddosProtect) {
|
||||
handleDdosProtect(document)
|
||||
} else {
|
||||
document
|
||||
}.select(".chapter-content img.chapter-img")
|
||||
.eachAttr("data-img")
|
||||
.mapIndexed { index, img ->
|
||||
Page(index, "", Base64.decode(img, Base64.DEFAULT).decodeToString())
|
||||
}
|
||||
val html = document.select("script:containsData(window.chapterImages)").first()!!.data()
|
||||
.substringAfter("window.chapterImages=\"").substringBefore("\"")
|
||||
.replace("\\/", "/")
|
||||
.replace("\\n", "")
|
||||
.replace("\\r", "")
|
||||
return Jsoup.parse(html).select("img.chapter-img").mapIndexed { index, element ->
|
||||
Page(index, imageUrl = element.attr("abs:data-srcset").trim())
|
||||
}
|
||||
}
|
||||
}
|
||||
|