From db6d5cadd9fa466769005792f1b809d195200364 Mon Sep 17 00:00:00 2001 From: Bryce Kehoe Date: Fri, 1 May 2026 02:16:40 +0100 Subject: [PATCH] fix(media): uppercase named resolution labels Display non-numeric Plex resolution labels in uppercase while preserving p suffixes for numeric heights. --- lib/media/media_version.dart | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/media/media_version.dart b/lib/media/media_version.dart index 0eaf41c2..bfd45ee2 100644 --- a/lib/media/media_version.dart +++ b/lib/media/media_version.dart @@ -8,14 +8,12 @@ int? bitrateKbpsFromBps(int? bps) { return (bps / 1000).round(); } -final _videoResolution = RegExp(r'^(\d+)(k?)$', caseSensitive: false); +final _numericVideoResolution = RegExp(r'^\d+$'); -/// Plex uses numeric heights for SD/HD and values like `4k`/`8k` for UHD+. +/// Plex may return numeric heights (`1080`) or named resolution labels (`sd`, `4k`). String _videoResolutionDisplayLabel(String resolution) { final value = resolution.trim(); - final match = _videoResolution.firstMatch(value); - if (match == null) return value; - return match.group(2)!.isEmpty ? '${match.group(1)}p' : '${match.group(1)}K'; + return _numericVideoResolution.hasMatch(value) ? '${value}p' : value.toUpperCase(); } /// A single media variant available for an item — represents one quality level