Add missing URL change handler to NS. (#11636)
This commit is contained in:
parent
d2615c8b88
commit
11063214d1
|
@ -16,6 +16,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage
|
|||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import okhttp3.Call
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
|
@ -100,13 +101,7 @@ class NeoxScanlator :
|
|||
// migrate from Neox to Neox to update the URL.
|
||||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||
return client.newCall(mangaDetailsRequest(manga))
|
||||
.asObservable()
|
||||
.doOnNext { response ->
|
||||
if (!response.isSuccessful) {
|
||||
response.close()
|
||||
throw Exception(if (response.code == 404) MIGRATION_MESSAGE else "HTTP error ${response.code}")
|
||||
}
|
||||
}
|
||||
.asCustomObservable()
|
||||
.map { response ->
|
||||
mangaDetailsParse(response).apply { initialized = true }
|
||||
}
|
||||
|
@ -122,16 +117,12 @@ class NeoxScanlator :
|
|||
|
||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
||||
return client.newCall(chapterListRequest(manga))
|
||||
.asObservable()
|
||||
.doOnNext { response ->
|
||||
if (!response.isSuccessful) {
|
||||
response.close()
|
||||
throw Exception(if (response.code == 404) MIGRATION_MESSAGE else "HTTP error ${response.code}")
|
||||
}
|
||||
}
|
||||
.asCustomObservable()
|
||||
.map(::chapterListParse)
|
||||
}
|
||||
|
||||
override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga)
|
||||
|
||||
override fun xhrChaptersRequest(mangaUrl: String): Request {
|
||||
val xhrHeaders = headersBuilder()
|
||||
.add("Referer", baseUrl)
|
||||
|
@ -211,7 +202,7 @@ class NeoxScanlator :
|
|||
titleCollectionPath = titlePathResult.getOrNull()
|
||||
|
||||
val fixedUrl = request.url.toString()
|
||||
.replace(TITLE_PATH_PLACEHOLDER, titleCollectionPath ?: "comicz")
|
||||
.replace(TITLE_PATH_PLACEHOLDER, titleCollectionPath ?: "manga")
|
||||
|
||||
val fixedRequest = request.newBuilder()
|
||||
.url(fixedUrl)
|
||||
|
@ -220,8 +211,24 @@ class NeoxScanlator :
|
|||
return chain.proceed(fixedRequest)
|
||||
}
|
||||
|
||||
private fun Call.asCustomObservable(): Observable<Response> {
|
||||
return asObservable().doOnNext { response ->
|
||||
if (!response.isSuccessful) {
|
||||
response.close()
|
||||
val message = if (response.code == 404)
|
||||
MIGRATION_MESSAGE else "HTTP error ${response.code}"
|
||||
throw Exception(message)
|
||||
}
|
||||
|
||||
if (response.request.url.toString() == "$baseUrl/" && response.code == 200) {
|
||||
response.close()
|
||||
throw Exception(MIGRATION_MESSAGE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MIGRATION_MESSAGE = "A URL deste mangá mudou. " +
|
||||
private const val MIGRATION_MESSAGE = "A URL deste título mudou. " +
|
||||
"Faça a migração da Neox para a Neox para atualizar a URL."
|
||||
|
||||
private const val ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9," +
|
||||
|
|
|
@ -339,7 +339,7 @@ class MadaraGenerator : ThemeSourceGenerator {
|
|||
SingleLang("NeatManga", "https://neatmanga.com", "en", overrideVersionCode = 2),
|
||||
SingleLang("NekoBreaker Scan", "https://nekobreakerscan.com", "pt-BR", overrideVersionCode = 1),
|
||||
SingleLang("NekoScan", "https://nekoscan.com", "en", overrideVersionCode = 2),
|
||||
SingleLang("Neox Scanlator", "https://neoxscans.net", "pt-BR", overrideVersionCode = 10),
|
||||
SingleLang("Neox Scanlator", "https://neoxscans.net", "pt-BR", overrideVersionCode = 11),
|
||||
SingleLang("Night Comic", "https://www.nightcomic.com", "en", overrideVersionCode = 1),
|
||||
SingleLang("Niji Translations", "https://niji-translations.com", "ar", overrideVersionCode = 1),
|
||||
SingleLang("Ninja Scan", "https://ninjascan.xyz", "pt-BR", overrideVersionCode = 1),
|
||||
|
|
Loading…
Reference in New Issue