diff --git a/src/all/izneo/build.gradle b/src/all/izneo/build.gradle index d0b655aa3..168d5eef6 100644 --- a/src/all/izneo/build.gradle +++ b/src/all/izneo/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'izneo (webtoons)' pkgNameSuffix = 'all.izneo' extClass = '.IzneoFactory' - extVersionCode = 2 + extVersionCode = 3 } apply from: "$rootDir/common.gradle" diff --git a/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt b/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt index 4b9a8d2e0..93ca1d714 100644 --- a/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt +++ b/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt @@ -21,6 +21,7 @@ import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import okhttp3.Response +import rx.Observable import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.text.SimpleDateFormat @@ -77,9 +78,6 @@ class Izneo(override val lang: String) : ConfigurableSource, HttpSource() { override fun mangaDetailsRequest(manga: SManga) = GET(ORIGIN + manga.url, headers) - override fun chapterListRequest(manga: SManga) = - GET(manga.apiUrl + "/volumes/old/0/500", apiHeaders) - override fun pageListRequest(chapter: SChapter) = GET(ORIGIN + "/book/" + chapter.url, apiHeaders) @@ -138,7 +136,24 @@ class Izneo(override val lang: String) : ConfigurableSource, HttpSource() { }!! override fun fetchMangaDetails(manga: SManga) = - rx.Observable.just(manga.apply { initialized = true })!! + Observable.just(manga.apply { initialized = true })!! + + override fun fetchChapterList(manga: SManga): Observable> { + val url = "$ORIGIN/$lang/api/web/serie/" + + manga.url.substringAfterLast('-') + "/volumes/old" + val chapters = mutableListOf() + var cutoff = 0 + var current = LIMIT + while (current == LIMIT) { + client.newCall(GET("$url/$cutoff/$LIMIT", apiHeaders)) + .execute().run(::chapterListParse).let { + cutoff += LIMIT + current = it.size + chapters.addAll(it) + } + } + return Observable.just(chapters) + } override fun setupPreferenceScreen(screen: PreferenceScreen) { EditTextPreference(screen.context).apply { @@ -164,9 +179,6 @@ class Izneo(override val lang: String) : ConfigurableSource, HttpSource() { }.let(screen::addPreference) } - private inline val SManga.apiUrl: String - get() = "$ORIGIN/$lang/api/web/serie/" + url.substringAfterLast('-') - private inline val Album.timestamp: Long get() = dateFormat.parse(publicationDate)?.time ?: 0L @@ -182,6 +194,9 @@ class Izneo(override val lang: String) : ConfigurableSource, HttpSource() { } }.jsonObject + override fun chapterListRequest(manga: SManga) = + throw UnsupportedOperationException("Not used") + override fun mangaDetailsParse(response: Response) = throw UnsupportedOperationException("Not used") @@ -191,6 +206,8 @@ class Izneo(override val lang: String) : ConfigurableSource, HttpSource() { companion object { private const val ORIGIN = "https://izneo.com" + private const val LIMIT = 50 + private val dateFormat by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ROOT) }