mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Primary claim support, fix sub for clients without type
This commit is contained in:
parent
570f32e980
commit
7eef6eece2
10 changed files with 17 additions and 12 deletions
|
@ -584,7 +584,7 @@ open class JSClient : IPlatformClient {
|
|||
if(it.containsKey(claimType)) {
|
||||
val templates = it[claimType];
|
||||
if(templates != null)
|
||||
for(value in values.keys.sortedBy { it }) {
|
||||
for(value in values.keys.sortedBy { if(it == config.primaryClaimFieldType) Int.MIN_VALUE else it }) {
|
||||
if(templates.containsKey(value)) {
|
||||
return templates[value]!!.replace("{{CLAIMVALUE}}", values[value]!!);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ class SourcePluginConfig(
|
|||
var subscriptionRateLimit: Int? = null,
|
||||
var enableInSearch: Boolean = true,
|
||||
var enableInHome: Boolean = true,
|
||||
var supportedClaimTypes: List<Int> = listOf()
|
||||
var supportedClaimTypes: List<Int> = listOf(),
|
||||
var primaryClaimFieldType: Int? = null
|
||||
) : IV8PluginConfig {
|
||||
|
||||
val absoluteIconUrl: String? get() = resolveAbsoluteUrl(iconUrl, sourceUrl);
|
||||
|
|
|
@ -178,7 +178,7 @@ class SubscriptionsFeedFragment : MainFragment() {
|
|||
val subRequestCounts = StateSubscriptions.instance.getSubscriptionRequestCount();
|
||||
val reqCountStr = subRequestCounts.map { " ${it.key.config.name}: ${it.value}/${it.key.getSubscriptionRateLimit()}" }.joinToString("\n");
|
||||
val rateLimitPlugins = subRequestCounts.filter { clientCount -> clientCount.key.getSubscriptionRateLimit()?.let { rateLimit -> clientCount.value > rateLimit } == true }
|
||||
Logger.w(TAG, "Refreshing subscriptions with requests:\n" + reqCountStr);
|
||||
Logger.w(TAG, "Trying to refreshing subscriptions with requests:\n" + reqCountStr);
|
||||
if(rateLimitPlugins.any())
|
||||
throw RateLimitException(rateLimitPlugins.map { it.key.id });
|
||||
}
|
||||
|
|
|
@ -407,8 +407,9 @@ class StatePlatform {
|
|||
return@async searchResult;
|
||||
} catch(ex: Throwable) {
|
||||
Logger.e(TAG, "getHomeRefresh", ex);
|
||||
throw ex;
|
||||
//throw ex;
|
||||
//return@async null;
|
||||
return@async PlaceholderPager(10, { PlatformContentPlaceholder(it.id, ex) });
|
||||
}
|
||||
});
|
||||
}.toList();
|
||||
|
|
|
@ -144,14 +144,15 @@ class StatePolycentric {
|
|||
return DedupContentPager(pager, StatePlatform.instance.getEnabledClients().map { it.id });
|
||||
}
|
||||
|
||||
fun getChannelUrls(url: String, channelId: PlatformID? = null): List<String> {
|
||||
fun getChannelUrls(url: String, channelId: PlatformID? = null, cacheOnly: Boolean = false): List<String> {
|
||||
|
||||
var polycentricProfile: PolycentricProfile? = null;
|
||||
try {
|
||||
polycentricProfile = PolycentricCache.instance.getCachedProfile(url)?.profile;
|
||||
if (polycentricProfile == null && channelId != null) {
|
||||
Logger.i("StateSubscriptions", "Get polycentric profile not cached");
|
||||
polycentricProfile = runBlocking { PolycentricCache.instance.getProfileAsync(channelId) }?.profile;
|
||||
if(!cacheOnly)
|
||||
polycentricProfile = runBlocking { PolycentricCache.instance.getProfileAsync(channelId) }?.profile;
|
||||
} else {
|
||||
Logger.i("StateSubscriptions", "Get polycentric profile cached");
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ class StateSubscriptions {
|
|||
|
||||
fun getSubscriptionRequestCount(): Map<JSClient, Int> {
|
||||
return SubscriptionFetchAlgorithm.getAlgorithm(_algorithmSubscriptions, StateApp.instance.scope)
|
||||
.countRequests(getSubscriptions());
|
||||
.countRequests(getSubscriptions().associateWith { StatePolycentric.instance.getChannelUrls(it.channel.url, it.channel.id, true) });
|
||||
}
|
||||
|
||||
fun getSubscriptionsFeedWithExceptions(allowFailure: Boolean = false, withCacheFallback: Boolean = false, cacheScope: CoroutineScope, onProgress: ((Int, Int)->Unit)? = null, onNewCacheHit: ((Subscription, IPlatformContent)->Unit)? = null): Pair<IPager<IPlatformContent>, List<Throwable>> {
|
||||
|
|
|
@ -33,7 +33,7 @@ class SmartSubscriptionAlgorithm(
|
|||
val client = it.value!! as JSClient;
|
||||
val capabilities = client.getChannelCapabilities();
|
||||
|
||||
if(capabilities.hasType(ResultCapabilities.TYPE_MIXED))
|
||||
if(capabilities.hasType(ResultCapabilities.TYPE_MIXED) || capabilities.types.isEmpty())
|
||||
return@flatMap listOf(SubscriptionTask(client, sub, it.key, ResultCapabilities.TYPE_MIXED));
|
||||
else {
|
||||
val types = listOf(
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.futo.platformplayer.engine.exceptions.ScriptCaptchaRequiredException
|
|||
import com.futo.platformplayer.engine.exceptions.ScriptCriticalException
|
||||
import com.futo.platformplayer.exceptions.ChannelException
|
||||
import com.futo.platformplayer.findNonRuntimeException
|
||||
import com.futo.platformplayer.fragment.mainactivity.main.SubscriptionsFeedFragment
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
import com.futo.platformplayer.models.Subscription
|
||||
import com.futo.platformplayer.states.StatePlatform
|
||||
|
@ -46,9 +47,10 @@ abstract class SubscriptionsTaskFetchAlgorithm(
|
|||
val tasksGrouped = tasks.groupBy { it.client }
|
||||
val taskCount = tasks.filter { !it.fromCache }.size;
|
||||
val cacheCount = tasks.size - taskCount;
|
||||
|
||||
Logger.i(TAG, "Starting Subscriptions Fetch:\n" +
|
||||
" Tasks: ${taskCount}\n" +
|
||||
" Cached: ${cacheCount}");
|
||||
tasksGrouped.map { " ${it.key.name}: ${it.value.count { !it.fromCache }}, Cached(${it.value.count { it.fromCache } })" }.joinToString("\n"));
|
||||
|
||||
try {
|
||||
for(clientTasks in tasksGrouped) {
|
||||
val clientTaskCount = clientTasks.value.filter { !it.fromCache }.size;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 948835fa682b6e536bf05f66b426144ef5b47e69
|
||||
Subproject commit b6db44bf3ba2825fca9b86c3867204467cfb334f
|
|
@ -1 +1 @@
|
|||
Subproject commit ae803c9295cf3d53aa49ddc2799d0f86aecc06a6
|
||||
Subproject commit fca0ba3d5ae20baf0586cfea1f716ef4bc00c2f7
|
Loading…
Add table
Reference in a new issue