-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
537 additions
and
275 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
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
id("lib-android") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":lib:playlist-utils")) | ||
} |
85 changes: 85 additions & 0 deletions
85
lib/url-resolver/src/main/java/eu/kanade/tachiyomi/lib/urlresolver/UrlResolver.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,85 @@ | ||
package eu.kanade.tachiyomi.lib.universalextractor | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Application | ||
import android.os.Handler | ||
import android.os.Looper | ||
import android.webkit.WebResourceRequest | ||
import android.webkit.WebResourceResponse | ||
import android.webkit.WebView | ||
import android.webkit.WebViewClient | ||
import eu.kanade.tachiyomi.animesource.model.Video | ||
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils | ||
import okhttp3.Headers | ||
import okhttp3.HttpUrl.Companion.toHttpUrl | ||
import okhttp3.OkHttpClient | ||
import uy.kohesive.injekt.injectLazy | ||
import java.util.Locale | ||
import java.util.concurrent.CountDownLatch | ||
import java.util.concurrent.TimeUnit | ||
|
||
class UrlResolver(private val client: OkHttpClient) { | ||
private val context: Application by injectLazy() | ||
private val handler by lazy { Handler(Looper.getMainLooper()) } | ||
@SuppressLint("SetJavaScriptEnabled") | ||
fun videosFromUrl(origRequestUrl: String, origRequestHeader: Headers, customQuality: String? = null): List<Video> { | ||
val host = origRequestUrl.toHttpUrl().host.substringBefore(".").proper() | ||
val latch = CountDownLatch(1) | ||
var webView: WebView? = null | ||
var resultUrl = "" | ||
val playlistUtils by lazy { PlaylistUtils(client, origRequestHeader) } | ||
val headers = origRequestHeader.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap() | ||
|
||
handler.post { | ||
val newView = WebView(context) | ||
webView = newView | ||
with(newView.settings) { | ||
javaScriptEnabled = true | ||
domStorageEnabled = true | ||
databaseEnabled = true | ||
useWideViewPort = false | ||
loadWithOverviewMode = false | ||
userAgentString = origRequestHeader["User-Agent"] | ||
} | ||
newView.webViewClient = object : WebViewClient() { | ||
override fun shouldInterceptRequest( | ||
view: WebView, | ||
request: WebResourceRequest, | ||
): WebResourceResponse? { | ||
val url = request.url.toString() | ||
if (VIDEO_REGEX.containsMatchIn(url)) { | ||
resultUrl = url | ||
latch.countDown() | ||
} | ||
return super.shouldInterceptRequest(view, request) | ||
} | ||
} | ||
|
||
webView?.loadUrl(origRequestUrl, headers) | ||
} | ||
|
||
latch.await(TIMEOUT_SEC, TimeUnit.SECONDS) | ||
|
||
handler.post { | ||
webView?.stopLoading() | ||
webView?.destroy() | ||
webView = null | ||
} | ||
return when { | ||
"m3u8" in resultUrl -> playlistUtils.extractFromHls(resultUrl, origRequestUrl, videoNameGen = { "$host: $it" }) | ||
"mpd" in resultUrl -> playlistUtils.extractFromDash(resultUrl, { it -> "$host: $it" }, referer = origRequestUrl) | ||
"mp4" in resultUrl -> Video(resultUrl, "$host: ${customQuality ?: "Mirror"}", resultUrl, origRequestHeader.newBuilder().add("referer", origRequestUrl).build()).let(::listOf) | ||
else -> emptyList() | ||
} | ||
} | ||
|
||
private fun String.proper(): String { | ||
return this.replaceFirstChar { if (it.isLowerCase()) it.titlecase( | ||
Locale.getDefault()) else it.toString() } | ||
} | ||
|
||
companion object { | ||
const val TIMEOUT_SEC: Long = 20 | ||
private val VIDEO_REGEX by lazy { Regex("\\.(mp4|m3u8|mpd)") } | ||
} | ||
} |
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
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
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,14 +1,18 @@ | ||
ext { | ||
extName = 'AnimeLek' | ||
extClass = '.AnimeLek' | ||
extVersionCode = 34 | ||
extVersionCode = 1 | ||
} | ||
|
||
apply from: "$rootDir/common.gradle" | ||
|
||
dependencies { | ||
implementation(project(':lib:streamtape-extractor')) | ||
implementation(project(':lib:multiservers')) | ||
implementation(project(':lib:okru-extractor')) | ||
implementation(project(':lib:dood-extractor')) | ||
implementation(project(':lib:vidbom-extractor')) | ||
implementation(project(':lib:mixdrop-extractor')) | ||
implementation(project(':lib:mp4upload-extractor')) | ||
implementation(project(':lib:streamwish-extractor')) | ||
} |
Oops, something went wrong.