fix Hitomi method conflict with ext-lib 1.5 methods (#806)

* maybe fix private fun conflict with ext-lib 1.5 interface methods

* add pages in description

* slight refactor

* bump

* make search default order same as site

some entries don't show up on popular sort
This commit is contained in:
AwkwardPeak7 2024-01-30 18:45:33 +05:00 committed by Draff
parent 46c51293c7
commit 9f21ec0d06
2 changed files with 39 additions and 48 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Hitomi' extName = 'Hitomi'
extClass = '.HitomiFactory' extClass = '.HitomiFactory'
extVersionCode = 25 extVersionCode = 26
isNsfw = true isNsfw = true
} }

View File

@ -56,50 +56,44 @@ class Hitomi(
.set("origin", baseUrl) .set("origin", baseUrl)
override fun fetchPopularManga(page: Int): Observable<MangasPage> = Observable.fromCallable { override fun fetchPopularManga(page: Int): Observable<MangasPage> = Observable.fromCallable {
runBlocking { getPopularManga(page) } runBlocking {
} val entries = getGalleryIDsFromNozomi("popular", "today", nozomiLang, page.nextPageRange())
.toMangaList()
private suspend fun getPopularManga(page: Int): MangasPage { MangasPage(entries, entries.size >= 24)
val entries = getGalleryIDsFromNozomi("popular", "today", nozomiLang, page.nextPageRange()) }
.toMangaList()
return MangasPage(entries, entries.size >= 24)
} }
override fun fetchLatestUpdates(page: Int): Observable<MangasPage> = Observable.fromCallable { override fun fetchLatestUpdates(page: Int): Observable<MangasPage> = Observable.fromCallable {
runBlocking { getLatestUpdates(page) } runBlocking {
} val entries = getGalleryIDsFromNozomi(null, "index", nozomiLang, page.nextPageRange())
.toMangaList()
private suspend fun getLatestUpdates(page: Int): MangasPage { MangasPage(entries, entries.size >= 24)
val entries = getGalleryIDsFromNozomi(null, "index", nozomiLang, page.nextPageRange()) }
.toMangaList()
return MangasPage(entries, entries.size >= 24)
} }
private lateinit var searchResponse: List<Int> private lateinit var searchResponse: List<Int>
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = Observable.fromCallable { override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = Observable.fromCallable {
runBlocking { getSearchManga(page, query, filters) } runBlocking {
} if (page == 1) {
searchResponse = hitomiSearch(
query.trim(),
filters.filterIsInstance<SortFilter>().firstOrNull()?.state == 1,
nozomiLang,
).toList()
}
private suspend fun getSearchManga(page: Int, query: String, filters: FilterList): MangasPage { val end = min(page * 25, searchResponse.size)
if (page == 1) { val entries = searchResponse.subList((page - 1) * 25, end)
searchResponse = hitomiSearch( .toMangaList()
query.trim(),
filters.filterIsInstance<SortFilter>().firstOrNull()?.state == 0, MangasPage(entries, end != searchResponse.size)
nozomiLang,
).toList()
} }
val end = min(page * 25, searchResponse.size)
val entries = searchResponse.subList((page - 1) * 25, end)
.toMangaList()
return MangasPage(entries, end != searchResponse.size)
} }
private class SortFilter : Filter.Select<String>("Sort By", arrayOf("Popularity", "Updated")) private class SortFilter : Filter.Select<String>("Sort By", arrayOf("Updated", "Popularity"))
override fun getFilterList(): FilterList { override fun getFilterList(): FilterList {
return FilterList(SortFilter()) return FilterList(SortFilter())
@ -450,6 +444,7 @@ class Hitomi(
parodys?.joinToString { it.formatted }?.let { parodys?.joinToString { it.formatted }?.let {
append("Parodies: ", it, "\n") append("Parodies: ", it, "\n")
} }
append("Pages: ", files.size)
} }
status = SManga.COMPLETED status = SManga.COMPLETED
update_strategy = UpdateStrategy.ONLY_FETCH_ONCE update_strategy = UpdateStrategy.ONLY_FETCH_ONCE
@ -464,10 +459,8 @@ class Hitomi(
return GET("$ltnUrl/galleries/$id.js", headers) return GET("$ltnUrl/galleries/$id.js", headers)
} }
override fun mangaDetailsParse(response: Response): SManga { override fun mangaDetailsParse(response: Response) = runBlocking {
return response.parseScriptAs<Gallery>().let { response.parseScriptAs<Gallery>().toSManga()
runBlocking { it.toSManga() }
}
} }
override fun getMangaUrl(manga: SManga) = baseUrl + manga.url override fun getMangaUrl(manga: SManga) = baseUrl + manga.url
@ -508,22 +501,20 @@ class Hitomi(
return GET("$ltnUrl/galleries/$id.js", headers) return GET("$ltnUrl/galleries/$id.js", headers)
} }
override fun pageListParse(response: Response): List<Page> { override fun pageListParse(response: Response) = runBlocking {
val gallery = response.parseScriptAs<Gallery>() val gallery = response.parseScriptAs<Gallery>()
return gallery.files.mapIndexed { idx, img -> gallery.files.mapIndexed { idx, img ->
runBlocking { val hash = img.hash
val hash = img.hash val commonId = commonImageId()
val commonId = commonImageId() val imageId = imageIdFromHash(hash)
val imageId = imageIdFromHash(hash) val subDomain = 'a' + subdomainOffset(imageId)
val subDomain = 'a' + subdomainOffset(imageId)
Page( Page(
idx, idx,
"$baseUrl/reader/$id.html", "$baseUrl/reader/$id.html",
"https://${subDomain}a.$domain/webp/$commonId$imageId/$hash.webp", "https://${subDomain}a.$domain/webp/$commonId$imageId/$hash.webp",
) )
}
} }
} }