[Kemono] Update API path (#18638)

* [Kemono] Update API path

Now uses /api/v1 instead of just /api

* Update Kemono.kt

* Bump KemonoGenerator baseversion

* Update date format

* Update pageListParse
This commit is contained in:
spicemace 2023-10-21 07:37:58 -07:00 committed by GitHub
parent 36ed3acc2f
commit 4cd74249b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

View File

@ -51,6 +51,8 @@ open class Kemono(
override val baseUrl = preferences.getString(BASE_URL_PREF, defaultUrl)!!
private val apiPath = "api/v1"
private val imgCdnUrl = when (name) {
"Kemono" -> baseUrl
else -> defaultUrl
@ -122,7 +124,7 @@ open class Kemono(
block: (ArrayList<KemonoCreatorDto>) -> List<KemonoCreatorDto>,
): MangasPage {
val imgCdnUrl = this.imgCdnUrl
val response = client.newCall(GET("$baseUrl/api/creators", headers)).execute()
val response = client.newCall(GET("$baseUrl/$apiPath/creators", headers)).execute()
val allCreators = block(response.parseAs())
val count = allCreators.size
val fromIndex = (page - 1) * NEW_PAGE_SIZE
@ -143,7 +145,7 @@ open class Kemono(
override fun onFailure(call: Call, e: IOException) = Unit
}
client.newCall(GET("$baseUrl/api/creators", headers)).enqueue(callback)
client.newCall(GET("$baseUrl/$apiPath/creators", headers)).enqueue(callback)
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = throw UnsupportedOperationException()
@ -167,7 +169,7 @@ open class Kemono(
var hasNextPage = true
val result = ArrayList<SChapter>()
while (offset < maxPosts && hasNextPage) {
val request = GET("$baseUrl/api${manga.url}?limit=$POST_PAGE_SIZE&o=$offset", headers)
val request = GET("$baseUrl/$apiPath${manga.url}?limit=$POST_PAGE_SIZE&o=$offset", headers)
val page: List<KemonoPostDto> = client.newCall(request).execute().parseAs()
page.forEach { post -> if (post.images.isNotEmpty()) result.add(post.toSChapter()) }
offset += POST_PAGE_SIZE
@ -179,11 +181,11 @@ open class Kemono(
override fun chapterListParse(response: Response) = throw UnsupportedOperationException()
override fun pageListRequest(chapter: SChapter): Request =
GET("$baseUrl/api${chapter.url}", headers)
GET("$baseUrl/$apiPath${chapter.url}", headers)
override fun pageListParse(response: Response): List<Page> {
val post: List<KemonoPostDto> = response.parseAs()
return post[0].images.mapIndexed { i, path -> Page(i, imageUrl = baseUrl + path) }
val post: KemonoPostDto = response.parseAs()
return post.images.mapIndexed { i, path -> Page(i, imageUrl = baseUrl + path) }
}
override fun imageRequest(page: Page): Request {

View File

@ -97,7 +97,7 @@ class KemonoAttachmentDto(val name: String, val path: String) {
}
private fun getApiDateFormat() =
SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH)
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
private fun getChapterNameDateFormat() =
SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss", Locale.ENGLISH)

View File

@ -9,7 +9,7 @@ class KemonoGenerator : ThemeSourceGenerator {
override val themePkg = "kemono"
override val baseVersionCode = 7
override val baseVersionCode = 8
override val sources = listOf(
SingleLang("Kemono", "https://kemono.party", "all", isNsfw = true),