Skip to content

feat(sel): add multiEpisode filter function#798

Open
raabot wants to merge 1 commit intoViren070:mainfrom
raabot:feat/multi-episode-sel-function
Open

feat(sel): add multiEpisode filter function#798
raabot wants to merge 1 commit intoViren070:mainfrom
raabot:feat/multi-episode-sel-function

Conversation

@raabot
Copy link

@raabot raabot commented Mar 9, 2026

Summary

  • Adds a new SEL function multiEpisode(streams, minEpisodes?) that filters streams based on parsedFile.episodes.length
  • Enables users to exclude multi-episode packs (e.g. S01E01-E08) while keeping single episode results — including single episodes selected from cached season pack folders
  • Default threshold is 2 episodes; configurable via optional second parameter

Motivation

The existing seasonPack function can't cleanly distinguish multi-episode files from single episodes:

  • seasonPack(streams, 'onlySeasons') only catches packs with no episode info (e.g. "S01") — misses packs like "S01E01-E08" where episodes are parsed
  • seasonPack(streams, 'seasonPack') is too aggressive — also excludes single episodes selected from cached season pack folders (via the folderSize > size * 2 heuristic)

multiEpisode fills this gap by checking the episodes array length directly.

Usage

In excluded stream expressions:

multiEpisode(streams)        — excludes streams with 2+ episodes
multiEpisode(streams, 3)     — excludes streams with 3+ episodes

Combined with seasonPack(streams, 'onlySeasons'), this covers all season pack variants:

Stream type seasonPack('onlySeasons') multiEpisode
Pure season pack "S01" (no episodes) ✅ caught
Multi-episode pack "S01E01-E08" ❌ missed ✅ caught
Single episode "S01E01" ✅ kept
Single episode from cached pack folder ✅ kept

Test plan

  • Verify multiEpisode(streams) returns streams with parsedFile.episodes.length >= 2
  • Verify multiEpisode(streams, 3) respects custom threshold
  • Verify single-episode streams are not matched
  • Verify error handling for invalid inputs

Summary by CodeRabbit

Release Notes

  • New Features
    • Added stream filtering capability that allows filtering streams based on a minimum episode count requirement, with a default threshold of 2 episodes.

Adds a new SEL function `multiEpisode(streams, minEpisodes?)` that
filters streams based on the number of parsed episodes. This enables
users to exclude multi-episode packs (e.g. S01E01-E08) while keeping
single episode results, including those selected from cached season
pack folders.

The existing `seasonPack` function cannot distinguish between a single
episode selected from a pack and a multi-episode file, since
`onlySeasons` mode only catches packs with no episode info, and
`seasonPack` mode is too aggressive (also excludes single files from
pack folders). `multiEpisode` fills this gap by checking
`parsedFile.episodes.length` directly.

Usage in excluded stream expressions:
  multiEpisode(streams)       — excludes streams with 2+ episodes
  multiEpisode(streams, 3)    — excludes streams with 3+ episodes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d06f5872-9797-4db7-914c-f3d4275ac760

📥 Commits

Reviewing files that changed from the base of the PR and between 91391c8 and 5e4bdfa.

📒 Files selected for processing (1)
  • packages/core/src/parser/streamExpression.ts

Walkthrough

A new multiEpisode parser function is added to StreamExpressionEngine that filters an array of streams based on a minimum episode count threshold, with input validation for both the streams array and the minimum episodes parameter.

Changes

Cohort / File(s) Summary
Stream Expression Parser Enhancement
packages/core/src/parser/streamExpression.ts
Added multiEpisode method to StreamExpressionEngine that accepts an array of parsed streams and a minimum episode count (default: 2), returning only streams meeting the episode threshold. Includes input validation for array and numeric constraints.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A filter for streams, so clever and neat,
Multi-episodes bundled, a filtering feat!
With validation in place, we hop with delight,
Streams of the worthy, filtered just right! 🎬✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a new multiEpisode filter function to the SEL parser. It is concise, specific, and directly corresponds to the primary modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant