extractor: fixed Rabbitstream (#757)

* Extractor: added Rabbitstream

* Extractor: added Rabbitstream

* fixed Rabbitstream

---------

Co-authored-by: Sofie99 <Sofie99@gmail.com>
This commit is contained in:
Sofie 2023-11-10 21:28:27 +07:00 committed by GitHub
parent 11136fe63d
commit 22a0c25d83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,13 +16,13 @@ import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec import javax.crypto.spec.SecretKeySpec
// No License found in https://github.com/enimax-anime/key // Code found in https://github.com/theonlymo/keys
// special credits to @enimax for providing key // special credits to @theonlymo for providing key
class Megacloud : Rabbitstream() { class Megacloud : Rabbitstream() {
override val name = "Megacloud" override val name = "Megacloud"
override val mainUrl = "https://megacloud.tv" override val mainUrl = "https://megacloud.tv"
override val embed = "embed-2/ajax/e-1" override val embed = "embed-2/ajax/e-1"
override val key = "https://raw.githubusercontent.com/enimax-anime/key/e6/key.txt" override val key = "https://raw.githubusercontent.com/theonlymo/keys/e1/key"
} }
class Dokicloud : Rabbitstream() { class Dokicloud : Rabbitstream() {
@ -35,7 +35,7 @@ open class Rabbitstream : ExtractorApi() {
override val mainUrl = "https://rabbitstream.net" override val mainUrl = "https://rabbitstream.net"
override val requiresReferer = false override val requiresReferer = false
open val embed = "ajax/embed-4" open val embed = "ajax/embed-4"
open val key = "https://raw.githubusercontent.com/enimax-anime/key/e4/key.txt" open val key = "https://raw.githubusercontent.com/theonlymo/keys/e4/key"
override suspend fun getUrl( override suspend fun getUrl(
url: String, url: String,
@ -86,21 +86,23 @@ open class Rabbitstream : ExtractorApi() {
private suspend fun getRawKey(): String = app.get(key).text private suspend fun getRawKey(): String = app.get(key).text
private fun extractRealKey(originalString: String?, stops: String): Pair<String, String> { private fun extractRealKey(sources: String, stops: String): Pair<String, String> {
val table = parseJson<List<List<Int>>>(stops) val decryptKey = parseJson<List<List<Int>>>(stops)
val decryptedKey = StringBuilder() val sourcesArray = sources.toCharArray()
var offset = 0
var encryptedString = originalString
table.forEach { (start, end) -> var extractedKey = ""
decryptedKey.append(encryptedString?.substring(start - offset, end - offset)) var currentIndex = 0
encryptedString = encryptedString?.substring( for (index in decryptKey) {
0, val start = index[0] + currentIndex
start - offset val end = start + index[1]
) + encryptedString?.substring(end - offset) for (i in start until end) {
offset += end - start extractedKey += sourcesArray[i].toString()
sourcesArray[i] = ' '
}
currentIndex += index[1]
} }
return decryptedKey.toString() to encryptedString.toString()
return extractedKey to sourcesArray.joinToString("")
} }
private inline fun <reified T> decryptMapped(input: String, key: String): T? { private inline fun <reified T> decryptMapped(input: String, key: String): T? {