mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-17 13:32:38 +02:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 801c646a09 | |||
| df4ec87613 | |||
| b08a79b7cb | |||
| 396e9f9f43 | |||
| 0e5a87a911 | |||
| 64d72f6d10 |
@@ -211,7 +211,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
|
||||
//State
|
||||
private val _queue: LinkedList<Pair<MainFragment, Any?>> = LinkedList();
|
||||
lateinit var fragCurrent: MainFragment private set;
|
||||
var fragCurrent: MainFragment? = null; private set;
|
||||
private var _parameterCurrent: Any? = null;
|
||||
|
||||
var fragBeforeOverlay: MainFragment? = null; private set;
|
||||
@@ -566,7 +566,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
defaultTab.action(_fragBotBarMenu);
|
||||
StateSubscriptions.instance;
|
||||
|
||||
fragCurrent.onShown(null, false);
|
||||
fragCurrent?.onShown(null, false);
|
||||
|
||||
//Other stuff
|
||||
rootView.progress = 0f;
|
||||
@@ -1153,7 +1153,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
if (_fragVideoDetail.state == VideoDetailFragment.State.MAXIMIZED && _fragVideoDetail.onBackPressed())
|
||||
return;
|
||||
|
||||
if (!fragCurrent.onBackPressed())
|
||||
if (!(fragCurrent?.onBackPressed() ?: true))
|
||||
closeSegment();
|
||||
}
|
||||
|
||||
@@ -1231,27 +1231,27 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
return;
|
||||
}
|
||||
|
||||
fragCurrent.onHide();
|
||||
fragCurrent?.onHide();
|
||||
|
||||
if (segment.isMainView) {
|
||||
var transaction = supportFragmentManager.beginTransaction();
|
||||
if (segment.topBar != null) {
|
||||
if (segment.topBar != fragCurrent.topBar) {
|
||||
if (segment.topBar != fragCurrent?.topBar) {
|
||||
transaction = transaction
|
||||
.show(segment.topBar as Fragment)
|
||||
.replace(R.id.fragment_top_bar, segment.topBar as Fragment);
|
||||
fragCurrent.topBar?.onHide();
|
||||
fragCurrent?.topBar?.onHide();
|
||||
}
|
||||
} else if (fragCurrent.topBar != null)
|
||||
transaction.hide(fragCurrent.topBar as Fragment);
|
||||
} else if (fragCurrent?.topBar != null)
|
||||
transaction.hide(fragCurrent?.topBar as Fragment);
|
||||
|
||||
transaction = transaction.replace(R.id.fragment_main, segment);
|
||||
|
||||
if (segment.hasBottomBar) {
|
||||
if (!fragCurrent.hasBottomBar)
|
||||
if (!(fragCurrent?.hasBottomBar ?: false))
|
||||
transaction = transaction.show(_fragBotBarMenu);
|
||||
} else {
|
||||
if (fragCurrent.hasBottomBar)
|
||||
if (fragCurrent?.hasBottomBar ?: false)
|
||||
transaction = transaction.hide(_fragBotBarMenu);
|
||||
}
|
||||
transaction.commitNow();
|
||||
@@ -1264,10 +1264,10 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
}
|
||||
}
|
||||
|
||||
if (fragCurrent.isHistory && withHistory && _queue.lastOrNull() != fragCurrent)
|
||||
_queue.add(Pair(fragCurrent, _parameterCurrent));
|
||||
if (fragCurrent?.isHistory ?: false && withHistory && _queue.lastOrNull() != fragCurrent)
|
||||
_queue.add(Pair(fragCurrent!!, _parameterCurrent));
|
||||
|
||||
if (segment.isOverlay && !fragCurrent.isOverlay && withHistory)// && fragCurrent.isHistory)
|
||||
if (segment.isOverlay && !(fragCurrent?.isOverlay ?: false) && withHistory)// && fragCurrent.isHistory)
|
||||
fragBeforeOverlay = fragCurrent;
|
||||
|
||||
fragCurrent = segment;
|
||||
@@ -1364,7 +1364,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
|
||||
private fun updateSegmentPaddings() {
|
||||
var paddingBottom = 0f;
|
||||
if (fragCurrent.hasBottomBar)
|
||||
if (fragCurrent?.hasBottomBar ?: false)
|
||||
paddingBottom += HEIGHT_MENU_DP;
|
||||
|
||||
_fragContainerOverlay.setPadding(
|
||||
|
||||
@@ -153,8 +153,8 @@ open class JSClient : IPlatformClient {
|
||||
_captcha = descriptor.getCaptchaData();
|
||||
flags = descriptor.flags.toTypedArray();
|
||||
|
||||
_httpClient = JSHttpClient(this, null, _captcha);
|
||||
_httpClientAuth = JSHttpClient(this, _auth, _captcha);
|
||||
_httpClient = JSHttpClient(this, null, _captcha, config);
|
||||
_httpClientAuth = JSHttpClient(this, _auth, _captcha, config);
|
||||
_plugin = V8Plugin(context, descriptor.config, null, _httpClient, _httpClientAuth);
|
||||
_plugin.withDependency(context, "scripts/polyfil.js");
|
||||
_plugin.withDependency(context, "scripts/source.js");
|
||||
@@ -186,8 +186,8 @@ open class JSClient : IPlatformClient {
|
||||
_captcha = descriptor.getCaptchaData();
|
||||
flags = descriptor.flags.toTypedArray();
|
||||
|
||||
_httpClient = JSHttpClient(this, null, _captcha);
|
||||
_httpClientAuth = JSHttpClient(this, _auth, _captcha);
|
||||
_httpClient = JSHttpClient(this, null, _captcha, config);
|
||||
_httpClientAuth = JSHttpClient(this, _auth, _captcha, config);
|
||||
_plugin = V8Plugin(context, descriptor.config, script, _httpClient, _httpClientAuth);
|
||||
_plugin.withDependency(context, "scripts/polyfil.js");
|
||||
_plugin.withDependency(context, "scripts/source.js");
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import java.util.UUID
|
||||
class JSHttpClient : ManagedHttpClient {
|
||||
private val _jsClient: JSClient?;
|
||||
private val _jsConfig: SourcePluginConfig?;
|
||||
val config get() = _jsConfig
|
||||
private val _auth: SourceAuth?;
|
||||
private val _captcha: SourceCaptchaData?;
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ object Libcurl {
|
||||
var body: ByteArray? = null,
|
||||
var impersonateTarget: String = "chrome136",
|
||||
var useBuiltInHeaders: Boolean = true,
|
||||
var timeoutMs: Int = 30_000,
|
||||
var cookieJarPath: String? = null,
|
||||
var sendCookies: Boolean = true,
|
||||
var persistCookies: Boolean = true,
|
||||
var timeoutMs: Int = 30_000
|
||||
)
|
||||
|
||||
@Keep
|
||||
@@ -121,12 +118,6 @@ object Libcurl {
|
||||
if (slist != 0L) checkOK(ce_setopt_ptr(easy, CURLOPT.HTTPHEADER, slist))
|
||||
}
|
||||
|
||||
if (req.sendCookies || req.persistCookies) {
|
||||
val jar = (req.cookieJarPath ?: defaultCookieJarPath())
|
||||
if (req.sendCookies) checkOK(ce_setopt_str(easy, CURLOPT.COOKIEFILE, jar))
|
||||
if (req.persistCookies) checkOK(ce_setopt_str(easy, CURLOPT.COOKIEJAR, jar))
|
||||
}
|
||||
|
||||
val method = req.method
|
||||
if (!method.equals("GET", ignoreCase = true)) {
|
||||
checkOK(ce_setopt_str(easy, CURLOPT.CUSTOMREQUEST, method))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.futo.platformplayer.engine.packages
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.core.net.toUri
|
||||
import com.caoccao.javet.annotations.V8Convert
|
||||
import com.caoccao.javet.annotations.V8Function
|
||||
import com.caoccao.javet.annotations.V8Property
|
||||
@@ -10,9 +12,13 @@ import com.caoccao.javet.values.V8Value
|
||||
import com.caoccao.javet.values.primitive.V8ValueString
|
||||
import com.caoccao.javet.values.reference.V8ValueTypedArray
|
||||
import com.curlbind.Libcurl
|
||||
import com.futo.platformplayer.api.http.ManagedHttpClient
|
||||
import com.futo.platformplayer.api.media.platforms.js.SourcePluginConfig
|
||||
import com.futo.platformplayer.api.media.platforms.js.internal.JSHttpClient
|
||||
import com.futo.platformplayer.engine.IV8PluginConfig
|
||||
import com.futo.platformplayer.engine.V8Plugin
|
||||
import com.futo.platformplayer.engine.exceptions.ScriptException
|
||||
import com.futo.platformplayer.engine.exceptions.ScriptImplementationException
|
||||
import com.futo.platformplayer.engine.internal.IV8Convertable
|
||||
import com.futo.platformplayer.engine.internal.V8BindObject
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
@@ -43,8 +49,8 @@ class PackageHttpImp : V8Package {
|
||||
|
||||
constructor(plugin: V8Plugin, config: IV8PluginConfig) : super(plugin) {
|
||||
_config = config
|
||||
_packageClient = PackageHttpClient(this, withAuth = false)
|
||||
_packageClientAuth = PackageHttpClient(this, withAuth = true)
|
||||
_packageClient = PackageHttpClient(this, plugin.httpClient)
|
||||
_packageClientAuth = PackageHttpClient(this, plugin.httpClientAuth)
|
||||
}
|
||||
|
||||
fun cleanup() {
|
||||
@@ -95,7 +101,10 @@ class PackageHttpImp : V8Package {
|
||||
|
||||
@V8Function
|
||||
fun newClient(withAuth: Boolean): PackageHttpClient {
|
||||
val client = PackageHttpClient(this, withAuth)
|
||||
val httpClient = if(withAuth) _plugin.httpClientAuth.clone() else _plugin.httpClient.clone();
|
||||
if(httpClient is JSHttpClient)
|
||||
_plugin.registerHttpClient(httpClient);
|
||||
val client = PackageHttpClient(this, httpClient)
|
||||
client.clientId()?.let { _clients[it] = client }
|
||||
return client
|
||||
}
|
||||
@@ -672,9 +681,6 @@ class PackageHttpImp : V8Package {
|
||||
@Transient
|
||||
private val _package: PackageHttpImp
|
||||
|
||||
@Transient
|
||||
private val _withAuth: Boolean
|
||||
|
||||
val parentConfig: IV8PluginConfig
|
||||
get() = _package._config
|
||||
|
||||
@@ -686,44 +692,21 @@ class PackageHttpImp : V8Package {
|
||||
|
||||
@Volatile
|
||||
private var timeoutMs: Int = 30_000
|
||||
|
||||
@Volatile
|
||||
private var sendCookies: Boolean = true
|
||||
|
||||
@Volatile
|
||||
private var updateCookies: Boolean = true
|
||||
|
||||
@Volatile
|
||||
private var allowNewCookies: Boolean = true
|
||||
|
||||
@Volatile
|
||||
private var cookieJarPath: String? = null
|
||||
|
||||
@Volatile
|
||||
private var impersonateTarget: String = "chrome136"
|
||||
|
||||
@Volatile
|
||||
private var useBuiltInHeaders: Boolean = true
|
||||
|
||||
@Transient
|
||||
private val _client: ManagedHttpClient;
|
||||
|
||||
@V8Property
|
||||
fun clientId(): String? = _clientId
|
||||
|
||||
constructor(pack: PackageHttpImp, withAuth: Boolean) : super() {
|
||||
constructor(pack: PackageHttpImp, baseClient: ManagedHttpClient) : super() {
|
||||
_package = pack
|
||||
_withAuth = withAuth
|
||||
}
|
||||
|
||||
private fun ensureCookieJarPath(): String {
|
||||
val existing = cookieJarPath
|
||||
if (existing != null) return existing
|
||||
|
||||
val tmp = System.getProperty("java.io.tmpdir") ?: "/data/local/tmp"
|
||||
val safeName = parentConfig.name.replace(Regex("[^a-zA-Z0-9._-]"), "_")
|
||||
val fileName =
|
||||
if (_withAuth) "imphttp.$safeName.auth.cookies.txt" else "imphttp.$safeName.cookies.txt"
|
||||
val path = if (tmp.endsWith("/")) tmp + fileName else "$tmp/$fileName"
|
||||
cookieJarPath = path
|
||||
return path
|
||||
_client = baseClient
|
||||
}
|
||||
|
||||
@V8Function
|
||||
@@ -737,17 +720,18 @@ class PackageHttpImp : V8Package {
|
||||
|
||||
@V8Function
|
||||
fun setDoApplyCookies(apply: Boolean) {
|
||||
sendCookies = apply
|
||||
if(_client is JSHttpClient)
|
||||
_client.doApplyCookies = apply;
|
||||
}
|
||||
|
||||
@V8Function
|
||||
fun setDoUpdateCookies(update: Boolean) {
|
||||
updateCookies = update
|
||||
if(_client is JSHttpClient)
|
||||
_client.doUpdateCookies = update;
|
||||
}
|
||||
|
||||
@V8Function
|
||||
fun setDoAllowNewCookies(allow: Boolean) {
|
||||
allowNewCookies = allow
|
||||
if(_client is JSHttpClient)
|
||||
_client.doAllowNewCookies = allow;
|
||||
}
|
||||
|
||||
@V8Function
|
||||
@@ -1060,18 +1044,29 @@ class PackageHttpImp : V8Package {
|
||||
private fun performCurl(
|
||||
method: String,
|
||||
url: String,
|
||||
headers: Map<String, String>,
|
||||
hs: Map<String, String>, //TODO: Why is this not a Map<String, List<String>>
|
||||
bodyBytes: ByteArray?,
|
||||
impersonateTargetOverride: String? = null,
|
||||
useBuiltInHeadersOverride: Boolean? = null,
|
||||
timeoutMsOverride: Int? = null
|
||||
): Libcurl.Response {
|
||||
val jar = ensureCookieJarPath()
|
||||
val client = _client
|
||||
if (client is JSHttpClient) {
|
||||
if (!(client.config?.isUrlAllowed(url) ?: false)) {
|
||||
throw Exception( "Attempted to access non-whitelisted url: $url\nAdd it to your config");
|
||||
}
|
||||
}
|
||||
|
||||
val finalImpersonateTarget = impersonateTargetOverride ?: this.impersonateTarget
|
||||
val finalUseBuiltInHeaders = useBuiltInHeadersOverride ?: this.useBuiltInHeaders
|
||||
val finalTimeoutMs = timeoutMsOverride ?: this.timeoutMs
|
||||
|
||||
val uri = url.toUri()
|
||||
val headers = hs.toMutableMap()
|
||||
if (client is JSHttpClient) {
|
||||
client.applyHeaders(uri, headers, _client.isLoggedIn, true)
|
||||
}
|
||||
|
||||
val req = Libcurl.Request(
|
||||
url = url,
|
||||
method = method,
|
||||
@@ -1079,12 +1074,13 @@ class PackageHttpImp : V8Package {
|
||||
body = bodyBytes,
|
||||
impersonateTarget = finalImpersonateTarget,
|
||||
useBuiltInHeaders = finalUseBuiltInHeaders,
|
||||
timeoutMs = finalTimeoutMs,
|
||||
cookieJarPath = jar,
|
||||
sendCookies = sendCookies,
|
||||
persistCookies = updateCookies && allowNewCookies
|
||||
timeoutMs = finalTimeoutMs
|
||||
)
|
||||
return Libcurl.perform(req)
|
||||
val resp = Libcurl.perform(req)
|
||||
if (client is JSHttpClient) {
|
||||
client.processRequest(method, resp.status, uri, resp.headers)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
private fun executeRequest(
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.futo.platformplayer.activities.MainActivity
|
||||
import com.futo.platformplayer.fragment.mainactivity.main.MainFragment
|
||||
|
||||
open class MainActivityFragment : Fragment() {
|
||||
protected val currentMain : MainFragment
|
||||
protected val currentMain : MainFragment?
|
||||
get() {
|
||||
isValidMainActivity();
|
||||
return (activity as MainActivity).fragCurrent;
|
||||
|
||||
@@ -484,7 +484,8 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
||||
recyclerData.resultsUnfiltered.addAll(toAdd);
|
||||
recyclerData.adapter.notifyDataSetChanged();
|
||||
recyclerData.loadedFeedStyle = feedStyle;
|
||||
ensureEnoughContentVisible(filteredResults)
|
||||
if(pager.hasMorePages())
|
||||
ensureEnoughContentVisible(filteredResults)
|
||||
}
|
||||
|
||||
private fun detachPagerEvents() {
|
||||
|
||||
+3
-1
@@ -365,8 +365,10 @@ class HomeFragment : MainFragment() {
|
||||
finishRefreshLayoutLoader();
|
||||
setLoading(false);
|
||||
setPager(pager);
|
||||
if(pager.getResults().isEmpty() && !pager.hasMorePages())
|
||||
if(pager.getResults().isEmpty() && !pager.hasMorePages()) {
|
||||
setLoading(false);
|
||||
setEmptyPager(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user