MangaReader - update parsing (#4152)
* MangaReader - update parsing * Update build.gradle
This commit is contained in:
parent
48cdd49994
commit
524562993c
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'Mangareader & Mangapanda'
|
||||
pkgNameSuffix = 'en.mangareader'
|
||||
extClass = '.MRPFactory'
|
||||
extVersionCode = 5
|
||||
extVersionCode = 6
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -27,54 +27,11 @@ abstract class MRP(
|
|||
|
||||
override val client: OkHttpClient = network.cloudflareClient
|
||||
|
||||
override fun popularMangaSelector() = "div.mangaresultitem"
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
return if (page == 1) {
|
||||
GET("$baseUrl/popular/")
|
||||
} else {
|
||||
GET("$baseUrl/popular/$nextPageNumber")
|
||||
}
|
||||
return GET("$baseUrl/popular" + if (page > 1) "/${(page - 1) * 30}" else "", headers)
|
||||
}
|
||||
|
||||
// Site's page numbering is weird, have to do some work to get the right page number for additional requests
|
||||
private lateinit var nextPageNumber: String
|
||||
|
||||
private val nextPageSelector = "div#sp a:contains(>)"
|
||||
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
val document = response.asJsoup()
|
||||
|
||||
nextPageNumber = document.select(nextPageSelector).attr("href")
|
||||
.substringAfterLast("/").substringBefore("\"")
|
||||
|
||||
val manga = mutableListOf<SManga>()
|
||||
document.select(popularMangaSelector()).map { manga.add(popularMangaFromElement(it)) }
|
||||
|
||||
return MangasPage(manga, document.select(nextPageSelector).hasText())
|
||||
}
|
||||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val document = response.asJsoup()
|
||||
|
||||
nextPageNumber = document.select(nextPageSelector).attr("href")
|
||||
.substringAfterLast("/").substringBefore("\"")
|
||||
|
||||
val manga = mutableListOf<SManga>()
|
||||
document.select(latestUpdatesSelector()).map { manga.add(latestUpdatesFromElement(it)) }
|
||||
|
||||
return MangasPage(manga, document.select(nextPageSelector).hasText())
|
||||
}
|
||||
|
||||
override fun latestUpdatesSelector() = "tr.c3"
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request {
|
||||
return if (page == 1) {
|
||||
GET("$baseUrl/latest/")
|
||||
} else {
|
||||
GET("$baseUrl/latest/$nextPageNumber")
|
||||
}
|
||||
}
|
||||
override fun popularMangaSelector() = "div.mangaresultitem"
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga {
|
||||
val manga = SManga.create()
|
||||
|
@ -86,6 +43,30 @@ abstract class MRP(
|
|||
return manga
|
||||
}
|
||||
|
||||
override fun popularMangaNextPageSelector() = "div#sp strong + a"
|
||||
|
||||
private var nextLatestPage: String? = null
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request {
|
||||
return if (page == 1) {
|
||||
nextLatestPage = null
|
||||
GET("$baseUrl/latest", headers)
|
||||
} else {
|
||||
GET(nextLatestPage!!, headers)
|
||||
}
|
||||
}
|
||||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val document = response.asJsoup()
|
||||
|
||||
val mangas = document.select(latestUpdatesSelector()).map { latestUpdatesFromElement(it) }
|
||||
nextLatestPage = document.select(latestUpdatesNextPageSelector()).firstOrNull()?.attr("abs:href")
|
||||
|
||||
return MangasPage(mangas, nextLatestPage != null)
|
||||
}
|
||||
|
||||
override fun latestUpdatesSelector() = "tr.c3"
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SManga {
|
||||
val manga = SManga.create()
|
||||
element.select("a.chapter").first().let {
|
||||
|
@ -95,20 +76,12 @@ abstract class MRP(
|
|||
return manga
|
||||
}
|
||||
|
||||
override fun popularMangaNextPageSelector() = "Not using this"
|
||||
|
||||
override fun latestUpdatesNextPageSelector() = "Not using this"
|
||||
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
return if (page == 1) {
|
||||
GET("$baseUrl/search/?w=$query&p", headers)
|
||||
} else {
|
||||
GET("$baseUrl/search/?w=$query&p=$nextPageNumber", headers)
|
||||
}
|
||||
return GET("$baseUrl/search/?w=$query" + if (page > 1) "&p=${(page - 1) * 30}" else "", headers)
|
||||
}
|
||||
|
||||
override fun searchMangaParse(response: Response) = popularMangaParse(response)
|
||||
|
||||
override fun searchMangaSelector() = popularMangaSelector()
|
||||
|
||||
override fun searchMangaFromElement(element: Element) = popularMangaFromElement(element)
|
||||
|
@ -130,7 +103,7 @@ abstract class MRP(
|
|||
return manga
|
||||
}
|
||||
|
||||
private fun parseStatus(status: String?) = when {
|
||||
protected fun parseStatus(status: String?) = when {
|
||||
status == null -> SManga.UNKNOWN
|
||||
status.contains("Ongoing") -> SManga.ONGOING
|
||||
status.contains("Completed") -> SManga.COMPLETED
|
||||
|
@ -173,8 +146,6 @@ abstract class MRP(
|
|||
|
||||
// Get the image from the requested page
|
||||
override fun imageUrlParse(document: Document): String {
|
||||
return document.select("a img").attr("src")
|
||||
return document.select("a img").attr("abs:src")
|
||||
}
|
||||
|
||||
override fun getFilterList() = FilterList()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
package eu.kanade.tachiyomi.extension.en.mangareader
|
||||
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.github.salomonbrys.kotson.string
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
|
||||
class MRPFactory : SourceFactory {
|
||||
override fun createSources(): List<Source> = listOf(
|
||||
|
@ -9,5 +18,42 @@ class MRPFactory : SourceFactory {
|
|||
Mangapanda())
|
||||
}
|
||||
|
||||
class Mangareader : MRP("Mangareader", "https://www.mangareader.net")
|
||||
class Mangareader : MRP("Mangareader", "https://www.mangareader.net") {
|
||||
override fun popularMangaSelector() = "div > div > table"
|
||||
override fun popularMangaFromElement(element: Element): SManga {
|
||||
return SManga.create().apply {
|
||||
element.select("a").let {
|
||||
setUrlWithoutDomain(it.attr("href"))
|
||||
title = it.text()
|
||||
}
|
||||
thumbnail_url = element.select("div[data-src]").attr("abs:data-src")
|
||||
}
|
||||
}
|
||||
override fun popularMangaNextPageSelector() = "li:has(.pcur) + li a"
|
||||
override fun latestUpdatesSelector() = "div:has(i) + div div > a"
|
||||
override fun latestUpdatesFromElement(element: Element): SManga {
|
||||
return SManga.create().apply {
|
||||
setUrlWithoutDomain(element.attr("href"))
|
||||
title = element.text()
|
||||
}
|
||||
}
|
||||
override fun mangaDetailsParse(document: Document): SManga {
|
||||
return SManga.create().apply {
|
||||
thumbnail_url = document.select("div > img[alt]").attr("abs:src")
|
||||
status = parseStatus(document.select("div > table tr td:contains(Status:) + td").text())
|
||||
author = document.select("div > table tr td:contains(Author:) + td").text()
|
||||
artist = document.select("div > table tr td:contains(Artist:) + td").text()
|
||||
genre = document.select("div > table tr td:contains(Genre:) + td").joinToString { it.text() }
|
||||
description = document.select("div > div + p").text()
|
||||
}
|
||||
}
|
||||
override fun chapterListSelector() = "tr:has(i)"
|
||||
private val gson by lazy { Gson() }
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val script = document.select("script:containsData(document[)").firstOrNull()?.data() ?: throw Exception("script not found")
|
||||
return gson.fromJson<JsonObject>(script.substringAfterLast("="))["im"].asJsonArray.mapIndexed { i, json ->
|
||||
Page(i, "", "https:" + json["u"].string)
|
||||
}
|
||||
}
|
||||
}
|
||||
class Mangapanda : MRP("Mangapanda", "https://www.mangapanda.com")
|
||||
|
|
Loading…
Reference in New Issue