[RU]Remanga detect HTTP error when GET mangaBranches (#18164)

* [RU]Remanga detect HTTP error when GET mangaBranches

* more change logic
This commit is contained in:
Eshlender 2023-09-27 03:24:08 +05:00 committed by GitHub
parent 1c8211937f
commit a90fe950ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Remanga'
pkgNameSuffix = 'ru.remanga'
extClass = '.Remanga'
extVersionCode = 79
extVersionCode = 80
}
dependencies {

View File

@ -404,7 +404,7 @@ class Remanga : ConfigurableSource, HttpSource() {
.asObservable().doOnNext { response ->
if (!response.isSuccessful) {
response.close()
if (response.code == 404 && USER_ID == "") warnLogin = true else throw Exception("HTTP error ${response.code}")
if (USER_ID == "") warnLogin = true else throw Exception("HTTP error ${response.code}")
}
}
.map { response ->
@ -425,7 +425,14 @@ class Remanga : ConfigurableSource, HttpSource() {
}
private fun mangaBranches(manga: SManga): List<BranchesDto> {
val responseString = client.newCall(GET(baseUrl + manga.url, headers)).execute().body.string()
val requestString = client.newCall(GET(baseUrl + manga.url, headers)).execute()
if (!requestString.isSuccessful) {
if (USER_ID == "") {
throw Exception("HTTP error ${requestString.code}. Для просмотра контента необходима авторизация через WebView\uD83C\uDF0E")
}
throw Exception("HTTP error ${requestString.code}")
}
val responseString = requestString.body.string()
// manga requiring login return "content" as a JsonArray instead of the JsonObject we expect
// callback request for update outside the library
val content = json.decodeFromString<JsonObject>(responseString)["content"]