mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 11:24:35 -05:00
Fix MangaDex and Other Sources (#715)
This commit is contained in:
@@ -137,7 +137,7 @@ twelvemonkeys-imageio-jpeg = { module = "com.twelvemonkeys.imageio:imageio-jpeg"
|
|||||||
twelvemonkeys-imageio-webp = { module = "com.twelvemonkeys.imageio:imageio-webp", version.ref = "twelvemonkeys" }
|
twelvemonkeys-imageio-webp = { module = "com.twelvemonkeys.imageio:imageio-webp", version.ref = "twelvemonkeys" }
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
mockk = "io.mockk:mockk:1.13.8"
|
mockk = "io.mockk:mockk:1.13.7"
|
||||||
|
|
||||||
# cron scheduler
|
# cron scheduler
|
||||||
cron4j = "it.sauronsoftware.cron4j:cron4j:2.2.5"
|
cron4j = "it.sauronsoftware.cron4j:cron4j:2.2.5"
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
get() = network.client
|
get() = network.client
|
||||||
|
|
||||||
private fun generateId(): Long {
|
private fun generateId(): Long {
|
||||||
return generateId(name, lang, versionId)
|
return generateId("${name.lowercase()}/$lang/$versionId")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +94,10 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
versionId: Int,
|
versionId: Int,
|
||||||
): Long {
|
): Long {
|
||||||
val key = "${name.lowercase()}/$lang/$versionId"
|
val key = "${name.lowercase()}/$lang/$versionId"
|
||||||
|
return generateId(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateId(key: String): Long {
|
||||||
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
|
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
|
||||||
return (0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
|
return (0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -416,7 +416,6 @@ class OpAnd(var op: Op<Boolean>? = null) {
|
|||||||
value: String?,
|
value: String?,
|
||||||
column: Column<String?>,
|
column: Column<String?>,
|
||||||
) = andWhere(value) { column like it }
|
) = andWhere(value) { column like it }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Comparable<T>> andFilterWithCompare(
|
fun <T : Comparable<T>> andFilterWithCompare(
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ object BytecodeEditor {
|
|||||||
*/
|
*/
|
||||||
private fun String?.replaceDirectly() =
|
private fun String?.replaceDirectly() =
|
||||||
when (this) {
|
when (this) {
|
||||||
null -> this
|
null -> null
|
||||||
in classesToReplace -> "$REPLACEMENT_PATH/$this"
|
in classesToReplace -> "$REPLACEMENT_PATH/$this"
|
||||||
else -> this
|
else -> this
|
||||||
}
|
}
|
||||||
@@ -108,24 +108,50 @@ object BytecodeEditor {
|
|||||||
* Replace references to the class, used in places that have
|
* Replace references to the class, used in places that have
|
||||||
* other text around the class references
|
* other text around the class references
|
||||||
*
|
*
|
||||||
* @return [String] with class references replaced,
|
* @return [String] with class references replaced, or null if [String] was null
|
||||||
* or null if [String] was null
|
|
||||||
*/
|
*/
|
||||||
private fun String?.replaceIndirectly(): String? {
|
private fun String?.replaceIndirectly(): String? {
|
||||||
var classReference = this
|
if (this == null) return null
|
||||||
if (classReference != null) {
|
var classReference: String = this
|
||||||
classesToReplace.forEach {
|
classesToReplace.forEach {
|
||||||
classReference = classReference?.replace(it, "$REPLACEMENT_PATH/$it")
|
classReference = classReference.replace(it, "$REPLACEMENT_PATH/$it")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return classReference
|
return classReference
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of methods that will be fixed. Remove once https://github.com/ThexXTURBOXx/dex2jar/issues/27
|
||||||
|
* is fixed.
|
||||||
|
*/
|
||||||
|
private val methodsToFix =
|
||||||
|
mapOf(
|
||||||
|
("kotlin/time/Duration" to "getInWholeMilliseconds_impl") to "getInWholeMilliseconds-impl",
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace references to the method, used in places that have
|
||||||
|
* other text around the class references
|
||||||
|
*
|
||||||
|
* @param clazz Class the method is in
|
||||||
|
*
|
||||||
|
* @return [String] with method reference replaced, or null if [String] or [clazz] was null
|
||||||
|
*/
|
||||||
|
private fun String?.replaceMethodIndirectly(clazz: String?): String? {
|
||||||
|
if (clazz == null || this == null) return this
|
||||||
|
var method: String = this
|
||||||
|
methodsToFix.forEach {
|
||||||
|
if (clazz == it.key.first) {
|
||||||
|
method = method.replace(it.key.second, it.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return method
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace all references to certain classes inside the class file
|
* Replace all references to certain classes inside the class file
|
||||||
* with ones that behave more like Androids
|
* with ones that behave more like Androids
|
||||||
*
|
*
|
||||||
* @param classfileBuffer Class bytecode to load into ASM for ease of modification
|
* @param pair Class bytecode to load into ASM for ease of modification
|
||||||
*
|
*
|
||||||
* @return [ByteArray] with modified bytecode
|
* @return [ByteArray] with modified bytecode
|
||||||
*/
|
*/
|
||||||
@@ -226,7 +252,7 @@ object BytecodeEditor {
|
|||||||
super.visitMethodInsn(
|
super.visitMethodInsn(
|
||||||
opcode,
|
opcode,
|
||||||
owner.replaceDirectly(),
|
owner.replaceDirectly(),
|
||||||
name,
|
name.replaceMethodIndirectly(owner),
|
||||||
desc.replaceIndirectly(),
|
desc.replaceIndirectly(),
|
||||||
itf,
|
itf,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user