mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
feat: add allAddons variable to dynamic exit condition and add placeholder exit conditions
This commit is contained in:
@@ -615,13 +615,15 @@ export class ExitConditionEvaluator extends StreamExpressionEngine {
|
||||
private totalStreams: ParsedStream[],
|
||||
private totalTimeTaken: number,
|
||||
private queryType: string,
|
||||
private queriedAddons: string[]
|
||||
private queriedAddons: string[],
|
||||
private allAddons: string[]
|
||||
) {
|
||||
super();
|
||||
this.parser.consts.totalStreams = this.totalStreams;
|
||||
this.parser.consts.totalTimeTaken = this.totalTimeTaken;
|
||||
this.parser.consts.queryType = this.queryType;
|
||||
this.parser.consts.queriedAddons = this.queriedAddons;
|
||||
this.parser.consts.allAddons = this.allAddons;
|
||||
}
|
||||
|
||||
async evaluate(condition: string) {
|
||||
@@ -629,7 +631,13 @@ export class ExitConditionEvaluator extends StreamExpressionEngine {
|
||||
}
|
||||
|
||||
static async testEvaluate(condition: string) {
|
||||
const parser = new ExitConditionEvaluator([], 200, 'movie', ['Test Addon']);
|
||||
const parser = new ExitConditionEvaluator(
|
||||
[],
|
||||
200,
|
||||
'movie',
|
||||
['Test Addon'],
|
||||
['Test Addon']
|
||||
);
|
||||
return await parser.evaluate(condition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,9 @@ class StreamFetcher {
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
const queriedAddons: string[] = [];
|
||||
const allAddons: string[] = Array.from(
|
||||
new Set(addons.map((addon) => addon.name))
|
||||
);
|
||||
const presetProgress = addons.reduce(
|
||||
(acc, addon) => {
|
||||
const id = addon.preset.id;
|
||||
@@ -227,7 +230,8 @@ class StreamFetcher {
|
||||
allStreams,
|
||||
timeTaken,
|
||||
queryType,
|
||||
queriedAddons
|
||||
queriedAddons,
|
||||
allAddons
|
||||
);
|
||||
|
||||
const shouldExit = await evaluator.evaluate(condition);
|
||||
|
||||
@@ -1261,6 +1261,15 @@ function AddonFetchingBehaviorCard() {
|
||||
'All addons start fetching at the same time. As soon as any addon returns results, the exit condition is evaluated. If the condition is met, results are returned immediately and any remaining addon results are ignored.',
|
||||
};
|
||||
|
||||
const placeholderExitConditions = [
|
||||
'count(resolution(totalStreams, "2160p")) > 0 or totalTimeTaken > 5000',
|
||||
"queryType == 'anime' ? (count(resolution(totalStreams, '1080p')) > 0 or totalTimeTaken > 5000) : false",
|
||||
"'addon' in queriedAddons and (totalTimeTaken >= 6000 or count(totalStreams) >= 5)",
|
||||
"count(seeders(size(totalStreams, '5GB', '20GB'), 50)) > 0",
|
||||
"queryType == 'movie' ? count(cached(resolution(totalStreams, '2160p'))) > 0 : count(resolution(totalStreams, '1080p')) >= 2",
|
||||
"count(cached(quality(totalStreams, 'Bluray REMUX', 'Bluray', 'WEB-DL'))) > 0",
|
||||
];
|
||||
|
||||
return (
|
||||
<SettingsCard
|
||||
title="Addon Fetching Strategy"
|
||||
@@ -1382,6 +1391,11 @@ function AddonFetchingBehaviorCard() {
|
||||
{mode === 'dynamic' && (
|
||||
<TextInput
|
||||
label="Exit Condition"
|
||||
placeholder={
|
||||
placeholderExitConditions[
|
||||
Math.floor(Math.random() * placeholderExitConditions.length)
|
||||
]
|
||||
}
|
||||
value={userData.dynamicAddonFetching?.condition ?? ''}
|
||||
onValueChange={(value) => {
|
||||
setUserData((prev) => ({
|
||||
@@ -1421,6 +1435,10 @@ function AddonFetchingBehaviorCard() {
|
||||
Tip: use the <code>in</code> operator to check if a specific
|
||||
addon has been queried.
|
||||
</li>
|
||||
<li>
|
||||
<code>allAddons</code>: All addons that were intended to be
|
||||
used for that query.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user