Skip to content

Fix native search container expansion - #220

Merged
Nikorag merged 4 commits into
Nikorag:mainfrom
matt20013:fix/native-search-series-expansion
Apr 22, 2026
Merged

Fix native search container expansion#220
Nikorag merged 4 commits into
Nikorag:mainfrom
matt20013:fix/native-search-series-expansion

Conversation

@matt20013

Copy link
Copy Markdown
Contributor

Summary

  • expand native-search results when the search hit resolves to a series or brand container PID, not only when brand resolution succeeds
  • include direct and nested episode expansion for container hits, then dedupe by PID to avoid duplicate releases
  • preserve existing behavior for standard brand expansion and one-off PID fallback while improving episode-level results for edge-case shows

Verification

  • local verification script against this patch returns episode-level results for Smiley's People (S0E1..S0E6)
  • The Mrs Merton Show still returns expanded episode results under native search
  • TypeScript backend compiles successfully (npm run build:backend)

Context

This addresses cases where native search returns container-level matches but fails to expand to episode-level items needed by Sonarr.

Expand episode results when native search hits series or brand containers so Sonarr receives episode-level results instead of container-only matches.

Made-with: Cursor
@matt20013

Copy link
Copy Markdown
Contributor Author

Linking related bug report: #219

I checked this issue and it looks to be the same native-search container expansion path this PR fixes.

}
}

async #expandEpisodesFromContainer(containerPid: string): Promise<IPlayerEpisodeMetadata[]> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests.

episodes.push(...seriesList.filter(({ type, release_date_time }) => type == 'episode' && release_date_time != null));

const searchHitMetadata = await iplayerDetailsService.getMetadata(ref);
const fallbackContainerPid = searchHitMetadata.programme.type == 'series' || searchHitMetadata.programme.type == 'brand'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing tests failing, missing programme - might be this bit here. Either way, existing tests need updating.

- Mock iPlayer metadata programme.type for native search tests to match new getMetadata usage.
- Add coverage for container fallback expansion when brand PID lookup fails.
- Add coverage for nested container episode expansion and PID deduping.
@Nikorag
Nikorag merged commit 3ca7da8 into Nikorag:main Apr 22, 2026
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.

4 participants