Groups - Viren070/AIOStreams GitHub Wiki
Using Groups to Control Stream Fetching
The Grouping feature in AIOStreams lets you control when different sets of your addons are asked for streams. This is great for making AIOStreams faster and smarter about finding what you want.
Why use Grouping?
- Make your favorite or fastest addons search first.
- Only use backup or slower addons if your main ones don't find enough streams.
- Speed up results by not always asking all your addons for streams at once.
How It Works: The Basics
- Group 1 Always Runs: Addons in your first group ("Group 1") will always search for streams.
- Other Groups Need a "Go Ahead": For Group 2, Group 3, and so on, you set a Condition.
- Condition Check: Before searching a group (like Group 2), AIOStreams checks its Condition.
- If the Condition is
true
: The addons in that group will search. - If the Condition is
false
: That group and all subsequent groups are skipped.
- If the Condition is
- Step-by-Step: This happens for each group in order. If a group's condition is false, no further groups are processed.
Example: You can tell Group 2, "Only search if Group 1 found less than 5 streams." If this condition is met, Group 2 runs. If not, Group 2 (and any Group 3, 4, etc.) will be skipped.
Building Group Conditions
To make a group run, you must write a condition that results in a true
value. To skip a group, the condition must result in false
.
You build these conditions using the Stream Expression Language (SEL).
Key Ingredients for Group Conditions:
1. Constants (Information available to you):
previousStreams
: List of streams found by the last group that ran.totalStreams
: List of all streams found by all groups that have run so far.queryType
: What you're searching for (e.g.,"movie"
,"series"
).previousGroupTimeTaken
: How long the last group took (in milliseconds).totalTimeTaken
: Total time spent so far (in milliseconds).
2. Functions (Tools to check streams):
Functions help you filter and count streams to get the information you need. The most important function for group conditions is count()
, which tells you how many streams are in a list. You use this to compare against a number.
For example, count(cached(previousStreams))
gives you the number of cached streams from the last group. You can then compare this: count(cached(previousStreams)) > 0
. This results in a true/false value.
For a complete list of all available functions like
cached()
,resolution()
,service()
, and more, please see the full Stream Expression Language.
Quick Examples:
-
Group 2: Run if Group 1 found less than 3 streams.
- Condition:
count(previousStreams) < 3
- Condition:
-
Group 2: Run if Group 1 found NO cached Real-Debrid streams.
- Condition:
count(cached(service(previousStreams, 'realdebrid'))) == 0
- Condition:
-
Group 3: Run if searching for a "series" AND all previous groups combined found fewer than 2 1080p streams.
- Condition:
queryType == "series" and count(resolution(totalStreams, '1080p')) < 2
- Condition:
-
Group 2: Run if Group 1 found no 4K streams OR if it took Group 1 longer than 5 seconds (5000ms).
- Condition:
count(resolution(previousStreams, '4k')) == 0 or previousGroupTimeTaken > 5000
- Condition:
Tips for Success:
- Aim for True/False: Always double-check that your condition will end up as
true
orfalse
. - Start Simple: Begin with basic
count()
conditions and test them. previousStreams
vs.totalStreams
: UsepreviousStreams
for logic based on the immediately preceding group. UsetotalStreams
for logic based on everything found so far.- Errors? If a condition is written incorrectly, the group (and subsequent groups) will be skipped.