fix(media): uppercase named resolution labels
Display non-numeric Plex resolution labels in uppercase while preserving p suffixes for numeric heights.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user