AS: fix for j2k (#16871)

This commit is contained in:
AwkwardPeak7 2023-06-26 21:35:21 +05:00 committed by GitHub
parent 2d3b223259
commit 750d06f90d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 24 deletions

View File

@ -63,21 +63,26 @@ class AsuraScansEn : MangaThemesia(
// Temp Url for manga/chapter
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
val newManga = manga.permUrlToTemp()
val newManga = manga.titleToUrlFrag()
return super.fetchChapterList(newManga)
}
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
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")

View File

@ -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")),