[MangaThemesia + ConstellarScans] Add trailing slashes to URLs; stricter checking for decoding keys (#15088)
* [MangaThemesia] Append a trailing slash to requests to avoid 301s * [ConstellarScans] Don't trust their keys * whoops * this is just for you TheRunningRiot * [MangaThemesia] Return proper URL when searching by URL
This commit is contained in:
parent
1fccdf3d28
commit
dfcd66b3fc
|
@ -30,7 +30,7 @@ import java.security.MessageDigest
|
||||||
class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarscans.com", "en") {
|
class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarscans.com", "en") {
|
||||||
|
|
||||||
override val client = super.client.newBuilder()
|
override val client = super.client.newBuilder()
|
||||||
.rateLimit(1, 2)
|
.rateLimit(1, 3)
|
||||||
.addInterceptor { chain ->
|
.addInterceptor { chain ->
|
||||||
val response = chain.proceed(chain.request())
|
val response = chain.proceed(chain.request())
|
||||||
|
|
||||||
|
@ -97,24 +97,22 @@ class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarsca
|
||||||
?: return super.pageListParse(document)
|
?: return super.pageListParse(document)
|
||||||
val descrambledData = descrambleString(tsData).trim()
|
val descrambledData = descrambleString(tsData).trim()
|
||||||
|
|
||||||
val match = DESCRAMBLING_KEY_RE.find(descrambledData)?.value
|
// check if the object can be parsed with JSON, else assume it is encrypted
|
||||||
if (match != null) {
|
//
|
||||||
Log.d("constellarscans", "device-limited chapter, key: $match")
|
// done because constellarscans have shit code and would sometimes give us an invalid key
|
||||||
return decodeDeviceLimitedChapter(match)
|
// for no reason
|
||||||
}
|
return try {
|
||||||
|
val parsedTsData = json.parseToJsonElement(descrambledData).jsonObject
|
||||||
val imageListJson =
|
val imageList = parsedTsData["sources"]!!.jsonArray[0].jsonObject["images"]!!.jsonArray
|
||||||
JSON_IMAGE_LIST_REGEX.find(descrambledData)?.groupValues?.get(1).orEmpty()
|
imageList.mapIndexed { idx, it ->
|
||||||
val imageList = try {
|
Page(idx, imageUrl = it.jsonPrimitive.content)
|
||||||
json.parseToJsonElement(imageListJson).jsonArray
|
}
|
||||||
} catch (_: IllegalArgumentException) {
|
} catch (_: IllegalArgumentException) {
|
||||||
emptyList()
|
val match = DESCRAMBLING_KEY_RE.find(descrambledData)?.value
|
||||||
|
?: throw Exception("Did not receive valid decryption key. Try opening the chapter again.")
|
||||||
|
Log.d("constellarscans", "device-limited chapter: $match")
|
||||||
|
decodeDeviceLimitedChapter(match)
|
||||||
}
|
}
|
||||||
val scriptPages = imageList.mapIndexed { i, jsonEl ->
|
|
||||||
Page(i, imageUrl = jsonEl.jsonPrimitive.content)
|
|
||||||
}
|
|
||||||
|
|
||||||
return scriptPages
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageRequest(page: Page): Request = super.imageRequest(page).newBuilder()
|
override fun imageRequest(page: Page): Request = super.imageRequest(page).newBuilder()
|
||||||
|
|
|
@ -71,11 +71,11 @@ abstract class MangaThemesia(
|
||||||
|
|
||||||
return fetchMangaDetails(
|
return fetchMangaDetails(
|
||||||
SManga.create()
|
SManga.create()
|
||||||
.apply { this.url = "$mangaUrlDirectory/$mangaPath" }
|
.apply { this.url = "$mangaUrlDirectory/$mangaPath/" }
|
||||||
)
|
)
|
||||||
.map {
|
.map {
|
||||||
// Isn't set in returned manga
|
// Isn't set in returned manga
|
||||||
it.url = "$mangaUrlDirectory/$id"
|
it.url = "$mangaUrlDirectory/$mangaPath/"
|
||||||
MangasPage(listOf(it), false)
|
MangasPage(listOf(it), false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,7 @@ abstract class MangaThemesia(
|
||||||
else -> { /* Do Nothing */ }
|
else -> { /* Do Nothing */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
url.addPathSegment("")
|
||||||
return GET(url.toString())
|
return GET(url.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator {
|
||||||
|
|
||||||
override val themeClass = "MangaThemesia"
|
override val themeClass = "MangaThemesia"
|
||||||
|
|
||||||
override val baseVersionCode: Int = 23
|
override val baseVersionCode: Int = 24
|
||||||
|
|
||||||
override val sources = listOf(
|
override val sources = listOf(
|
||||||
MultiLang("Asura Scans", "https://www.asurascans.com", listOf("en", "tr"), className = "AsuraScansFactory", pkgName = "asurascans", overrideVersionCode = 18),
|
MultiLang("Asura Scans", "https://www.asurascans.com", listOf("en", "tr"), className = "AsuraScansFactory", pkgName = "asurascans", overrideVersionCode = 18),
|
||||||
|
|
Loading…
Reference in New Issue