parent
a7cfba60a2
commit
22f0293165
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Webcomics'
|
extName = 'Webcomics'
|
||||||
extClass = '.Webcomics'
|
extClass = '.Webcomics'
|
||||||
extVersionCode = 6
|
extVersionCode = 7
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|||||||
@ -11,21 +11,21 @@ import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
|||||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import keiyoushi.utils.getPreferences
|
import keiyoushi.utils.getPreferences
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
|
||||||
import org.jsoup.nodes.Element
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class Webcomics : ParsedHttpSource(), ConfigurableSource {
|
class Webcomics : HttpSource(), ConfigurableSource {
|
||||||
|
|
||||||
override val name = "Webcomics"
|
override val name = "Webcomics"
|
||||||
|
|
||||||
@ -54,26 +54,33 @@ class Webcomics : ParsedHttpSource(), ConfigurableSource {
|
|||||||
|
|
||||||
// ========================== Popular =====================================
|
// ========================== Popular =====================================
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int) = GET("$baseUrl/genres/All/All/Popularity/$page", headers)
|
override fun popularMangaRequest(page: Int) =
|
||||||
|
GET("$baseUrl/genres/All/All/Popularity/$page", headers)
|
||||||
|
|
||||||
override fun popularMangaSelector() = ".book-list .list-item a"
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
|
||||||
override fun popularMangaNextPageSelector() = ".page-list li:not([style*=none]) a.next"
|
val mangas = document.select("#All a").map { element ->
|
||||||
|
SManga.create().apply {
|
||||||
override fun popularMangaFromElement(element: Element) = SManga.create().apply {
|
title = element.selectFirst("h5")!!.text()
|
||||||
title = element.selectFirst("h2")!!.text()
|
thumbnail_url = element.selectFirst("img[src]")?.absUrl("src")
|
||||||
thumbnail_url = element.selectFirst("img")?.absUrl("src")
|
|
||||||
setUrlWithoutDomain(element.absUrl("href"))
|
setUrlWithoutDomain(element.absUrl("href"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val hasNextPage = document.selectFirst("script:containsData(__NUXT__)")?.data()
|
||||||
|
?.substringAfter("page:")
|
||||||
|
?.substringBefore(",")
|
||||||
|
?.let { it.toIntOrNull() != null } ?: false
|
||||||
|
|
||||||
|
return MangasPage(mangas, hasNextPage)
|
||||||
|
}
|
||||||
|
|
||||||
// ========================== Latest =====================================
|
// ========================== Latest =====================================
|
||||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/genres/All/All/Latest_Updated/$page", headers)
|
override fun latestUpdatesRequest(page: Int) =
|
||||||
|
GET("$baseUrl/genres/All/All/Latest_Updated/$page", headers)
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = popularMangaSelector()
|
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element) = popularMangaFromElement(element)
|
|
||||||
|
|
||||||
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
|
|
||||||
|
|
||||||
// ========================== Search =====================================
|
// ========================== Search =====================================
|
||||||
|
|
||||||
@ -90,22 +97,35 @@ class Webcomics : ParsedHttpSource(), ConfigurableSource {
|
|||||||
val url = "$baseUrl/genres/$genre/All/Popular/$page"
|
val url = "$baseUrl/genres/$genre/All/Popular/$page"
|
||||||
return GET(url, headers)
|
return GET(url, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return popularMangaRequest(page)
|
return popularMangaRequest(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchMangaSelector() = popularMangaSelector()
|
override fun searchMangaParse(response: Response): MangasPage {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
|
||||||
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
val mangas = document.select(".container .van-list div a").map { element ->
|
||||||
|
SManga.create().apply {
|
||||||
|
title = element.selectFirst("h5.info_name")!!.text()
|
||||||
|
thumbnail_url = element.selectFirst("img[src]")?.absUrl("src")
|
||||||
|
setUrlWithoutDomain(element.absUrl("href"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun searchMangaFromElement(element: Element) = popularMangaFromElement(element)
|
return MangasPage(mangas, false)
|
||||||
|
}
|
||||||
|
|
||||||
// ========================== Details ====================================
|
// ========================== Details ====================================
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
|
override fun mangaDetailsParse(response: Response): SManga {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
|
||||||
val infoElement = document.selectFirst(".card-info")!!
|
val infoElement = document.selectFirst(".card-info")!!
|
||||||
|
|
||||||
|
return SManga.create().apply {
|
||||||
title = infoElement.selectFirst("h5")!!.text()
|
title = infoElement.selectFirst("h5")!!.text()
|
||||||
description = infoElement.selectFirst(".book-detail > p")?.text()
|
description = infoElement.selectFirst(".book-detail > p")?.text()
|
||||||
genre = infoElement.select(".label-tag").joinToString { it.text() }
|
genre = infoElement.select(".label-tag").joinToString { it.text() }
|
||||||
@ -114,11 +134,10 @@ class Webcomics : ParsedHttpSource(), ConfigurableSource {
|
|||||||
status = if (it.contains("IDK")) SManga.COMPLETED else SManga.ONGOING
|
status = if (it.contains("IDK")) SManga.COMPLETED else SManga.ONGOING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ========================== Chapter ====================================
|
// ========================== Chapter ====================================
|
||||||
|
|
||||||
override fun chapterListSelector() = throw UnsupportedOperationException()
|
|
||||||
|
|
||||||
override fun chapterListRequest(manga: SManga): Request {
|
override fun chapterListRequest(manga: SManga): Request {
|
||||||
val mangaId = manga.url.substringAfterLast("/")
|
val mangaId = manga.url.substringAfterLast("/")
|
||||||
return GET("$apiUrl/chapter/list?manga_id=$mangaId", headers)
|
return GET("$apiUrl/chapter/list?manga_id=$mangaId", headers)
|
||||||
@ -145,28 +164,21 @@ class Webcomics : ParsedHttpSource(), ConfigurableSource {
|
|||||||
}.sortedBy(SChapter::chapter_number).reversed()
|
}.sortedBy(SChapter::chapter_number).reversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
|
||||||
val urlElement = element.select("a")
|
|
||||||
|
|
||||||
val chapter = SChapter.create()
|
|
||||||
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
|
||||||
chapter.name = urlElement.text().trim()
|
|
||||||
return chapter
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========================== Pages ====================================
|
// ========================== Pages ====================================
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val script = document.select("script")
|
val document = response.asJsoup()
|
||||||
|
|
||||||
|
val script = document.select("script:containsData(__NUXT__)")
|
||||||
.firstOrNull { PAGE_REGEX.containsMatchIn(it.data()) }
|
.firstOrNull { PAGE_REGEX.containsMatchIn(it.data()) }
|
||||||
?: throw Exception("You may need to log in")
|
?: throw Exception("You may need to log in")
|
||||||
|
|
||||||
return PAGE_REGEX.findAll(script.data()).mapIndexed { index, match ->
|
return PAGE_REGEX.findAll(script.data()).mapIndexed { index, match ->
|
||||||
Page(index, imageUrl = match.groups[1]!!.value.unicode())
|
Page(index, imageUrl = match.groups[0]!!.value.unicode())
|
||||||
}.toList()
|
}.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document) = ""
|
override fun imageUrlParse(response: Response) = throw UnsupportedOperationException()
|
||||||
|
|
||||||
// ========================== Filters ==================================
|
// ========================== Filters ==================================
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user