forked from aniyomiorg/aniyomi-extensions
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix [OnePace] * fix but more elegant [OnePace]
- Loading branch information
1 parent
4082065
commit be441f9
Showing
3 changed files
with
35 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/all/onepace/src/eu/kanade/tachiyomi/animeextension/all/onepace/ZippyExtractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package eu.kanade.tachiyomi.animeextension.all.onepace | ||
|
||
import app.cash.quickjs.QuickJs | ||
import kotlinx.serialization.decodeFromString | ||
import kotlinx.serialization.json.Json | ||
import kotlinx.serialization.json.JsonObject | ||
import kotlinx.serialization.json.jsonPrimitive | ||
import org.jsoup.Jsoup | ||
|
||
class ZippyExtractor { | ||
fun getVideoUrl(url: String, json: Json): String { | ||
val document = Jsoup.connect(url).get() | ||
val jscript = document.selectFirst("script:containsData(dlbutton)").data() | ||
.replace("document.getElementById('dlbutton').href", "a") | ||
.replace("document.getElementById('fimage').href", "b") | ||
.replace("document.getElementById('fimage')", "false") | ||
val quickjs = QuickJs.create() | ||
val objectA = quickjs.evaluate(objectScript(jscript)).toString() | ||
quickjs.close() | ||
return json.decodeFromString<JsonObject>(objectA)["a"]!!.jsonPrimitive.content | ||
} | ||
|
||
private fun objectScript(script: String) = """ | ||
$script; | ||
let return_object = {a:a}; | ||
JSON.stringify(return_object); | ||
""" | ||
} |