add mangawindow.club and manganelos.com to Paprika (#3417)
* add mangawindow.club and manganelos.com to Paprika * update extVersionCode * DRY the code * throw exceprion for unreachable code * Paparika: comment out logs, remove redundancy * Paprika: remove unused import
This commit is contained in:
parent
2d5e12b768
commit
6df012ed41
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: Paprika'
|
||||
pkgNameSuffix = 'all.paprika'
|
||||
extClass = '.PaprikaFactory'
|
||||
extVersionCode = 1
|
||||
extVersionCode = 2
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.source.online.ParsedHttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
@ -104,7 +105,7 @@ abstract class Paprika(
|
|||
}
|
||||
}
|
||||
|
||||
private fun String?.toStatus() = when {
|
||||
fun String?.toStatus() = when {
|
||||
this == null -> SManga.UNKNOWN
|
||||
this.contains("Ongoing", ignoreCase = true) -> SManga.ONGOING
|
||||
this.contains("Completed", ignoreCase = true) -> SManga.COMPLETED
|
||||
|
@ -119,15 +120,22 @@ abstract class Paprika(
|
|||
*/
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
return super.chapterListParse(response).distinctBy { it.url }
|
||||
val document = response.asJsoup()
|
||||
val mangaTitle = document.select("div.manga-detail h1").text()
|
||||
return document.select(chapterListSelector()).map { chapterFromElement(it, mangaTitle) }.distinctBy { it.url }
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = "div.total-chapter:has(h2) li"
|
||||
|
||||
// never called
|
||||
override fun chapterFromElement(element: Element): SChapter {
|
||||
throw Exception("unreachable code was reached!")
|
||||
}
|
||||
|
||||
open fun chapterFromElement(element: Element, mangaTitle: String): SChapter {
|
||||
return SChapter.create().apply {
|
||||
element.select("a").let {
|
||||
name = it.text()
|
||||
name = it.text().substringAfter("$mangaTitle ")
|
||||
setUrlWithoutDomain(it.attr("href"))
|
||||
}
|
||||
date_upload = element.select("div.small").firstOrNull()?.text().toDate()
|
||||
|
@ -136,7 +144,7 @@ abstract class Paprika(
|
|||
|
||||
private val currentYear by lazy { Calendar.getInstance(Locale.US)[1].toString().takeLast(2) }
|
||||
|
||||
private fun String?.toDate(): Long {
|
||||
fun String?.toDate(): Long {
|
||||
this ?: return 0L
|
||||
return try {
|
||||
when {
|
||||
|
@ -181,7 +189,7 @@ abstract class Paprika(
|
|||
GenreFilter(getGenreList())
|
||||
)
|
||||
|
||||
private class OrderFilter(vals: Array<Pair<String, String>>) : UriPartFilter("Category", vals)
|
||||
class OrderFilter(vals: Array<Pair<String, String>>) : UriPartFilter("Category", vals)
|
||||
|
||||
private fun getOrderList() = arrayOf(
|
||||
Pair("Views", "2"),
|
||||
|
@ -189,7 +197,7 @@ abstract class Paprika(
|
|||
Pair("A-Z", "1")
|
||||
)
|
||||
|
||||
private class GenreFilter(vals: Array<Pair<String, String>>) : UriPartFilter("Category", vals)
|
||||
class GenreFilter(vals: Array<Pair<String, String>>) : UriPartFilter("Category", vals)
|
||||
|
||||
private fun getGenreList() = arrayOf(
|
||||
Pair("4 koma", "4-koma"),
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
package eu.kanade.tachiyomi.extension.all.paprika
|
||||
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
|
||||
abstract class PaprikaAlt(
|
||||
override val name: String,
|
||||
override val baseUrl: String,
|
||||
override val lang: String
|
||||
) : Paprika(name, baseUrl, lang) {
|
||||
override fun popularMangaSelector() = "div.anipost"
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga {
|
||||
//Log.d("Paprika", "processing popular element")
|
||||
return SManga.create().apply {
|
||||
element.select("a:has(h2)").let {
|
||||
setUrlWithoutDomain(it.attr("href"))
|
||||
title = it.text()
|
||||
//Log.d("Paprika", "manga url: $url")
|
||||
//Log.d("Paprika", "manga title: $title")
|
||||
}
|
||||
thumbnail_url = element.select("img").attr("abs:src")
|
||||
//Log.d("Paprika", "manga thumb: $thumbnail_url")
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
return if (query.isNotBlank()) {
|
||||
GET("$baseUrl/search?s=$query&post_type=manga&page=$page")
|
||||
} else {
|
||||
val url = HttpUrl.parse("$baseUrl/genres/")!!.newBuilder()
|
||||
filters.forEach { filter ->
|
||||
when (filter) {
|
||||
is GenreFilter -> url.addPathSegment(filter.toUriPart())
|
||||
is OrderFilter -> url.addQueryParameter("orderby", filter.toUriPart())
|
||||
}
|
||||
}
|
||||
url.addQueryParameter("page", page.toString())
|
||||
GET(url.toString(), headers)
|
||||
}
|
||||
}
|
||||
|
||||
override fun mangaDetailsParse(document: Document): SManga {
|
||||
return SManga.create().apply {
|
||||
title = document.select(".animeinfo .rm h1")[0].text()
|
||||
thumbnail_url = document.select(".animeinfo .lm img").attr("abs:src")
|
||||
document.select(".listinfo li").forEach {
|
||||
it.text().apply {
|
||||
when {
|
||||
this.startsWith("Author") -> author = this.substringAfter(":").trim()
|
||||
this.startsWith("Artist") -> artist = this.substringAfter(":").trim()
|
||||
this.startsWith("Genre") -> genre = this.substringAfter(":").trim().replace(";", ",")
|
||||
this.startsWith("Status") -> status = this.substringAfter(":").trim().toStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
description = document.select("#noidungm").joinToString("\n") { it.text() }
|
||||
|
||||
//Log.d("Paprika", "mangaDetials")
|
||||
}
|
||||
}
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val document = response.asJsoup()
|
||||
val mangaTitle = document.select(".animeinfo .rm h1")[0].text()
|
||||
return document.select(chapterListSelector()).map { chapterFromElement(it, mangaTitle) }.distinctBy { it.url }
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = ".animeinfo .rm .cl li"
|
||||
|
||||
// changing the signature to pass the manga title in order to trim the title from chapter titles
|
||||
override fun chapterFromElement(element: Element, mangaTitle: String): SChapter {
|
||||
return SChapter.create().apply {
|
||||
element.select(".leftoff").let {
|
||||
name = it.text().substringAfter("$mangaTitle ")
|
||||
setUrlWithoutDomain(it.select("a").attr("href"))
|
||||
}
|
||||
date_upload = element.select(".rightoff").firstOrNull()?.text().toDate()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,9 +6,13 @@ import eu.kanade.tachiyomi.source.SourceFactory
|
|||
class PaprikaFactory : SourceFactory {
|
||||
override fun createSources(): List<Source> = listOf(
|
||||
MangazukiXyz(),
|
||||
MangaTensei()
|
||||
MangaTensei(),
|
||||
MangaNelo(),
|
||||
MangaWindowClub()
|
||||
)
|
||||
}
|
||||
|
||||
class MangazukiXyz : Paprika("MangaZuki.xyz", "https://ir2me.com", "en")
|
||||
class MangaTensei : Paprika("MangaTensei", "https://www.mangatensei.com", "en")
|
||||
class MangaNelo : Paprika("MangaNelo", "http://manganelos.com", "en")
|
||||
class MangaWindowClub : PaprikaAlt("MangaWindow.club", "https://mangawindow.club", "en")
|
||||
|
|
Loading…
Reference in New Issue