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(pt/vizer): Fixed pt/Vizer videos empty (#110)
- Loading branch information
Showing
8 changed files
with
177 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
id("lib-android") | ||
} | ||
|
||
dependencies { | ||
implementation("dev.datlag.jsunpacker:jsunpacker:1.0.1") { | ||
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8") | ||
} | ||
implementation(project(":lib:playlist-utils")) | ||
} |
63 changes: 63 additions & 0 deletions
63
...xtractor/src/main/java/eu/kanade/tachiyomi/lib/fireplayerextractor/FireplayerExtractor.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,63 @@ | ||
package eu.kanade.tachiyomi.lib.fireplayerextractor | ||
|
||
import dev.datlag.jsunpacker.JsUnpacker | ||
import eu.kanade.tachiyomi.animesource.model.Video | ||
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils | ||
import eu.kanade.tachiyomi.network.GET | ||
import eu.kanade.tachiyomi.network.POST | ||
import eu.kanade.tachiyomi.util.asJsoup | ||
import okhttp3.FormBody | ||
import okhttp3.Headers | ||
import okhttp3.HttpUrl.Companion.toHttpUrl | ||
import okhttp3.OkHttpClient | ||
|
||
class FireplayerExtractor( | ||
private val client: OkHttpClient, | ||
private val defaultHost: String? = null, | ||
) { | ||
fun videosFromUrl( | ||
url: String, | ||
videoNameGen: (String) -> String = { quality -> quality }, | ||
videoHost: String? = null, | ||
): List<Video> { | ||
val host = videoHost ?: defaultHost ?: "https://${url.toHttpUrl().host}" | ||
|
||
val headers = Headers.Builder() | ||
.set("X-Requested-With", "XMLHttpRequest") | ||
.set("Referer", host) | ||
.set("Origin", "https://${host.toHttpUrl().host}") | ||
.set("X-Requested-With", "XMLHttpRequest") | ||
.build() | ||
|
||
var id = url.substringAfterLast("/") | ||
|
||
if (id.length < 32) { | ||
val doc = client.newCall(GET(url, headers)).execute().asJsoup() | ||
|
||
val script = | ||
doc.selectFirst("script:containsData(eval):containsData(p,a,c,k,e,d)")?.data() | ||
?.let(JsUnpacker::unpackAndCombine) | ||
?: doc.selectFirst("script:containsData(FirePlayer)")?.data() | ||
|
||
if (script?.contains("FirePlayer(") == true) { | ||
id = script.substringAfter("FirePlayer(\"").substringBefore('"') | ||
} | ||
} | ||
|
||
val postUrl = "$host/player/index.php?data=$id&do=getVideo" | ||
val body = FormBody.Builder() | ||
.add("hash", id) | ||
.add("r", "") | ||
.build() | ||
|
||
val masterUrl = client.newCall(POST(postUrl, headers, body = body)).execute() | ||
.body.string() | ||
.substringAfter("securedLink\":\"") | ||
.substringBefore('"') | ||
.replace("\\", "") | ||
|
||
val playlistUtils = PlaylistUtils(client, headers) | ||
|
||
return playlistUtils.extractFromHls(masterUrl, videoNameGen = videoNameGen) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
ext { | ||
extName = 'Vizer.tv' | ||
extClass = '.Vizer' | ||
extVersionCode = 16 | ||
extVersionCode = 17 | ||
isNsfw = true | ||
} | ||
|
||
apply from: "$rootDir/common.gradle" | ||
|
||
dependencies { | ||
implementation(project(':lib:fireplayer-extractor')) | ||
implementation(project(':lib:mixdrop-extractor')) | ||
implementation(project(':lib:playlist-utils')) | ||
implementation(project(':lib:streamtape-extractor')) | ||
implementation "dev.datlag.jsunpacker:jsunpacker:1.0.1" | ||
} |
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
52 changes: 0 additions & 52 deletions
52
src/pt/vizer/src/eu/kanade/tachiyomi/animeextension/pt/vizer/extractors/WarezExtractor.kt
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
src/pt/vizer/src/eu/kanade/tachiyomi/animeextension/pt/vizer/interceptor/WebViewResolver.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,78 @@ | ||
package eu.kanade.tachiyomi.animeextension.pt.vizer.interceptor | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Application | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.util.Log | ||
import android.webkit.WebResourceRequest | ||
import android.webkit.WebResourceResponse | ||
import android.webkit.WebView | ||
import android.webkit.WebViewClient | ||
import okhttp3.Headers | ||
import uy.kohesive.injekt.injectLazy | ||
import java.util.concurrent.CountDownLatch | ||
import java.util.concurrent.TimeUnit | ||
|
||
class WebViewResolver(private val globalHeaders: Headers) { | ||
private val context: Application by injectLazy() | ||
private val handler by lazy { Handler(Looper.getMainLooper()) } | ||
private val tag by lazy { javaClass.simpleName } | ||
|
||
@SuppressLint("SetJavaScriptEnabled") | ||
fun getUrl(origRequestUrl: String, baseUrl: String): String? { | ||
val latch = CountDownLatch(1) | ||
var webView: WebView? = null | ||
var result: String? = null | ||
|
||
handler.post { | ||
val webview = WebView(context) | ||
webView = webview | ||
with(webview.settings) { | ||
javaScriptEnabled = true | ||
domStorageEnabled = true | ||
databaseEnabled = true | ||
useWideViewPort = false | ||
loadWithOverviewMode = false | ||
userAgentString = globalHeaders["User-Agent"] | ||
} | ||
webview.webViewClient = object : WebViewClient() { | ||
override fun shouldInterceptRequest( | ||
view: WebView, | ||
request: WebResourceRequest, | ||
): WebResourceResponse? { | ||
val url = request.url.toString() | ||
Log.d(tag, "Checking url $url") | ||
if (VIDEO_REGEX.containsMatchIn(url)) { | ||
result = url | ||
latch.countDown() | ||
} | ||
return super.shouldInterceptRequest(view, request) | ||
} | ||
|
||
override fun onPageFinished(view: WebView?, url: String?) { | ||
Log.d(tag, "onPageFinished $url") | ||
super.onPageFinished(view, url) | ||
|
||
view?.evaluateJavascript("document.body.innerHTML += '<iframe src=\"" + origRequestUrl + "\" scrolling=\"no\" frameborder=\"0\" allowfullscreen=\"\" webkitallowfullscreen=\"\" mozallowfullscreen=\"\"></iframe>'") {} | ||
} | ||
} | ||
|
||
webView?.loadUrl(baseUrl) | ||
} | ||
|
||
latch.await(TIMEOUT_SEC, TimeUnit.SECONDS) | ||
|
||
handler.post { | ||
webView?.stopLoading() | ||
webView?.destroy() | ||
webView = null | ||
} | ||
return result | ||
} | ||
|
||
companion object { | ||
const val TIMEOUT_SEC: Long = 25 | ||
private val VIDEO_REGEX by lazy { Regex("//(mixdrop|streamtape|warezcdn)|/video/") } | ||
} | ||
} |