Fix MangaDex and Other Sources (#715)

This commit is contained in:
Mitchell Syer
2023-10-15 21:50:30 -04:00
committed by GitHub
parent 682c364647
commit 2cf9a407e8
4 changed files with 42 additions and 13 deletions

View File

@@ -68,7 +68,7 @@ abstract class HttpSource : CatalogueSource {
get() = network.client
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,
): Long {
val key = "${name.lowercase()}/$lang/$versionId"
return generateId(key)
}
private fun generateId(key: String): Long {
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
}