Update manga and API endpoints at Tsuki. (#5053)
This commit is contained in:
parent
b95fb4cb91
commit
a8d25e4ca3
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Tsuki Mangás'
|
extName = 'Tsuki Mangás'
|
||||||
pkgNameSuffix = 'pt.tsukimangas'
|
pkgNameSuffix = 'pt.tsukimangas'
|
||||||
extClass = '.TsukiMangas'
|
extClass = '.TsukiMangas'
|
||||||
extVersionCode = 6
|
extVersionCode = 7
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class TsukiMangas : HttpSource() {
|
||||||
private fun popularMangaItemParse(obj: JsonObject) = SManga.create().apply {
|
private fun popularMangaItemParse(obj: JsonObject) = SManga.create().apply {
|
||||||
title = obj["TITULO"].string
|
title = obj["TITULO"].string
|
||||||
thumbnail_url = baseUrl + "/imgs/" + obj["CAPA"].string.substringBefore("?")
|
thumbnail_url = baseUrl + "/imgs/" + obj["CAPA"].string.substringBefore("?")
|
||||||
url = "/manga/" + obj["URL"].string
|
url = "/obra/${obj["ID"].int}/${obj["URL"].string}"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int): Request {
|
override fun latestUpdatesRequest(page: Int): Request {
|
||||||
|
@ -90,7 +90,7 @@ class TsukiMangas : HttpSource() {
|
||||||
private fun latestMangaItemParse(obj: JsonObject) = SManga.create().apply {
|
private fun latestMangaItemParse(obj: JsonObject) = SManga.create().apply {
|
||||||
title = obj["TITULO"].string
|
title = obj["TITULO"].string
|
||||||
thumbnail_url = baseUrl + "/imgs/" + obj["CAPA"].string
|
thumbnail_url = baseUrl + "/imgs/" + obj["CAPA"].string
|
||||||
url = "/manga/" + obj["URL"].string
|
url = "/obra/${obj["ID"].int}/${obj["URL"].string}"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||||
|
@ -122,6 +122,7 @@ class TsukiMangas : HttpSource() {
|
||||||
.addEncodedPathSegment(genreQuery)
|
.addEncodedPathSegment(genreQuery)
|
||||||
.addPathSegment(page.toString())
|
.addPathSegment(page.toString())
|
||||||
.addEncodedPathSegment(pathQuery)
|
.addEncodedPathSegment(pathQuery)
|
||||||
|
.addPathSegment("all")
|
||||||
.toString()
|
.toString()
|
||||||
|
|
||||||
return GET(url, newHeaders)
|
return GET(url, newHeaders)
|
||||||
|
@ -135,10 +136,7 @@ class TsukiMangas : HttpSource() {
|
||||||
|
|
||||||
val searchMangas = result.map { searchMangaItemParse(it.obj) }
|
val searchMangas = result.map { searchMangaItemParse(it.obj) }
|
||||||
|
|
||||||
val currentPage = response.request().url().toString()
|
val currentPage = response.request().url().pathSegments()[3].toInt()
|
||||||
.substringBeforeLast("/")
|
|
||||||
.substringAfterLast("/")
|
|
||||||
.toInt()
|
|
||||||
val lastPage = result[0].obj["page"].array[0].int
|
val lastPage = result[0].obj["page"].array[0].int
|
||||||
val hasNextPage = currentPage < lastPage
|
val hasNextPage = currentPage < lastPage
|
||||||
|
|
||||||
|
@ -148,7 +146,7 @@ class TsukiMangas : HttpSource() {
|
||||||
private fun searchMangaItemParse(obj: JsonObject) = SManga.create().apply {
|
private fun searchMangaItemParse(obj: JsonObject) = SManga.create().apply {
|
||||||
title = obj["TITULO"].string
|
title = obj["TITULO"].string
|
||||||
thumbnail_url = baseUrl + "/imgs/" + obj["CAPA"].string.substringBefore("?")
|
thumbnail_url = baseUrl + "/imgs/" + obj["CAPA"].string.substringBefore("?")
|
||||||
url = "/manga/" + obj["URL"].string
|
url = "/obra/${obj["ID"].int}/${obj["URL"].string}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround to allow "Open in browser" use the real URL.
|
// Workaround to allow "Open in browser" use the real URL.
|
||||||
|
@ -165,9 +163,9 @@ class TsukiMangas : HttpSource() {
|
||||||
.set("Referer", baseUrl + manga.url)
|
.set("Referer", baseUrl + manga.url)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val mangaSlug = manga.url.substringAfterLast("/")
|
val mangaId = manga.url.substringAfter("obra/").substringBefore("/")
|
||||||
|
|
||||||
return GET("$baseUrl/api/mangas/$mangaSlug", newHeaders)
|
return GET("$baseUrl/api/mangas/$mangaId", newHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsRequest(manga: SManga): Request {
|
override fun mangaDetailsRequest(manga: SManga): Request {
|
||||||
|
@ -185,7 +183,7 @@ class TsukiMangas : HttpSource() {
|
||||||
title = result["TITULO"].string
|
title = result["TITULO"].string
|
||||||
thumbnail_url = baseUrl + "/imgs/" + result["CAPA"].string.substringBefore("?")
|
thumbnail_url = baseUrl + "/imgs/" + result["CAPA"].string.substringBefore("?")
|
||||||
description = result["SINOPSE"].string
|
description = result["SINOPSE"].string
|
||||||
status = SManga.ONGOING
|
status = result["STATUS"].string.toStatus()
|
||||||
author = result["AUTOR"].string
|
author = result["AUTOR"].string
|
||||||
artist = result["ARTISTA"].string
|
artist = result["ARTISTA"].string
|
||||||
genre = result["GENEROS"].string
|
genre = result["GENEROS"].string
|
||||||
|
@ -195,13 +193,13 @@ class TsukiMangas : HttpSource() {
|
||||||
override fun chapterListRequest(manga: SManga): Request = chapterListRequestPaginated(manga.url, 1)
|
override fun chapterListRequest(manga: SManga): Request = chapterListRequestPaginated(manga.url, 1)
|
||||||
|
|
||||||
private fun chapterListRequestPaginated(mangaUrl: String, page: Int): Request {
|
private fun chapterListRequestPaginated(mangaUrl: String, page: Int): Request {
|
||||||
val slug = mangaUrl.substringAfterLast("/")
|
val mangaId = mangaUrl.substringAfter("obra/").substringBefore("/")
|
||||||
|
|
||||||
val newHeaders = headersBuilder()
|
val newHeaders = headersBuilder()
|
||||||
.set("Referer", baseUrl + mangaUrl)
|
.set("Referer", baseUrl + mangaUrl)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return GET("$baseUrl/api/capitulospag/$slug/DESC/$page", newHeaders)
|
return GET("$baseUrl/api/capitulospag/$mangaId/DESC/$page", newHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
|
@ -211,14 +209,13 @@ class TsukiMangas : HttpSource() {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
|
|
||||||
val mangaUrl = response.request().header("Referer")!!.substringAfter(baseUrl)
|
val mangaUrl = response.request().header("Referer")!!.substringAfter(baseUrl)
|
||||||
val mangaSlug = mangaUrl.substringAfterLast("/")
|
|
||||||
var page = 1
|
var page = 1
|
||||||
|
|
||||||
val chapters = mutableListOf<SChapter>()
|
val chapters = mutableListOf<SChapter>()
|
||||||
|
|
||||||
while (result.size() != 0) {
|
while (result.size() != 0) {
|
||||||
chapters += result
|
chapters += result
|
||||||
.map { chapterListItemParse(it.obj, mangaSlug) }
|
.map { chapterListItemParse(it.obj, mangaUrl) }
|
||||||
.toMutableList()
|
.toMutableList()
|
||||||
|
|
||||||
val newRequest = chapterListRequestPaginated(mangaUrl, ++page)
|
val newRequest = chapterListRequestPaginated(mangaUrl, ++page)
|
||||||
|
@ -228,13 +225,16 @@ class TsukiMangas : HttpSource() {
|
||||||
return chapters
|
return chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chapterListItemParse(obj: JsonObject, slug: String): SChapter = SChapter.create().apply {
|
private fun chapterListItemParse(obj: JsonObject, mangaUrl: String): SChapter = SChapter.create().apply {
|
||||||
|
val mangaId = mangaUrl.substringAfter("obra/").substringBefore("/")
|
||||||
|
val mangaSlug = mangaUrl.substringAfterLast("/")
|
||||||
|
|
||||||
name = "Cap. " + obj["NUMERO"].string +
|
name = "Cap. " + obj["NUMERO"].string +
|
||||||
(if (obj["TITULO"].string.isNotEmpty()) " - " + obj["TITULO"].string else "")
|
(if (obj["TITULO"].string.isNotEmpty()) " - " + obj["TITULO"].string else "")
|
||||||
chapter_number = obj["NUMERO"].string.toFloatOrNull() ?: -1f
|
chapter_number = obj["NUMERO"].string.toFloatOrNull() ?: -1f
|
||||||
scanlator = obj["scans"].array.joinToString { it.obj["NOME"].string }
|
scanlator = obj["scans"].array.joinToString { it.obj["NOME"].string }
|
||||||
date_upload = obj["DATA"].string.substringBefore("T").toDate()
|
date_upload = obj["DATA"].string.substringBefore("T").toDate()
|
||||||
url = "/leitor/$slug/" + obj["NUMERO"].string
|
url = "/leitor/$mangaId/${obj["ID"].int}/$mangaSlug/${obj["NUMERO"].string}"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListRequest(chapter: SChapter): Request {
|
override fun pageListRequest(chapter: SChapter): Request {
|
||||||
|
@ -242,7 +242,10 @@ class TsukiMangas : HttpSource() {
|
||||||
.set("Referer", baseUrl + chapter.url)
|
.set("Referer", baseUrl + chapter.url)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return GET("$baseUrl/api" + chapter.url, newHeaders)
|
val mangaId = chapter.url.substringAfter("leitor/").substringBefore("/")
|
||||||
|
val chapterId = chapter.url.substringAfter("$mangaId/").substringBefore("/")
|
||||||
|
|
||||||
|
return GET("$baseUrl/api/leitor/$mangaId/$chapterId", newHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
|
@ -333,6 +336,12 @@ class TsukiMangas : HttpSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.toStatus() = when {
|
||||||
|
contains("Ativo") -> SManga.ONGOING
|
||||||
|
contains("Completo") -> SManga.COMPLETED
|
||||||
|
else -> SManga.UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body()!!.string())
|
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body()!!.string())
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
Loading…
Reference in New Issue