Circumvent URL handling breaking attempt. (#11670)
This commit is contained in:
parent
5327edc069
commit
6da81f171f
@ -18,7 +18,6 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
@ -46,7 +45,7 @@ class NeoxScanlator :
|
|||||||
.connectTimeout(1, TimeUnit.MINUTES)
|
.connectTimeout(1, TimeUnit.MINUTES)
|
||||||
.readTimeout(1, TimeUnit.MINUTES)
|
.readTimeout(1, TimeUnit.MINUTES)
|
||||||
.addInterceptor(::titleCollectionIntercept)
|
.addInterceptor(::titleCollectionIntercept)
|
||||||
.addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS))
|
.addInterceptor(RateLimitInterceptor(1, 3, TimeUnit.SECONDS))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override val altNameSelector = ".post-content_item:contains(Alternativo) .summary-content"
|
override val altNameSelector = ".post-content_item:contains(Alternativo) .summary-content"
|
||||||
@ -71,7 +70,8 @@ class NeoxScanlator :
|
|||||||
|
|
||||||
titleCollectionPath = popularPage.mangas.firstOrNull()?.url
|
titleCollectionPath = popularPage.mangas.firstOrNull()?.url
|
||||||
?.removePrefix("/")
|
?.removePrefix("/")
|
||||||
?.substringBefore("/")
|
?.removeSuffix("/")
|
||||||
|
?.substringBeforeLast("/")
|
||||||
|
|
||||||
return popularPage
|
return popularPage
|
||||||
}
|
}
|
||||||
@ -81,7 +81,8 @@ class NeoxScanlator :
|
|||||||
|
|
||||||
titleCollectionPath = latestPage.mangas.firstOrNull()?.url
|
titleCollectionPath = latestPage.mangas.firstOrNull()?.url
|
||||||
?.removePrefix("/")
|
?.removePrefix("/")
|
||||||
?.substringBefore("/")
|
?.removeSuffix("/")
|
||||||
|
?.substringBeforeLast("/")
|
||||||
|
|
||||||
return latestPage
|
return latestPage
|
||||||
}
|
}
|
||||||
@ -91,14 +92,12 @@ class NeoxScanlator :
|
|||||||
|
|
||||||
titleCollectionPath = searchPage.mangas.firstOrNull()?.url
|
titleCollectionPath = searchPage.mangas.firstOrNull()?.url
|
||||||
?.removePrefix("/")
|
?.removePrefix("/")
|
||||||
?.substringBefore("/")
|
?.removeSuffix("/")
|
||||||
|
?.substringBeforeLast("/")
|
||||||
|
|
||||||
return searchPage
|
return searchPage
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sometimes the site changes the manga URL. This override will
|
|
||||||
// add an error instead of the HTTP 404 to inform the user to
|
|
||||||
// migrate from Neox to Neox to update the URL.
|
|
||||||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||||
return client.newCall(mangaDetailsRequest(manga))
|
return client.newCall(mangaDetailsRequest(manga))
|
||||||
.asCustomObservable()
|
.asCustomObservable()
|
||||||
@ -108,11 +107,12 @@ class NeoxScanlator :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsRequest(manga: SManga): Request {
|
override fun mangaDetailsRequest(manga: SManga): Request {
|
||||||
val fixedUrl = (baseUrl + manga.url).toHttpUrl().newBuilder()
|
val titleSlug = manga.url
|
||||||
.setPathSegment(0, titleCollectionPath ?: TITLE_PATH_PLACEHOLDER)
|
.removeSuffix("/")
|
||||||
.toString()
|
.substringAfterLast("/")
|
||||||
|
val fixedPath = titleCollectionPath ?: TITLE_PATH_PLACEHOLDER
|
||||||
|
|
||||||
return GET(fixedUrl, headers)
|
return GET("$baseUrl/$fixedPath/$titleSlug", headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
||||||
@ -129,23 +129,25 @@ class NeoxScanlator :
|
|||||||
.add("X-Requested-With", "XMLHttpRequest")
|
.add("X-Requested-With", "XMLHttpRequest")
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val fixedUrl = mangaUrl.toHttpUrl().newBuilder()
|
val titleSlug = mangaUrl
|
||||||
.setPathSegment(0, titleCollectionPath ?: TITLE_PATH_PLACEHOLDER)
|
.substringAfter(baseUrl)
|
||||||
.addPathSegments("ajax/chapters")
|
.removeSuffix("/")
|
||||||
.toString()
|
.substringAfterLast("/")
|
||||||
|
val fixedPath = titleCollectionPath ?: TITLE_PATH_PLACEHOLDER
|
||||||
|
|
||||||
return POST(fixedUrl, xhrHeaders)
|
return POST("$baseUrl/$fixedPath/$titleSlug/ajax/chapters", xhrHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListRequest(chapter: SChapter): Request {
|
override fun pageListRequest(chapter: SChapter): Request {
|
||||||
val chapterUrl = (baseUrl + chapter.url.removePrefix(baseUrl)).toHttpUrlOrNull()
|
val chapterUrl = chapter.url.toHttpUrlOrNull()
|
||||||
?: return super.pageListRequest(chapter)
|
?: return super.pageListRequest(chapter)
|
||||||
|
|
||||||
val fixedUrl = chapterUrl.newBuilder()
|
val chapterSlug = chapterUrl.pathSegments
|
||||||
.setPathSegment(0, titleCollectionPath ?: TITLE_PATH_PLACEHOLDER)
|
.takeLast(3)
|
||||||
.toString()
|
.joinToString("/")
|
||||||
|
val fixedPath = titleCollectionPath ?: TITLE_PATH_PLACEHOLDER
|
||||||
|
|
||||||
return GET(fixedUrl, headers)
|
return GET("$baseUrl/$fixedPath/$chapterSlug", headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageRequest(page: Page): Request {
|
override fun imageRequest(page: Page): Request {
|
||||||
@ -196,7 +198,8 @@ class NeoxScanlator :
|
|||||||
|
|
||||||
popularPage.mangas.firstOrNull()?.url
|
popularPage.mangas.firstOrNull()?.url
|
||||||
?.removePrefix("/")
|
?.removePrefix("/")
|
||||||
?.substringBefore("/")
|
?.removeSuffix("/")
|
||||||
|
?.substringBeforeLast("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
titleCollectionPath = titlePathResult.getOrNull()
|
titleCollectionPath = titlePathResult.getOrNull()
|
||||||
@ -215,7 +218,7 @@ class NeoxScanlator :
|
|||||||
return asObservable().doOnNext { response ->
|
return asObservable().doOnNext { response ->
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
response.close()
|
response.close()
|
||||||
val message = if (response.code == 404)
|
val message = if (response.code == 404 || response.code == 403)
|
||||||
MIGRATION_MESSAGE else "HTTP error ${response.code}"
|
MIGRATION_MESSAGE else "HTTP error ${response.code}"
|
||||||
throw Exception(message)
|
throw Exception(message)
|
||||||
}
|
}
|
||||||
@ -224,6 +227,11 @@ class NeoxScanlator :
|
|||||||
response.close()
|
response.close()
|
||||||
throw Exception(MIGRATION_MESSAGE)
|
throw Exception(MIGRATION_MESSAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!response.headers["Content-Type"]!!.contains("text/html")) {
|
||||||
|
response.close()
|
||||||
|
throw Exception(MIGRATION_MESSAGE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ class MadaraGenerator : ThemeSourceGenerator {
|
|||||||
SingleLang("NeatManga", "https://neatmanga.com", "en", overrideVersionCode = 2),
|
SingleLang("NeatManga", "https://neatmanga.com", "en", overrideVersionCode = 2),
|
||||||
SingleLang("NekoBreaker Scan", "https://nekobreakerscan.com", "pt-BR", overrideVersionCode = 1),
|
SingleLang("NekoBreaker Scan", "https://nekobreakerscan.com", "pt-BR", overrideVersionCode = 1),
|
||||||
SingleLang("NekoScan", "https://nekoscan.com", "en", overrideVersionCode = 2),
|
SingleLang("NekoScan", "https://nekoscan.com", "en", overrideVersionCode = 2),
|
||||||
SingleLang("Neox Scanlator", "https://neoxscans.net", "pt-BR", overrideVersionCode = 11),
|
SingleLang("Neox Scanlator", "https://neoxscans.net", "pt-BR", overrideVersionCode = 12),
|
||||||
SingleLang("Night Comic", "https://www.nightcomic.com", "en", overrideVersionCode = 1),
|
SingleLang("Night Comic", "https://www.nightcomic.com", "en", overrideVersionCode = 1),
|
||||||
SingleLang("Niji Translations", "https://niji-translations.com", "ar", overrideVersionCode = 1),
|
SingleLang("Niji Translations", "https://niji-translations.com", "ar", overrideVersionCode = 1),
|
||||||
SingleLang("Ninja Scan", "https://ninjascan.xyz", "pt-BR", overrideVersionCode = 1),
|
SingleLang("Ninja Scan", "https://ninjascan.xyz", "pt-BR", overrideVersionCode = 1),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user