Mangareader (add Mangapanda) (#1459)

This commit is contained in:
Mike 2019-09-06 23:12:15 -04:00 committed by Eugene
parent dd9b8bc6a8
commit ed870c659f
3 changed files with 42 additions and 30 deletions

View File

@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
ext { ext {
appName = 'Tachiyomi: Mangareader' appName = 'Tachiyomi: Mangareader & Mangapanda'
pkgNameSuffix = 'en.mangareader' pkgNameSuffix = 'en.mangareader'
extClass = '.Mangareader' extClass = '.MRPFactory'
extVersionCode = 3 extVersionCode = 4
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -0,0 +1,13 @@
package eu.kanade.tachiyomi.extension.en.mangareader
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
class MRPFactory : SourceFactory {
override fun createSources(): List<Source> = listOf(
Mangareader(),
Mangapanda())
}
class Mangareader : MRP("Mangareader", "https://www.mangareader.net")
class Mangapanda : MRP("Mangapanda", "https://www.mangapanda.com")

View File

@ -12,12 +12,10 @@ import okhttp3.Response
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
abstract class MRP(
class Mangareader : ParsedHttpSource() { override val name: String,
override val baseUrl: String
override val name = "Mangareader" ) : ParsedHttpSource() {
override val baseUrl = "http://mangareader.net"
override val lang = "en" override val lang = "en"
@ -28,16 +26,18 @@ class Mangareader : ParsedHttpSource() {
override fun popularMangaSelector() = "div.mangaresultitem" override fun popularMangaSelector() = "div.mangaresultitem"
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request {
if (page == 1) { return if (page == 1) {
return GET("$baseUrl/popular/") GET("$baseUrl/popular/")
} else { } else {
return GET("$baseUrl/popular/$nextPageNumber") GET("$baseUrl/popular/$nextPageNumber")
} }
} }
// Site's page numbering is weird, have to do some work to get the right page number for additional requests // Site's page numbering is weird, have to do some work to get the right page number for additional requests
private var nextPageNumber = "" private lateinit var nextPageNumber: String
val nextPageSelector = "div#sp a:contains(>)"
private val nextPageSelector = "div#sp a:contains(>)"
override fun popularMangaParse(response: Response): MangasPage { override fun popularMangaParse(response: Response): MangasPage {
val document = response.asJsoup() val document = response.asJsoup()
@ -65,10 +65,10 @@ class Mangareader : ParsedHttpSource() {
override fun latestUpdatesSelector() = "tr.c3" override fun latestUpdatesSelector() = "tr.c3"
override fun latestUpdatesRequest(page: Int): Request { override fun latestUpdatesRequest(page: Int): Request {
if (page == 1) { return if (page == 1) {
return GET("$baseUrl/latest/") GET("$baseUrl/latest/")
} else { } else {
return GET("$baseUrl/latest/$nextPageNumber") GET("$baseUrl/latest/$nextPageNumber")
} }
} }
@ -96,10 +96,10 @@ class Mangareader : ParsedHttpSource() {
override fun latestUpdatesNextPageSelector() = "Not using this" override fun latestUpdatesNextPageSelector() = "Not using this"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
if (page==1) { return if (page==1) {
return GET("$baseUrl/search/?w=$query&p", headers) GET("$baseUrl/search/?w=$query&p", headers)
} else { } else {
return GET("$baseUrl/search/?w=$query&p=$nextPageNumber", headers) GET("$baseUrl/search/?w=$query&p=$nextPageNumber", headers)
} }
} }
@ -138,13 +138,15 @@ class Mangareader : ParsedHttpSource() {
return super.chapterListParse(response).reversed() return super.chapterListParse(response).reversed()
} }
override fun chapterListSelector() = "div#chapterlist tr:gt(0)" override fun chapterListSelector() = "table#listing tr:not(.table_head)"
override fun chapterFromElement(element: Element): SChapter { override fun chapterFromElement(element: Element): SChapter {
val chapter = SChapter.create() val chapter = SChapter.create()
chapter.url = element.select("a").attr("href") element.select("a").let {
chapter.name = element.select("td:has(a)").text() chapter.setUrlWithoutDomain(it.attr("href"))
chapter.date_upload = parseDate(element.select("td:has(a) + td").text()) chapter.name = it.text()
}
chapter.date_upload = parseDate(element.select("td + td").text())
return chapter return chapter
} }
@ -163,16 +165,13 @@ class Mangareader : ParsedHttpSource() {
} }
// Get the page // Get the page
override fun imageUrlRequest(page: Page) = GET("$baseUrl" + page.url) override fun imageUrlRequest(page: Page) = GET(baseUrl + page.url)
// Get the image from the requested page // Get the image from the requested page
override fun imageUrlParse (response: Response): String { override fun imageUrlParse(document: Document): String {
val document = response.asJsoup()
return document.select("a img").attr("src") return document.select("a img").attr("src")
} }
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
override fun getFilterList() = FilterList() override fun getFilterList() = FilterList()
} }