mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-03 14:50:49 +00:00
SLD checks, minor fixes
This commit is contained in:
parent
72efb21439
commit
7439e44e44
5 changed files with 45 additions and 10 deletions
File diff suppressed because one or more lines are too long
|
@ -4,6 +4,7 @@ import android.net.Uri
|
||||||
import com.futo.platformplayer.SignatureProvider
|
import com.futo.platformplayer.SignatureProvider
|
||||||
import com.futo.platformplayer.api.media.Serializer
|
import com.futo.platformplayer.api.media.Serializer
|
||||||
import com.futo.platformplayer.engine.IV8PluginConfig
|
import com.futo.platformplayer.engine.IV8PluginConfig
|
||||||
|
import com.futo.platformplayer.matchesDomain
|
||||||
import com.futo.platformplayer.states.StatePlugins
|
import com.futo.platformplayer.states.StatePlugins
|
||||||
import kotlinx.serialization.Contextual
|
import kotlinx.serialization.Contextual
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
@ -79,7 +80,7 @@ class SourcePluginConfig(
|
||||||
private val _allowUrlsLower: List<String> get() {
|
private val _allowUrlsLower: List<String> get() {
|
||||||
if(_allowUrlsLowerVal == null)
|
if(_allowUrlsLowerVal == null)
|
||||||
_allowUrlsLowerVal = allowUrls.map { it.lowercase() }
|
_allowUrlsLowerVal = allowUrls.map { it.lowercase() }
|
||||||
.filter { it.length > 0 && (it[0] != '*' || (_allowRegex.matches(it))) };
|
.filter { it.length > 0 };
|
||||||
return _allowUrlsLowerVal!!;
|
return _allowUrlsLowerVal!!;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -172,12 +173,10 @@ class SourcePluginConfig(
|
||||||
return true;
|
return true;
|
||||||
val uri = Uri.parse(url);
|
val uri = Uri.parse(url);
|
||||||
val host = uri.host?.lowercase() ?: "";
|
val host = uri.host?.lowercase() ?: "";
|
||||||
return _allowUrlsLower.any { it == host || (it.length > 0 && it[0] == '*' && host.endsWith(it.substring(1))) };
|
return _allowUrlsLower.any { it == host || (it.length > 0 && it[0] == '.' && host.matchesDomain(it)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val _allowRegex = Regex("\\*\\.[a-z0-9]+\\.[a-z]+");
|
|
||||||
|
|
||||||
fun fromJson(json: String, sourceUrl: String? = null): SourcePluginConfig {
|
fun fromJson(json: String, sourceUrl: String? = null): SourcePluginConfig {
|
||||||
val obj = Serializer.json.decodeFromString<SourcePluginConfig>(json);
|
val obj = Serializer.json.decodeFromString<SourcePluginConfig>(json);
|
||||||
if(obj.sourceUrl == null)
|
if(obj.sourceUrl == null)
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.caoccao.javet.exceptions.JavetException
|
||||||
import com.caoccao.javet.exceptions.JavetExecutionException
|
import com.caoccao.javet.exceptions.JavetExecutionException
|
||||||
import com.caoccao.javet.interop.V8Host
|
import com.caoccao.javet.interop.V8Host
|
||||||
import com.caoccao.javet.interop.V8Runtime
|
import com.caoccao.javet.interop.V8Runtime
|
||||||
|
import com.caoccao.javet.interop.options.V8Flags
|
||||||
|
import com.caoccao.javet.interop.options.V8RuntimeOptions
|
||||||
import com.caoccao.javet.values.V8Value
|
import com.caoccao.javet.values.V8Value
|
||||||
import com.caoccao.javet.values.primitive.V8ValueBoolean
|
import com.caoccao.javet.values.primitive.V8ValueBoolean
|
||||||
import com.caoccao.javet.values.primitive.V8ValueInteger
|
import com.caoccao.javet.values.primitive.V8ValueInteger
|
||||||
|
@ -133,9 +135,10 @@ class V8Plugin {
|
||||||
synchronized(_runtimeLock) {
|
synchronized(_runtimeLock) {
|
||||||
if (_runtime != null)
|
if (_runtime != null)
|
||||||
return;
|
return;
|
||||||
|
//V8RuntimeOptions.V8_FLAGS.setUseStrict(true);
|
||||||
val host = V8Host.getV8Instance();
|
val host = V8Host.getV8Instance();
|
||||||
val options = host.jsRuntimeType.getRuntimeOptions();
|
val options = host.jsRuntimeType.getRuntimeOptions();
|
||||||
|
|
||||||
_runtime = host.createV8Runtime(options);
|
_runtime = host.createV8Runtime(options);
|
||||||
if (!host.isIsolateCreated)
|
if (!host.isIsolateCreated)
|
||||||
throw IllegalStateException("Isolate not created");
|
throw IllegalStateException("Isolate not created");
|
||||||
|
|
|
@ -1674,7 +1674,7 @@ class VideoDetailView : ConstraintLayout {
|
||||||
_didTriggerDatasourceErrroCount++;
|
_didTriggerDatasourceErrroCount++;
|
||||||
|
|
||||||
UIDialogs.toast("Block detected, attempting bypass");
|
UIDialogs.toast("Block detected, attempting bypass");
|
||||||
|
//return;
|
||||||
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val newDetails = StatePlatform.instance.getContentDetails(currentVideo.url, true).await();
|
val newDetails = StatePlatform.instance.getContentDetails(currentVideo.url, true).await();
|
||||||
val previousVideoSource = _lastVideoSource;
|
val previousVideoSource = _lastVideoSource;
|
||||||
|
@ -1808,7 +1808,7 @@ class VideoDetailView : ConstraintLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val doDedup = false;
|
val doDedup = true;
|
||||||
|
|
||||||
val bestVideoSources = if(doDedup) (videoSources?.map { it.height * it.width }
|
val bestVideoSources = if(doDedup) (videoSources?.map { it.height * it.width }
|
||||||
?.distinct()
|
?.distinct()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.futo.platformplayer
|
package com.futo.platformplayer
|
||||||
|
|
||||||
|
import com.futo.platformplayer.api.media.platforms.js.SourcePluginConfig
|
||||||
import junit.framework.TestCase.assertEquals
|
import junit.framework.TestCase.assertEquals
|
||||||
|
import junit.framework.TestCase.assertFalse
|
||||||
import junit.framework.TestCase.assertTrue
|
import junit.framework.TestCase.assertTrue
|
||||||
import org.junit.Assert.assertThrows
|
import org.junit.Assert.assertThrows
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -52,4 +54,21 @@ class UtilityTests {
|
||||||
assertEquals("\ud83d\udc80\ud83d\udd14", "\\ud83d\\udc80\\ud83d\\udd14".decodeUnicode())
|
assertEquals("\ud83d\udc80\ud83d\udd14", "\\ud83d\\udc80\\ud83d\\udd14".decodeUnicode())
|
||||||
assertEquals("String with a slash (/) in it", "String with a slash (/) in it".decodeUnicode())
|
assertEquals("String with a slash (/) in it", "String with a slash (/) in it".decodeUnicode())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testMatchDomain() {
|
||||||
|
//TLD
|
||||||
|
assertTrue("test.abc.com".matchesDomain(".abc.com"))
|
||||||
|
assertTrue("abc.com".matchesDomain("abc.com"))
|
||||||
|
assertFalse("test.abc.com".matchesDomain("abc.com"))
|
||||||
|
assertThrows(IllegalStateException::class.java, { "test.uk".matchesDomain(".uk") });
|
||||||
|
|
||||||
|
|
||||||
|
//SLD
|
||||||
|
assertTrue("abc.co.uk".matchesDomain("abc.co.uk"))
|
||||||
|
assertTrue("test.abc.co.uk".matchesDomain("test.abc.co.uk"))
|
||||||
|
assertTrue("test.abc.co.uk".matchesDomain(".abc.co.uk"))
|
||||||
|
assertThrows(IllegalStateException::class.java, { "test.abc.co.uk".matchesDomain(".co.uk") });
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue