Skip to content

Jellyfin search returns folders alongside audiobooks with the same name #1502

@matalvernaz

Description

@matalvernaz

Bug

When searching in the Jellyfin integration, results include both folders and the audiobooks inside them when they share the same name. For example, searching "Harry Potter" returns the folder and the audiobook, when only the audiobook should appear.

This is Jellyfin-specific — AudiobookShelf uses a dedicated /search endpoint that only returns books, so it's not affected.

Expected Behavior

Search results should only return audiobooks, not navigable folders. Folders are useful when browsing a library, but not when searching by name.

Root Cause

In JellyfinConnectionService.swift, the fetchItems method determines which item types to include based only on the recursive flag:

let itemTypes: [JellyfinAPI.BaseItemKind] = recursive ? [.audioBook] : [.audioBook, .folder]

When a search term is provided, isRecursive is set to true (line above), but itemTypes still checks the original recursive parameter — which is false for search calls. This means folders are included in search results.

Proposed Fix

let itemTypes: [JellyfinAPI.BaseItemKind] = (recursive || searchTerm != nil) ? [.audioBook] : [.audioBook, .folder]

This filters out folders when searching while preserving them for normal folder-level browsing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions