Skip to content

Commit

Permalink
fix(en/allanime): Fix video decryptor (#2396)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofie99 authored Oct 18, 2023
1 parent a9fd254 commit 05e141c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 722 deletions.
2 changes: 1 addition & 1 deletion src/en/allanime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ext {
extName = 'AllAnime'
pkgNameSuffix = 'en.allanime'
extClass = '.AllAnime'
extVersionCode = 28
extVersionCode = 29
libVersion = '13'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
)

videoJson.data.episode.sourceUrls.forEach { video ->
val videoUrl = if (video.sourceUrl.startsWith("##")) {
AllAnimeDecryptor.decryptAllAnime(
"1234567890123456789",
video.sourceUrl.substringAfter("##"),
)
} else if (video.sourceUrl.startsWith("#")) {
AllAnimeDecryptor.decryptAllAnime(
"allanimenews",
video.sourceUrl.substringAfter("#"),
)
} else {
video.sourceUrl
}
val videoUrl = video.sourceUrl.decryptSource()

val matchingMapping = mappings.firstOrNull { (altHoster, urlMatches) ->
altHosterSelection.contains(altHoster) && videoUrl.containsAny(urlMatches)
Expand Down Expand Up @@ -435,6 +423,16 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
return json.decodeFromString(responseBody)
}

private fun String.decryptSource(): String {
return if (this.startsWith("-")) {
this.substringAfterLast('-').chunked(2)
.map { it.toInt(16).toByte() }
.toByteArray().map {
(it.toInt() xor 56).toChar()
}.joinToString("")
} else this
}

private fun prioritySort(pList: List<Pair<Video, Float>>): List<Video> {
val prefServer = preferences.prefServer
val quality = preferences.quality
Expand Down
Loading

0 comments on commit 05e141c

Please sign in to comment.