Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
fix: an album's animated cover starts at once on a second visit, even after a relaunch
My-Name-Is-Jeff5b066fd614a6
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex af4c21d0..ae9e4dda 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -137,7 +137,7 @@ Shared:system's now playing through this hook and Player/NowPlayingExtras.x is checked by harness/now-playing/AnimatedArtwork/ moving artwork (AnimatedArtwork.h): the track's Canvas, else Apple Music's animated album cover(SGMotionCatalog.m: searched without the album's edition, the edition of the same name first, and- left alone for 10 minutes after a 403 or 429), kept as local files (SGMotionStore.m, a download that+ left alone for 10 minutes after a 403 or 429; an album's answer kept on disk for a week, so a relaunch skips the search), kept as local files (SGMotionStore.m, a download thatfails on the way tried once more), on iOS 26 the lock screen's full-screenartwork (LockScreenMotion.x). With Every song, a song with neither gets its cover over copies of itblurred and swaying, a seamless 8 s 3:4 loop drawn on the CPU only when the lock screen asks for itdiff --git a/tweak/Sources/Redesigned/Album/AlbumHeader.x b/tweak/Sources/Redesigned/Album/AlbumHeader.xindex b0d91c9f..8c54429a 100644--- a/tweak/Sources/Redesigned/Album/AlbumHeader.x+++ b/tweak/Sources/Redesigned/Album/AlbumHeader.x@@ -224,6 +224,8 @@ static void *kReadyContext = &kReadyContext;_player = [AVQueuePlayer new];_player.muted = YES;_player.preventsDisplaySleepDuringVideoPlayback = NO;+ // A file on the phone: nothing to buffer against, so it starts as soon as it can.+ _player.automaticallyWaitsToMinimizeStalling = NO;_looper = [AVPlayerLooper playerLooperWithPlayer:_player templateItem:item];[self sgr_dropMotion];_motion = [AVPlayerLayer playerLayerWithPlayer:_player];@@ -252,7 +254,8 @@ static void *kReadyContext = &kReadyContext;dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf sgr_fadeInMotion:object]; });}-// Once, when the clip has a frame to show: eased out, over the Kit's crossfade, on screen; at once off it.+// Once, when the clip has a frame to show: over 0.2 s on a curve most of the way there at once (the Kit's response,+// an entrance being quick), on screen; at once off it.- (void)sgr_fadeInMotion:(AVPlayerLayer *)layer {if (layer != _motion || !layer.readyForDisplay || layer.opacity == 1) return;[CATransaction begin];@@ -262,8 +265,8 @@ static void *kReadyContext = &kReadyContext;CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];fade.fromValue = @0;fade.toValue = @1;- fade.duration = SGRCrossfade;- fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];+ fade.duration = 0.2;+ fade.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.23 :1 :0.32 :1];[layer addAnimation:fade forKey:@"fade"];}[CATransaction commit];diff --git a/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.m b/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.mindex fb9634de..4997992d 100644--- a/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.m+++ b/tweak/Sources/Shared/AnimatedArtwork/SGMotionCatalog.m@@ -1,6 +1,6 @@// Animated album covers, artist logos and songs by ISRC from Apple Music's catalog. The catalog takes the developer// token Apple Music's web player carries, so the token is read out of the web player's script and-// kept until it is about to expire. Answers are kept for the launch.+// kept until it is about to expire. Answers are kept for the launch, and an album's for a week on disk.#import "Core/SGCore.h"#import "AnimatedArtwork.h"@@ -17,10 +17,39 @@ static NSMutableDictionary<NSString *, id> *sg_kept;static NSMutableDictionary<NSString *, NSMutableArray *> *sg_waiting;static NSMutableArray<void (^)(NSString *)> *sg_tokenWaiting;+// An album's answer, its clip's address or that it has none, kept on disk so that an album opened before starts at+// once after a relaunch, without the token and the search. Older answers are asked again.+static const NSTimeInterval kAlbumAnswerLife = 7 * 24 * 3600;++static NSURL *albumAnswersFile(void) {+ NSURL *caches = [NSFileManager.defaultManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask].firstObject;+ return [caches URLByAppendingPathComponent:@"Vitrine/Motion/album answers.plist"];+}++// Key to {url: the address, "" for none; at: when it was asked}.+static NSMutableDictionary<NSString *, NSDictionary *> *sg_albumAnswers;++static void keepAlbumAnswer(NSString *key, NSURL *remote) {+ sg_albumAnswers[key] = @{@"url": remote.absoluteString ?: @"", @"at": NSDate.date};+ NSURL *file = albumAnswersFile();+ [NSFileManager.defaultManager createDirectoryAtURL:file.URLByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:nil];+ [sg_albumAnswers writeToURL:file atomically:YES];+}+static void setUp(void) {static dispatch_once_t once;dispatch_once(&once, ^{sg_kept = [NSMutableDictionary dictionary];+ sg_albumAnswers = [NSMutableDictionary dictionary];+ NSDictionary *stored = [NSDictionary dictionaryWithContentsOfURL:albumAnswersFile()];+ for (NSString *key in stored) {+ NSDictionary *answer = stored[key];+ NSDate *at = [answer isKindOfClass:NSDictionary.class] ? answer[@"at"] : nil;+ NSString *url = [at isKindOfClass:NSDate.class] ? answer[@"url"] : nil;+ if (![url isKindOfClass:NSString.class] || -at.timeIntervalSinceNow > kAlbumAnswerLife) continue;+ sg_albumAnswers[key] = answer;+ sg_kept[key] = url.length ? ([NSURL URLWithString:url] ?: NSNull.null) : NSNull.null;+ }sg_waiting = [NSMutableDictionary dictionary];sg_tokenWaiting = [NSMutableArray array];});@@ -305,6 +334,7 @@ static void lookUp(NSString *key, void (^done)(id value), void (^look)(void (^ansg_waiting[key] = [NSMutableArray arrayWithObject:[done copy]];look(^(id value, BOOL keep) {if (keep) sg_kept[key] = value ?: NSNull.null;+ if (keep && [key hasPrefix:@"album\n"] && (!value || [value isKindOfClass:NSURL.class])) keepAlbumAnswer(key, value);NSArray *callers = sg_waiting[key];[sg_waiting removeObjectForKey:key];for (void (^caller)(id) in callers) caller(value);