Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib-multisrc/gattsu/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ plugins {
}

keiyoushi {
baseVersionCode = 6
libVersion = "1.4"
baseVersionCode = 0
libVersion = "1.6"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,38 @@

package eu.kanade.tachiyomi.multisrc.gattsu

import eu.kanade.tachiyomi.network.GET
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.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.source.model.SMangaUpdate
import keiyoushi.network.get
import keiyoushi.source.KeiSource
import keiyoushi.utils.asJsoup
import keiyoushi.utils.tryParse
import keiyoushi.utils.tryParseDate
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.time.format.DateTimeFormatter
import java.util.Locale

abstract class Gattsu : HttpSource() {
abstract class Gattsu : KeiSource() {

override val supportsLatest = true
override fun Headers.Builder.configureHeaders(): Headers.Builder = set("Accept", ACCEPT)
.set("Accept-Language", ACCEPT_LANGUAGE)

override fun headersBuilder() = Headers.Builder()
.add("Accept", ACCEPT)
.add("Accept-Language", ACCEPT_LANGUAGE)
.add("Referer", baseUrl)
// Website does not have a popular, so the latest listing is used instead.
override val supportsLatest = false

// Website does not have a popular, so use latest instead.
override fun popularMangaRequest(page: Int): Request = latestUpdatesRequest(page)
override suspend fun getLatestUpdates(page: Int): MangasPage = throw UnsupportedOperationException()

override fun popularMangaParse(response: Response): MangasPage = latestUpdatesParse(response)

override fun latestUpdatesRequest(page: Int): Request {
override suspend fun getPopularManga(page: Int): MangasPage {
val path = if (page == 1) "" else "page/$page"
return GET("$baseUrl/$path", headers)
}

override fun latestUpdatesParse(response: Response): MangasPage {
val document = response.asJsoup()
val document = client.get("$baseUrl/$path").asJsoup()
val mangas = document.select(latestUpdatesSelector()).map { element ->
latestUpdatesFromElement(element)
}
Expand All @@ -60,17 +54,13 @@ abstract class Gattsu : HttpSource() {

open fun latestUpdatesNextPageSelector(): String? = "ul.paginacao li.next > a"

override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
override suspend fun getSearchMangaList(page: Int, query: String, filters: FilterList): MangasPage {
val searchUrl = "$baseUrl/page/$page/".toHttpUrl().newBuilder()
.addQueryParameter("s", query)
.addQueryParameter("post_type", "post")
.toString()

return GET(searchUrl, headers)
}
.build()

override fun searchMangaParse(response: Response): MangasPage {
val document = response.asJsoup()
val document = client.get(searchUrl).asJsoup()
val mangas = document.select(searchMangaSelector()).map { element ->
searchMangaFromElement(element)
}
Expand All @@ -87,8 +77,24 @@ abstract class Gattsu : HttpSource() {

open fun searchMangaNextPageSelector(): String? = latestUpdatesNextPageSelector()

override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply {
val document = response.asJsoup()
override suspend fun getMangaByUrl(url: HttpUrl): SManga? {
if (url.host != baseUrl.toHttpUrl().host || url.pathSegments.all(String::isEmpty)) return null

return mangaDetailsParse(client.get(url).asJsoup()).apply { setUrlWithoutDomain(url.toString()) }
}

// Details and chapters come from the same page
override suspend fun fetchMangaUpdate(
manga: SManga,
chapters: List<SChapter>,
fetchDetails: Boolean,
fetchChapters: Boolean,
): SMangaUpdate {
val document = client.get(getMangaUrl(manga)).asJsoup()
return SMangaUpdate(mangaDetailsParse(document), chapterListParse(document))
}

open fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
val postBox = document.select("div.meio div.post-box").first()!!

title = postBox.select("h1.post-titulo").first()!!.text()
Expand All @@ -105,9 +111,7 @@ abstract class Gattsu : HttpSource() {
.withoutSize()
}

override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup()

open fun chapterListParse(document: Document): List<SChapter> {
if (document.selectFirst(pageListSelector()) == null) {
return emptyList()
}
Expand All @@ -116,7 +120,7 @@ abstract class Gattsu : HttpSource() {
.map { chapterFromElement(it) }
}

open fun chapterListSelector() = "div.meio div.post-box:first-of-type"
open fun chapterListSelector() = "div.meio div.post-box:has(h1.post-titulo)"

open fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
name = "Capítulo único"
Expand All @@ -131,32 +135,26 @@ abstract class Gattsu : HttpSource() {
protected open fun pageListSelector(): String = "div.meio div.post-box ul.post-fotos li a > img, " +
"div.meio div.post-box.listaImagens div.galeriaHtml img"

override fun pageListParse(response: Response): List<Page> {
val document = response.asJsoup()
override suspend fun getPageList(chapter: SChapter): List<Page> {
val document = client.get(getChapterUrl(chapter)).asJsoup()
return document.select(pageListSelector())
.mapIndexed { i, el ->
Page(i, document.location(), imageUrl = el.imgAttr().withoutSize())
}
}

override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException()

override fun imageRequest(page: Page): Request {
val imageHeaders = headersBuilder()
.add("Accept", ACCEPT_IMAGE)
.add("Referer", page.url)
.build()

return GET(page.imageUrl!!, imageHeaders)
}
override fun imageRequest(page: Page): Request = super.imageRequest(page).newBuilder()
.header("Accept", ACCEPT_IMAGE)
.header("Referer", page.url)
.build()

protected fun Element.imgAttr(): String = if (hasAttr("data-src")) {
attr("abs:data-src")
} else {
attr("abs:src")
}

protected fun String.toDate(): Long = DATE_FORMATTER.tryParse(this.substringBefore("T"))
protected fun String.toDate(): Long = DATE_FORMATTER.tryParseDate(this.substringBefore("T"))

protected fun String.withoutSize(): String = this.replace(THUMB_SIZE_REGEX, ".")

Expand All @@ -168,8 +166,6 @@ abstract class Gattsu : HttpSource() {

private val THUMB_SIZE_REGEX = "-\\d+x\\d+\\.".toRegex()

private val DATE_FORMATTER by lazy {
SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH)
}
private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.ENGLISH)
}
}
4 changes: 2 additions & 2 deletions src/pt/hentaiseason/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ plugins {

keiyoushi {
name = "Hentai Season"
versionCode = 1
versionCode = 0
contentWarning = ContentWarning.NSFW
libVersion = "1.4"
libVersion = "1.6"
theme = "gattsu"

source {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ import kotlin.time.Duration.Companion.seconds
@Source
abstract class HentaiSeason : Gattsu() {

override val client: OkHttpClient = super.client.newBuilder()
.rateLimit(1, 2.seconds)
.build()
override fun OkHttpClient.Builder.configureClient(): OkHttpClient.Builder = rateLimit(1, 2.seconds)
}
4 changes: 2 additions & 2 deletions src/pt/hentaitokyo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ plugins {

keiyoushi {
name = "Hentai Tokyo"
versionCode = 1
versionCode = 0
contentWarning = ContentWarning.NSFW
libVersion = "1.4"
libVersion = "1.6"
theme = "gattsu"

source {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ import kotlin.time.Duration.Companion.seconds
@Source
abstract class HentaiTokyo : Gattsu() {

override val client: OkHttpClient = super.client.newBuilder()
.rateLimit(1, 2.seconds)
.build()
override fun OkHttpClient.Builder.configureClient(): OkHttpClient.Builder = rateLimit(1, 2.seconds)
}
4 changes: 2 additions & 2 deletions src/pt/universohentai/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ plugins {

keiyoushi {
name = "Universo Hentai"
versionCode = 1
versionCode = 0
contentWarning = ContentWarning.NSFW
libVersion = "1.4"
libVersion = "1.6"
theme = "gattsu"

source {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import keiyoushi.annotation.Source
import keiyoushi.network.rateLimit
import keiyoushi.utils.asJsoup
import okhttp3.OkHttpClient
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import kotlin.time.Duration.Companion.seconds

@Source
abstract class UniversoHentai : Gattsu() {

override val client: OkHttpClient = super.client.newBuilder()
.rateLimit(1, 2.seconds)
.build()
override fun OkHttpClient.Builder.configureClient(): OkHttpClient.Builder = rateLimit(1, 2.seconds)

override fun latestUpdatesSelector() = "div.meio div.videos div.video a[href^=$baseUrl]:not(:has(span.selo-hd))"

Expand All @@ -26,8 +23,7 @@ abstract class UniversoHentai : Gattsu() {
setUrlWithoutDomain(element.attr("href"))
}

override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply {
val document = response.asJsoup()
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
val postBox = document.selectFirst(chapterListSelector())!!

title = postBox.select("h1.post-titulo").first()!!.text()
Expand All @@ -40,12 +36,8 @@ abstract class UniversoHentai : Gattsu() {
.withoutSize()
}

override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup()

return document.select(chapterListSelector())
.map { chapterFromElement(it) }
}
override fun chapterListParse(document: Document): List<SChapter> = document.select(chapterListSelector())
.map { chapterFromElement(it) }

override fun chapterListSelector() = "div.meio div.post[itemscope]:has(a[title=Abrir galeria])"

Expand Down
Loading