Skip to content
Viren070 edited this page Nov 3, 2025 · 18 revisions

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 and waiting for them all to respond.

How It Works: The Basics

  1. Parallel Fetch Start: AIOStreams begins fetching from all groups at once.
  2. Evaluate as Results Arrive:
    • As soon as Group 1 responds, AIOStreams immediately checks Group 2’s Condition.
    • If the Condition is false, AIOStreams ignores any pending results from Group 2 (and beyond) and exits early.
    • If the Condition is true, AIOStreams will include Group 2’s results once they arrive and then check Group 3’s Condition, and so on.
  3. Early Exit: The moment a group's Condition evaluates to false, all subsequent groups (those whose results are still pending) are skipped—no waiting or processing.
  4. Final Results: You’ll receive results only from Group 1 and any later groups whose Conditions were met before an early exit occurred.

Example:

  • AIOStreams fires off fetches for Group 1, Group 2, Group 3 concurrently.
  • Group 1 returns 3 streams → check “Group 2 Condition.”
  • If you’ve set Group 2 to “only run if Group 1 found fewer than 5 streams” and that Condition is false, AIOStreams ignores Group 2 and Group 3 entirely and returns just Group 1’s results immediately.
  • If the Condition is true, AIOStreams waits for Group 2 to finish and includes their streams as they arrive. The process then repeats as Group 3's condition is evaluated, until either all groups get processed, or an early exit occurs.

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", "anime.series", "anime.movie").
  • 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:

  1. Group 2: Run if Group 1 found less than 3 streams.

    • Condition: count(previousStreams) < 3
  2. Group 2: Run if Group 1 found NO cached Real-Debrid streams.

    • Condition: count(cached(service(previousStreams, 'realdebrid'))) == 0
  3. 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
  4. 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, '2160p')) == 0 or previousGroupTimeTaken > 5000

Tips for Success:

  • Aim for True/False: Always double-check that your condition will end up as true or false.
  • Start Simple: Begin with basic count() conditions and test them.
  • previousStreams vs. totalStreams: Use previousStreams for logic based on the immediately preceding group. Use totalStreams for logic based on everything found so far.
  • Errors? If a condition is written incorrectly, the group (and subsequent groups) will be skipped.

Clone this wiki locally