parent
f1a59ba618
commit
6770a0672a
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Yugen Mangás'
|
extName = 'Yugen Mangás'
|
||||||
extClass = '.YugenMangas'
|
extClass = '.YugenMangas'
|
||||||
extVersionCode = 38
|
extVersionCode = 39
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
@ -53,13 +54,12 @@ class YugenMangas : HttpSource() {
|
||||||
.add("Sec-Fetch-Site", "same-site")
|
.add("Sec-Fetch-Site", "same-site")
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
return GET("$API_BASE_URL/random_top_series/", apiHeaders)
|
return GET("$API_BASE_URL/top_series_all/", apiHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaParse(response: Response): MangasPage {
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
val result = response.parseAs<List<YugenMangaDto>>()
|
val result = response.parseAs<List<YugenMangaDto>>()
|
||||||
val mangaList = result.map { it.toSManga(baseUrl) }
|
val mangaList = result.map { it.toSManga(API_HOST) }
|
||||||
|
|
||||||
return MangasPage(mangaList, hasNextPage = false)
|
return MangasPage(mangaList, hasNextPage = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ class YugenMangas : HttpSource() {
|
||||||
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
|
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val apiUrl = "$API_BASE_URL/series/list".toHttpUrl().newBuilder()
|
val apiUrl = "$API_BASE_URL/series".toHttpUrl().newBuilder()
|
||||||
.addQueryParameter("query", query)
|
.addQueryParameter("search", query)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return GET(apiUrl, apiHeaders)
|
return GET(apiUrl, apiHeaders)
|
||||||
|
@ -81,14 +81,13 @@ class YugenMangas : HttpSource() {
|
||||||
|
|
||||||
override fun mangaDetailsRequest(manga: SManga): Request {
|
override fun mangaDetailsRequest(manga: SManga): Request {
|
||||||
val slug = manga.url.removePrefix("/series/")
|
val slug = manga.url.removePrefix("/series/")
|
||||||
|
return POST("$API_BASE_URL/serie/serie_details/$slug", apiHeaders)
|
||||||
return POST("$API_BASE_URL/serie_details/$slug", apiHeaders)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMangaUrl(manga: SManga) = baseUrl + manga.url
|
override fun getMangaUrl(manga: SManga) = baseUrl + manga.url
|
||||||
|
|
||||||
override fun mangaDetailsParse(response: Response): SManga {
|
override fun mangaDetailsParse(response: Response): SManga {
|
||||||
return response.parseAs<YugenMangaDto>().toSManga(baseUrl)
|
return response.parseAs<YugenMangaDto>().toSManga(API_BASE_URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListRequest(manga: SManga): Request {
|
override fun chapterListRequest(manga: SManga): Request {
|
||||||
|
@ -101,7 +100,7 @@ class YugenMangas : HttpSource() {
|
||||||
.set("Content-Type", payload.contentType().toString())
|
.set("Content-Type", payload.contentType().toString())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return POST("$API_BASE_URL/get_chapters_by_serie/", newHeaders, payload)
|
return POST("$API_BASE_URL/chapters/get_chapters_by_serie/", newHeaders, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
|
@ -114,23 +113,13 @@ class YugenMangas : HttpSource() {
|
||||||
|
|
||||||
override fun getChapterUrl(chapter: SChapter) = baseUrl + chapter.url
|
override fun getChapterUrl(chapter: SChapter) = baseUrl + chapter.url
|
||||||
|
|
||||||
override fun pageListRequest(chapter: SChapter): Request {
|
|
||||||
val paths = chapter.url.removePrefix("/").split("/")
|
|
||||||
|
|
||||||
val newHeaders = apiHeadersBuilder()
|
|
||||||
.set("Referer", getChapterUrl(chapter))
|
|
||||||
.build()
|
|
||||||
|
|
||||||
return POST("$API_BASE_URL/serie/${paths[1]}/chapter/${paths[2]}/images/imgs/", newHeaders)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val result = response.parseAs<YugenReaderDto>()
|
val json = response.asJsoup().selectFirst("script#__NUXT_DATA__")!!.data()
|
||||||
val chapterUrl = response.request.headers["Referer"].orEmpty()
|
return CHAPTER_PAGES_REGEX.findAll(json)
|
||||||
|
.mapIndexed { index, image ->
|
||||||
return result.images.orEmpty().mapIndexed { index, image ->
|
Page(index, baseUrl, "$API_HOST/${image.value}")
|
||||||
Page(index, chapterUrl, "$baseUrl/${image.removePrefix("/")}")
|
|
||||||
}
|
}
|
||||||
|
.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(response: Response) = ""
|
override fun imageUrlParse(response: Response) = ""
|
||||||
|
@ -153,7 +142,9 @@ class YugenMangas : HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val API_BASE_URL = "https://api.yugenmangas.net.br/api"
|
private const val API_HOST = "https://api.yugenmangas.net.br"
|
||||||
|
private const val API_BASE_URL = "$API_HOST/api"
|
||||||
|
private val CHAPTER_PAGES_REGEX = """(media/series[^"]+)""".toRegex()
|
||||||
private val JSON_MEDIA_TYPE = "application/json".toMediaType()
|
private val JSON_MEDIA_TYPE = "application/json".toMediaType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,15 @@ data class YugenMangaDto(
|
||||||
"completed", "finished" -> SManga.COMPLETED
|
"completed", "finished" -> SManga.COMPLETED
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
thumbnail_url = if (cover.startsWith("/")) baseUrl + cover else cover
|
|
||||||
|
thumbnail_url = when {
|
||||||
|
cover.startsWith(listOf("/", "cover")) -> "$baseUrl/media/${cover.removePrefix("/")}"
|
||||||
|
else -> cover
|
||||||
|
}
|
||||||
url = "/series/$slug"
|
url = "/series/$slug"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.startsWith(group: List<String>): Boolean = group.any(::startsWith)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -66,11 +72,6 @@ data class YugenChapterDto(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class YugenReaderDto(
|
|
||||||
@SerialName("chapter_images") val images: List<String>? = emptyList(),
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class YugenGetChaptersBySeriesDto(
|
data class YugenGetChaptersBySeriesDto(
|
||||||
@SerialName("serie_slug") val seriesSlug: String,
|
@SerialName("serie_slug") val seriesSlug: String,
|
||||||
|
|
Loading…
Reference in New Issue