Files
SpotiFLAC-Mobile/lib/utils/cover_art_utils.dart
T
zarzet 9580fafe4f feat(ui): add shared widgets, utils, and models for deduplicated screens
Single homes for logic that was copy-pasted across screens: the settings
collapsing header, album detail header (online screen's design as the
reference), selection pill button + bottom-bar chrome, disc separator
chip, error card, cover URL upgrade, byte/clock formatting, duration
extraction, UnifiedLibraryItem (moved out of the queue_tab library so
other screens can import it), and the batch convert/ReplayGain engine
keyed on it.
2026-07-11 16:34:16 +07:00

23 lines
774 B
Dart

/// Deezer CDN cover size pattern: /WxH-q-p-o-n.jpg
final RegExp _deezerCoverSizeRegex = RegExp(
r'/(\d+)x(\d+)-(\d+)-(\d+)-(\d+)-(\d+)\.jpg$',
);
/// Upgrades a Spotify/Deezer cover URL to a display-quality resolution
/// (Spotify 300px → 640px, Deezer → 1000x1000 preserving quality params).
/// Non-matching URLs pass through unchanged.
String? highResCoverUrl(String? url) {
if (url == null) return null;
if (url.contains('ab67616d00001e02')) {
return url.replaceAll('ab67616d00001e02', 'ab67616d0000b273');
}
if (url.contains('cdn-images.dzcdn.net') &&
_deezerCoverSizeRegex.hasMatch(url)) {
return url.replaceAllMapped(
_deezerCoverSizeRegex,
(m) => '/1000x1000-${m[3]}-${m[4]}-${m[5]}-${m[6]}.jpg',
);
}
return url;
}