fix(jellyfin): Add defensive checks for missing audio metadata (#2728)
* fix(jellyfin): Add defensive checks for missing audio metadata
Fixes KeyError when Jellyfin MediaStreamInfos are missing Channels field.
Changes:
- Handle empty MediaStreams arrays gracefully
- Use .get() with defaults for Channels (stereo) and codec
- Maintain consistency with existing SampleRate/BitDepth patterns
This prevents crashes on libraries with incomplete Jellyfin metadata
while using sensible defaults (2 channels, CD quality assumed).
Closes music-assistant/support#4447
* fix: Remove trailing whitespace and add test coverage
- Fix Ruff linting errors (blank lines with whitespace)
- Add test for empty MediaStreams array edge case
- Add test for missing Channels field with default value
- Addresses review feedback on PR #2728
* fix: Move test imports to top of file
Move inline imports from test functions to module level to comply
with linter requirements and improve code organization.
* Update tests/providers/jellyfin/test_parsers.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* test: add edge case coverage for audio_format
- Add test for empty MediaStreams array
- Add test for missing Channels field
- Ensure defensive checks prevent IndexError and KeyError
* fix: remove invalid ContentType import and correct bit_rate assertion
- Remove import from non-existent music_assistant.common.models.enums module
- Update test assertions to verify result structure without ContentType enum
- Fix bit_rate assertion to expect kbps (320) instead of bps (320000)
AudioFormat model automatically converts bps to kbps in __post_init__
- Fixes ModuleNotFoundError in CI test runs
* test: clean jellyfin parser tests
- remove unused JellyTrack import
- avoid runtime casts; use typed dict literals
- ignore arg-type warnings for dict track fixtures
---------
Co-authored-by: Marvin Schenkel <marvinschenkel@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>