diff --git a/multisrc/overrides/mangathemesia/asurascans/src/AsuraScansEn.kt b/multisrc/overrides/mangathemesia/asurascans/src/AsuraScansEn.kt index d8bacc6fc..c9b473d19 100644 --- a/multisrc/overrides/mangathemesia/asurascans/src/AsuraScansEn.kt +++ b/multisrc/overrides/mangathemesia/asurascans/src/AsuraScansEn.kt @@ -63,21 +63,26 @@ class AsuraScansEn : MangaThemesia( // Temp Url for manga/chapter override fun fetchChapterList(manga: SManga): Observable> { - val newManga = manga.permUrlToTemp() + val newManga = manga.titleToUrlFrag() return super.fetchChapterList(newManga) } override fun fetchMangaDetails(manga: SManga): Observable { - val newManga = manga.permUrlToTemp() + val newManga = manga.titleToUrlFrag() return super.fetchMangaDetails(newManga) } override fun getMangaUrl(manga: SManga): String { - val newManga = manga.permUrlToTemp() + val dbSlug = manga.url + .substringBefore("#") + .removeSuffix("/") + .substringAfterLast("/") - return baseUrl + newManga.url + val storedSlug = getSlugMap()[dbSlug] ?: dbSlug + + return "$baseUrl$mangaUrlDirectory/$storedSlug/" } // Skip scriptPages @@ -124,16 +129,10 @@ class AsuraScansEn : MangaThemesia( return this } - private fun SManga.permUrlToTemp(): SManga { + private fun SManga.titleToUrlFrag(): SManga { return try { - val dbSlug = this.url - .removeSuffix("/") - .substringAfterLast("/") - - val storedSlug = getSlugMap()[dbSlug] ?: dbSlug - this.apply { - url = "$mangaUrlDirectory/$storedSlug/#${title.toSearchQuery()}" + url = "$url#${title.toSearchQuery()}" } } catch (e: UninitializedPropertyAccessException) { // when called from deep link, title is not present @@ -143,26 +142,31 @@ class AsuraScansEn : MangaThemesia( private fun urlChangeInterceptor(chain: Interceptor.Chain): Response { val request = chain.request() - val response = chain.proceed(request) val frag = request.url.fragment if (frag.isNullOrEmpty()) { - return response + return chain.proceed(request) } + val dbSlug = request.url.toString() + .substringBefore("#") + .removeSuffix("/") + .substringAfterLast("/") + + val slugMap = getSlugMap().toMutableMap() + + val storedSlug = slugMap[dbSlug] ?: dbSlug + + val response = chain.proceed( + request.newBuilder() + .url("$baseUrl$mangaUrlDirectory/$storedSlug/") + .build(), + ) + if (!response.isSuccessful && response.code == 404) { response.close() - val dbSlug = request.url.toString() - .substringBefore("#") - .removeSuffix("/") - .substringAfterLast("/") - - val slugMap = getSlugMap().toMutableMap() - - val storedSlug = slugMap[dbSlug] ?: dbSlug - val newSlug = getNewSlug(storedSlug, frag) ?: throw IOException("Migrate from Asura to Asura") diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt index 2a63ce18f..9de8f7f9e 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt @@ -14,7 +14,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator { override val baseVersionCode: Int = 25 override val sources = listOf( - MultiLang("Asura Scans", "https://www.asurascans.com", listOf("en", "tr"), className = "AsuraScansFactory", pkgName = "asurascans", overrideVersionCode = 22), + MultiLang("Asura Scans", "https://www.asurascans.com", listOf("en", "tr"), className = "AsuraScansFactory", pkgName = "asurascans", overrideVersionCode = 23), MultiLang("Flame Scans", "https://flamescans.org", listOf("en"), className = "FlameScansFactory", pkgName = "flamescans", overrideVersionCode = 4), MultiLang("Komik Lab", "https://komiklab.com", listOf("en", "id"), className = "KomikLabFactory", pkgName = "komiklab", overrideVersionCode = 2), MultiLang("Miau Scan", "https://miauscan.com", listOf("es", "pt-BR")),