mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-19 00:02:15 +02:00
fix(cover): preserve provider high-resolution artwork
This commit is contained in:
@@ -3,8 +3,9 @@ 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).
|
||||
/// Upgrades a Spotify/Deezer cover URL to a display-quality resolution.
|
||||
/// Existing Deezer URLs at or above 1000px are preserved so provider
|
||||
/// extensions can supply higher-resolution artwork without being downgraded.
|
||||
/// Non-matching URLs pass through unchanged.
|
||||
String? highResCoverUrl(String? url) {
|
||||
if (url == null) return null;
|
||||
@@ -13,10 +14,12 @@ String? highResCoverUrl(String? url) {
|
||||
}
|
||||
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.replaceAllMapped(_deezerCoverSizeRegex, (m) {
|
||||
final width = int.tryParse(m[1] ?? '') ?? 0;
|
||||
final height = int.tryParse(m[2] ?? '') ?? 0;
|
||||
if (width >= 1000 && height >= 1000) return m[0]!;
|
||||
return '/1000x1000-${m[3]}-${m[4]}-${m[5]}-${m[6]}.jpg';
|
||||
});
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user