Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: lyrics from Musixmatch, with word timing from NetEase
Vojtěch Škopekf640a2fd180b
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 4435aa14..071f369b 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -47,6 +47,9 @@ app:ArtistBlock/ tracks by blocked artists skipped as they start (ArtistSkip.x), the list and the Blocked artists page under PlayerKaraoke/ Apple Music style lyrics on the full screen page: lines read from color-lyrics and the player's clock (KaraokeSource.x),words timed by estimate inside Spotify's line times (KaraokeTiming.m), drawn by KaraokeView.m over the page (KaraokePage.x)+ Musixmatch/ lyrics from Musixmatch with an anonymous token (Musixmatch.m), word timed where it has richsync; color-lyrics+ answered with them and has_lyrics forced for every track (MusixmatchLyrics.x); word timing from NetEase's yrc+ for the karaoke page when Musixmatch has none (NetEase.m); rows on the Lyrics pageOnboarding/ the welcome tour over Home on the first launch (Onboarding.x, the pages in Tour.m), offered again from the Mod pageAbout/ the update check and the Mod page: the build, its updates, the links and the reset@@ -77,8 +80,8 @@ one page, the mod's own rows first and Spotify's flags below them or on a sub pathey change. It opens on the Appearance card, the three switches that style the whole app: LiquidGlass UI, AMOLED and the accent colour (Spotify's green is offered from the colour row once a colouris set). Then a card of parts. Navbar: the glass tab bar and search field, then the tab editor.-Player: Gestures, Lyrics (Apple Music style, glass lyrics, hiding the lyrics card and preview, the-lyrics flags), Blocked artists (with the count on the row) and Now playing bar (its glass, its device+Player: Gestures, Lyrics (Apple Music style, glass lyrics, lyrics from Musixmatch and for every track,+hiding the lyrics card and preview, the lyrics flags), Blocked artists (with the count on the row) and Now playing bar (its glass, its devicebutton and its flags) as pages; then the player screen (artwork background, glass header buttons,Disable Canvas and the sheet, header, slider and sticky header flags), the cards under the player andthe player buttons to hide, and Queue & devices and Lock screen widget as flag pages. Home & Library:diff --git a/tweak/Sources/Features/Karaoke/Karaoke.h b/tweak/Sources/Features/Karaoke/Karaoke.hindex 18951061..714a281e 100644--- a/tweak/Sources/Features/Karaoke/Karaoke.h+++ b/tweak/Sources/Features/Karaoke/Karaoke.h@@ -1,8 +1,9 @@// Apple Music style lyrics on the full screen lyrics page: the line being sung lights up word by// word, the rest dim and blur with distance. Spotify only times whole lines, so the words inside a-// line are timed by an estimate (KaraokeTiming.m). The lines are read from the color-lyrics response-// as it arrives and the position from the player's state (KaraokeSource.x); a track without synced-// lyrics keeps Spotify's own page.+// line are timed by an estimate (KaraokeTiming.m), unless Musixmatch times the words. The lines are+// read from the color-lyrics response as it arrives, or handed over by Features/Musixmatch, and the+// position from the player's state (KaraokeSource.x); a track without synced lyrics keeps Spotify's+// own page.#import <UIKit/UIKit.h>#define SGKeyKaraokeLyrics @"spotifyglass.karaokeLyrics"@@ -20,8 +21,11 @@// A color-lyrics body, protobuf or JSON, as timed lines; nil unless Spotify synced it by line.NSArray<SGKaraokeLine *> *SGKaraokeLinesFromBody(NSData *body);+// Lines timed only by their starts, the words inside them estimated; a ♪ or empty text is a break.+NSArray<SGKaraokeLine *> *SGKaraokeEstimatedLines(NSArray<NSNumber *> *starts, NSArray<NSString *> *texts);NSArray<SGKaraokeLine *> *SGKaraokeLinesForTrack(NSString *trackID); // nil until the lyrics came+void SGKaraokeKeepLines(NSString *trackID, NSArray<SGKaraokeLine *> *lines);// Asks spclient for a track's lyrics once, with the headers of Spotify's own requests, for when no// page of Spotify's has asked for them, e.g. with the app in the background.void SGKaraokeRequestLyrics(NSString *trackID);diff --git a/tweak/Sources/Features/Karaoke/KaraokeSource.x b/tweak/Sources/Features/Karaoke/KaraokeSource.xindex 3a15aa22..e84bc060 100644--- a/tweak/Sources/Features/Karaoke/KaraokeSource.x+++ b/tweak/Sources/Features/Karaoke/KaraokeSource.x@@ -2,9 +2,11 @@// the same URLSession delegates AdBlock/AdNetwork.x reads, untouched, and kept per track, since the// page may open long after the request finished. The clock is SPTEsperantoPlayer's state, asked for on// every frame: the player is caught the first time the app asks it, and its position runs on by itself.+// With Musixmatch on, the color-lyrics body is Features/Musixmatch's to answer and it hands the lines over.#import "Core/SGCore.h"#import "Karaoke.h"#import "Features/LockScreenLyrics/LockScreenLyrics.h"+#import "Features/Musixmatch/Musixmatch.h"#import "Headers/SPTPlayer.h"static const NSUInteger kKeptTracks = 40;@@ -15,6 +17,7 @@ static NSMutableDictionary<NSString *, NSArray<SGKaraokeLine *> *> *sg_lyrics;static NSMutableSet<NSString *> *sg_requested;static NSDictionary<NSString *, NSString *> *sg_spclientHeaders;static __weak id sg_player;+static BOOL sg_musixmatch;static char kBodyKey;static NSString *trackInURL(NSURL *url) {@@ -43,7 +46,7 @@ static void rememberHeaders(NSURLSession *session, NSURLRequest *request) {dispatch_async(dispatch_get_main_queue(), ^{ sg_spclientHeaders = headers; });}-static void keep(NSString *track, NSArray<SGKaraokeLine *> *lines) {+void SGKaraokeKeepLines(NSString *track, NSArray<SGKaraokeLine *> *lines) {dispatch_async(dispatch_get_main_queue(), ^{if (sg_lyrics.count >= kKeptTracks) [sg_lyrics removeAllObjects];sg_lyrics[track] = lines;@@ -52,7 +55,7 @@ static void keep(NSString *track, NSArray<SGKaraokeLine *> *lines) {static void received(NSURLSession *session, NSURLSessionTask *task, NSData *data) {rememberHeaders(session, task.currentRequest);- if (!trackInURL(task.currentRequest.URL)) return;+ if (sg_musixmatch || !trackInURL(task.currentRequest.URL)) return;NSMutableData *body = objc_getAssociatedObject(task, &kBodyKey);if (!body) objc_setAssociatedObject(task, &kBodyKey, (body = [NSMutableData data]), OBJC_ASSOCIATION_RETAIN_NONATOMIC);[body appendData:data];@@ -62,7 +65,7 @@ static void completed(NSURLSessionTask *task, NSError *error) {NSMutableData *body = objc_getAssociatedObject(task, &kBodyKey);if (!body) {NSString *path = task.currentRequest.URL.path;- if ([path.lowercaseString containsString:@"lyrics"]) SGLog(@"karaoke: lyrics request not read: %@ (error %@)", path, error);+ if (!sg_musixmatch && [path.lowercaseString containsString:@"lyrics"]) SGLog(@"karaoke: lyrics request not read: %@ (error %@)", path, error);return;}objc_setAssociatedObject(task, &kBodyKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);@@ -70,15 +73,14 @@ static void completed(NSURLSessionTask *task, NSError *error) {if (error || !track) return;NSArray<SGKaraokeLine *> *lines = SGKaraokeLinesFromBody(body);SGLog(@"karaoke: lyrics for %@, %lu bytes, %lu synced lines", track, (unsigned long)body.length, (unsigned long)lines.count);- if (lines) keep(track, lines);+ if (lines) SGKaraokeKeepLines(track, lines);}NSArray<SGKaraokeLine *> *SGKaraokeLinesForTrack(NSString *trackID) {return trackID ? sg_lyrics[trackID] : nil;}-void SGKaraokeRequestLyrics(NSString *trackID) {- if (!trackID || sg_lyrics[trackID] || [sg_requested containsObject:trackID]) return;+static void requestFromSpotify(NSString *trackID) {NSDictionary<NSString *, NSString *> *headers = sg_spclientHeaders;if (!headers) return;[sg_requested addObject:trackID];@@ -92,10 +94,27 @@ void SGKaraokeRequestLyrics(NSString *trackID) {NSArray<SGKaraokeLine *> *lines = SGKaraokeLinesFromBody(body);SGLog(@"karaoke: fetched lyrics for %@: status %ld, %lu synced lines, error %@", trackID,(long)[(NSHTTPURLResponse *)response statusCode], (unsigned long)lines.count, error);- if (lines) keep(trackID, lines);+ if (lines) SGKaraokeKeepLines(trackID, lines);}] resume];}+void SGKaraokeRequestLyrics(NSString *trackID) {+ if (!trackID || sg_lyrics[trackID] || [sg_requested containsObject:trackID]) return;+ if (!sg_musixmatch) {+ requestFromSpotify(trackID);+ return;+ }+ [sg_requested addObject:trackID];+ SGMusixmatchFetch(trackID, ^(SGMusixmatchLyrics *lyrics) {+ if (lyrics.karaokeLines) {+ SGKaraokeKeepLines(trackID, lyrics.karaokeLines);+ return;+ }+ [sg_requested removeObject:trackID];+ requestFromSpotify(trackID);+ });+}+id SGKaraokePlayer(void) {return sg_player;}@@ -156,6 +175,7 @@ void SGKaraokeSeek(NSInteger ms) {if (!SGFlag(SGKeyKaraokeLyrics, NO) && !SGFlag(SGKeyLockScreenLyrics, NO)) return;sg_lyrics = [NSMutableDictionary dictionary];sg_requested = [NSMutableSet set];+ sg_musixmatch = SGFlag(SGKeyMusixmatchLyrics, NO);%init;SGLog(@"karaoke: on");SGRequireClasses(@[diff --git a/tweak/Sources/Features/Karaoke/KaraokeTiming.m b/tweak/Sources/Features/Karaoke/KaraokeTiming.mindex 9d601a78..607a608b 100644--- a/tweak/Sources/Features/Karaoke/KaraokeTiming.m+++ b/tweak/Sources/Features/Karaoke/KaraokeTiming.m@@ -66,7 +66,7 @@ static SGKaraokeLine *timedLine(NSString *text, NSInteger start, NSInteger gap)return line;}-static NSArray<SGKaraokeLine *> *timedLines(NSArray<NSNumber *> *starts, NSArray<NSString *> *texts) {+NSArray<SGKaraokeLine *> *SGKaraokeEstimatedLines(NSArray<NSNumber *> *starts, NSArray<NSString *> *texts) {NSMutableArray<SGKaraokeLine *> *lines = [NSMutableArray array];for (NSUInteger i = 0; i < texts.count; i++) {if (isBreak(texts[i])) continue;@@ -91,7 +91,7 @@ static NSArray<SGKaraokeLine *> *fromProtobuf(NSData *body) {[starts addObject:@((int32_t)SGPBFirst(line, 1).varint)];[texts addObject:SGPBText(SGPBFirst(line, 2)) ?: @""];}- return timedLines(starts, texts);+ return SGKaraokeEstimatedLines(starts, texts);}// { "lyrics": { "syncType": "LINE_SYNCED", "lines": [ { "startTimeMs": "1234", "words": "..." } ] } }@@ -107,7 +107,7 @@ static NSArray<SGKaraokeLine *> *fromJSON(NSData *body) {[starts addObject:@([line[@"startTimeMs"] integerValue])];[texts addObject:[words isKindOfClass:NSString.class] ? words : @""];}- return timedLines(starts, texts);+ return SGKaraokeEstimatedLines(starts, texts);}NSArray<SGKaraokeLine *> *SGKaraokeLinesFromBody(NSData *body) {diff --git a/tweak/Sources/Features/Musixmatch/Musixmatch.h b/tweak/Sources/Features/Musixmatch/Musixmatch.hnew file mode 100644index 00000000..2d341a96--- /dev/null+++ b/tweak/Sources/Features/Musixmatch/Musixmatch.h@@ -0,0 +1,33 @@+// Lyrics from Musixmatch in place of Spotify's. It is the catalogue Spotify licenses, and for part of+// it Musixmatch also has the time of every word (richsync), which Spotify never sends; the karaoke+// page then sweeps real timing instead of an estimate. The token is an anonymous one asked for as+// Musixmatch's iOS app, so Musixmatch learns the track's id and nothing of the Spotify account.+// MusixmatchLyrics.x answers Spotify's color-lyrics requests with what comes back.+#import <Foundation/Foundation.h>+#import "Features/Karaoke/Karaoke.h"++#define SGKeyMusixmatchLyrics @"spotifyglass.musixmatchLyrics"+#define SGKeyMusixmatchAllTracks @"spotifyglass.musixmatchAllTracks"+// Word timing for the karaoke page from NetEase Cloud Music when Musixmatch has none, e.g. for the+// tracks it is not licensed to show. Searched by the title, artist and length Musixmatch matched.+#define SGKeyNetEaseWordTiming @"spotifyglass.neteaseWordTiming"++@interface SGMusixmatchLyrics : NSObject+@property (nonatomic) BOOL synced;+@property (nonatomic) BOOL wordTimed;+// Every line as Spotify's lyrics page takes it: ♪ over a break and an empty last line where the+// singing ends. Starts are in milliseconds, all 0 when not synced. nil when only NetEase had words.+@property (nonatomic, copy) NSArray<NSNumber *> *starts;+@property (nonatomic, copy) NSArray<NSString *> *texts;+@property (nonatomic, copy) NSArray<SGKaraokeLine *> *karaokeLines; // nil unless synced or word timed+@end++// Calls back on the main queue with nil when Musixmatch has nothing it may show for the track, or+// could not be reached.+void SGMusixmatchFetch(NSString *trackID, void (^done)(SGMusixmatchLyrics *lyrics));+// NO once Musixmatch answered that it has no lyrics for the track; safe from any thread.+BOOL SGMusixmatchMayHave(NSString *trackID);++// NetEase.m. Calls back on the main queue, nil when no recording of about that length has word timing.+// NetEase censors swear words with asterisks.+void SGNetEaseWordLines(NSString *title, NSString *artist, NSInteger seconds, void (^done)(NSArray<SGKaraokeLine *> *lines));diff --git a/tweak/Sources/Features/Musixmatch/Musixmatch.m b/tweak/Sources/Features/Musixmatch/Musixmatch.mnew file mode 100644index 00000000..69dd2696--- /dev/null+++ b/tweak/Sources/Features/Musixmatch/Musixmatch.m@@ -0,0 +1,307 @@+#import "Core/SGCore.h"+#import "Musixmatch.h"++static NSString *const kAPI = @"https://apic-appmobile.musixmatch.com/ws/1.1/";+static NSString *const kAppID = @"mac-ios-v2.0";+static NSString *const kTokenKey = @"spotifyglass.musixmatch.token";+static const NSTimeInterval kTimeout = 5;+// After Musixmatch refused a token, typically with a captcha, it is not asked again for this long.+static const NSTimeInterval kTokenPause = 600;+// A pause this long between two richsync lines gets a ♪ line, so Spotify's page does not hold the last one.+static const NSInteger kBreakMs = 3000;+static const NSUInteger kKeptTracks = 40;++@implementation SGMusixmatchLyrics+@end++// Main queue only, except sg_missing. NSNull is kept for a track Musixmatch has nothing for.+static NSMutableDictionary<NSString *, id> *sg_kept;+static NSMutableDictionary<NSString *, NSMutableArray *> *sg_waiting;+static NSMutableArray<void (^)(NSString *)> *sg_tokenWaiting;+static NSDate *sg_tokenRefused;+static NSMutableSet<NSString *> *sg_missing;++static void setUp(void) {+ static dispatch_once_t once;+ dispatch_once(&once, ^{+ sg_kept = [NSMutableDictionary dictionary];+ sg_waiting = [NSMutableDictionary dictionary];+ sg_tokenWaiting = [NSMutableArray array];+ sg_missing = [NSMutableSet set];+ });+}++// Keys contain dots ("track.richsync.get"), so the path is split on slashes.+static id dig(id value, NSString *path) {+ for (NSString *key in [path componentsSeparatedByString:@"/"]) {+ if (![value isKindOfClass:NSDictionary.class]) return nil;+ value = value[key];+ }+ return value;+}++static BOOL truthy(id value) {+ return [value respondsToSelector:@selector(boolValue)] && [value boolValue];+}++static NSInteger msOf(id seconds) {+ return [seconds respondsToSelector:@selector(doubleValue)] ? (NSInteger)llround([seconds doubleValue] * 1000) : 0;+}++static id jsonOf(id text) {+ if ([text isKindOfClass:NSString.class]) text = [text dataUsingEncoding:NSUTF8StringEncoding];+ return [text isKindOfClass:NSData.class] ? [NSJSONSerialization JSONObjectWithData:text options:0 error:nil] : nil;+}++// token.get answers a request without the app's headers with a captcha.+static NSURLRequest *requestFor(NSString *method, NSDictionary<NSString *, NSString *> *query) {+ NSURLComponents *url = [NSURLComponents componentsWithString:[kAPI stringByAppendingString:method]];+ NSMutableArray<NSURLQueryItem *> *items = [NSMutableArray arrayWithObjects:+ [NSURLQueryItem queryItemWithName:@"format" value:@"json"],+ [NSURLQueryItem queryItemWithName:@"app_id" value:kAppID], nil];+ [query enumerateKeysAndObjectsUsingBlock:^(NSString *name, NSString *value, BOOL *stop) {+ [items addObject:[NSURLQueryItem queryItemWithName:name value:value]];+ }];+ url.queryItems = items;+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url.URL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:kTimeout];+ [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];+ [request setValue:@"10.1.1" forHTTPHeaderField:@"x-mxm-app-version"];+ [request setValue:@"Musixmatch/2025120901 CFNetwork/3860.300.31 Darwin/25.2.0" forHTTPHeaderField:@"X-User-Agent"];+ return request;+}++static void call(NSString *method, NSDictionary<NSString *, NSString *> *query, void (^done)(NSDictionary *message)) {+ [[NSURLSession.sharedSession dataTaskWithRequest:requestFor(method, query) completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {+ id message = dig(jsonOf(data), @"message");+ if (error || !message) SGLog(@"musixmatch: %@ failed: status %ld, error %@", method, (long)[(NSHTTPURLResponse *)response statusCode], error);+ dispatch_async(dispatch_get_main_queue(), ^{ done([message isKindOfClass:NSDictionary.class] ? message : nil); });+ }] resume];+}++static void withToken(void (^use)(NSString *token)) {+ NSString *token = [NSUserDefaults.standardUserDefaults stringForKey:kTokenKey];+ if (token.length) {+ use(token);+ return;+ }+ if (sg_tokenRefused && -sg_tokenRefused.timeIntervalSinceNow < kTokenPause) {+ use(nil);+ return;+ }+ [sg_tokenWaiting addObject:use];+ if (sg_tokenWaiting.count > 1) return;+ call(@"token.get", @{}, ^(NSDictionary *message) {+ id fresh = dig(message, @"body/user_token");+ BOOL usable = [fresh isKindOfClass:NSString.class] && [fresh length] && ![fresh isEqualToString:@"UpgradeRequired"];+ SGLog(@"musixmatch: token %@ (status %@, hint %@)", usable ? @"received" : @"refused", dig(message, @"header/status_code"), dig(message, @"header/hint"));+ if (usable) [NSUserDefaults.standardUserDefaults setObject:fresh forKey:kTokenKey];+ else sg_tokenRefused = NSDate.date;+ NSArray<void (^)(NSString *)> *waiting = [sg_tokenWaiting copy];+ [sg_tokenWaiting removeAllObjects];+ for (void (^waiter)(NSString *) in waiting) waiter(usable ? fresh : nil);+ });+}++#pragma mark - the three shapes Musixmatch has lyrics in++// [{ "ts": 27.16, "te": 28.25, "x": "I've been tryna call", "l": [{ "c": "I've", "o": 0.03 }, { "c": " ", "o": 0.41 }, …] }]+// o is from the line's start. A space entry ends the word before it; a word can come in more than+// one entry ("Milion", "+", ","), so everything between two spaces is one word.+static SGKaraokeLine *richsyncLine(NSDictionary *entry, NSInteger start, NSInteger end) {+ NSMutableArray<SGKaraokeWord *> *words = [NSMutableArray array];+ SGKaraokeWord *open = nil;+ id parts = entry[@"l"];+ for (NSDictionary *part in [parts isKindOfClass:NSArray.class] ? parts : @[]) {+ id text = dig(part, @"c");+ if (![text isKindOfClass:NSString.class]) continue;+ NSInteger at = start + msOf(part[@"o"]);+ NSString *trimmed = [text stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];+ if (!trimmed.length) {+ open.end = MAX(at, open.start);+ open = nil;+ } else if (open) {+ open.text = [open.text stringByAppendingString:trimmed];+ } else {+ open = [SGKaraokeWord new];+ open.text = trimmed;+ open.start = at;+ open.end = MAX(end, at);+ [words addObject:open];+ }+ }+ if (!words.count) return nil;+ SGKaraokeLine *line = [SGKaraokeLine new];+ line.words = words;+ line.start = start;+ line.end = MAX(end, words.lastObject.end);+ return line;+}++static SGMusixmatchLyrics *fromRichsync(id body) {+ if (![body isKindOfClass:NSArray.class]) return nil;+ NSMutableArray<NSNumber *> *starts = [NSMutableArray array];+ NSMutableArray<NSString *> *texts = [NSMutableArray array];+ NSMutableArray<SGKaraokeLine *> *karaoke = [NSMutableArray array];+ for (NSDictionary *entry in body) {+ if (![entry isKindOfClass:NSDictionary.class]) continue;+ SGKaraokeLine *line = richsyncLine(entry, msOf(entry[@"ts"]), msOf(entry[@"te"]));+ if (!line) continue;+ if (karaoke.count && line.start - karaoke.lastObject.end >= kBreakMs) {+ [starts addObject:@(karaoke.lastObject.end)];+ [texts addObject:@"♪"];+ }+ id text = entry[@"x"];+ [starts addObject:@(line.start)];+ [texts addObject:[text isKindOfClass:NSString.class] ? text : [[line.words valueForKey:@"text"] componentsJoinedByString:@" "]];+ [karaoke addObject:line];+ }+ if (!karaoke.count) return nil;+ [starts addObject:@(karaoke.lastObject.end)];+ [texts addObject:@""];+ SGMusixmatchLyrics *lyrics = [SGMusixmatchLyrics new];+ lyrics.synced = lyrics.wordTimed = YES;+ lyrics.starts = starts;+ lyrics.texts = texts;+ lyrics.karaokeLines = karaoke;+ return lyrics;+}++// [{ "text": "Yeah, yeah", "time": { "total": 3.32 } }, …, { "text": "", "time": { "total": 241.15 } }]+// An empty text is a break, and the last one marks the end.+static SGMusixmatchLyrics *fromSubtitles(id body) {+ if (![body isKindOfClass:NSArray.class] || ![body count]) return nil;+ NSMutableArray<NSNumber *> *starts = [NSMutableArray array];+ NSMutableArray<NSString *> *texts = [NSMutableArray array];+ NSArray *lines = body;+ for (NSUInteger i = 0; i < lines.count; i++) {+ id text = dig(lines[i], @"text");+ BOOL last = i + 1 == lines.count;+ if (![text isKindOfClass:NSString.class]) text = @"";+ [starts addObject:@(msOf(dig(lines[i], @"time/total")))];+ [texts addObject:last ? @"" : ([text length] ? text : @"♪")];+ }+ SGMusixmatchLyrics *lyrics = [SGMusixmatchLyrics new];+ lyrics.synced = YES;+ lyrics.starts = starts;+ lyrics.texts = texts;+ lyrics.karaokeLines = SGKaraokeEstimatedLines(starts, texts);+ return lyrics.karaokeLines ? lyrics : nil;+}++static SGMusixmatchLyrics *fromPlain(id body) {+ if (![body isKindOfClass:NSString.class] || ![body length]) return nil;+ NSMutableArray<NSNumber *> *starts = [NSMutableArray array];+ NSMutableArray<NSString *> *texts = [NSMutableArray array];+ for (NSString *line in [body componentsSeparatedByString:@"\n"]) {+ [starts addObject:@0];+ [texts addObject:line.length ? line : @"♪"];+ }+ SGMusixmatchLyrics *lyrics = [SGMusixmatchLyrics new];+ lyrics.starts = starts;+ lyrics.texts = texts;+ return lyrics;+}++// macro.subtitles.get runs the matcher and every lookup in one call; the best shape it has wins.+static SGMusixmatchLyrics *fromCalls(NSDictionary *calls) {+ if (truthy(dig(calls, @"matcher.track.get/message/body/track/instrumental"))) return nil;+ id richsync = dig(calls, @"track.richsync.get/message/body/richsync");+ SGMusixmatchLyrics *lyrics = nil;+ if (richsync && !truthy(dig(richsync, @"restricted"))) lyrics = fromRichsync(jsonOf(dig(richsync, @"richsync_body")));+ if (lyrics) return lyrics;+ id list = dig(calls, @"track.subtitles.get/message/body/subtitle_list");+ id subtitle = [list isKindOfClass:NSArray.class] && [list count] ? dig([list firstObject], @"subtitle") : nil;+ if (subtitle && !truthy(dig(subtitle, @"restricted"))) lyrics = fromSubtitles(jsonOf(dig(subtitle, @"subtitle_body")));+ if (lyrics) return lyrics;+ id plain = dig(calls, @"track.lyrics.get/message/body/lyrics");+ return plain && !truthy(dig(plain, @"restricted")) ? fromPlain(dig(plain, @"lyrics_body")) : nil;+}++#pragma mark - asking++static void finish(NSString *trackID, SGMusixmatchLyrics *lyrics, BOOL answered) {+ if (answered) {+ if (sg_kept.count >= kKeptTracks) [sg_kept removeAllObjects];+ sg_kept[trackID] = lyrics ?: NSNull.null;+ if (!lyrics.texts.count) {+ @synchronized (sg_missing) { [sg_missing addObject:trackID]; }+ }+ }+ NSArray *waiting = sg_waiting[trackID];+ [sg_waiting removeObjectForKey:trackID];+ for (void (^done)(SGMusixmatchLyrics *) in waiting) done(lyrics);+}++static void ask(NSString *trackID, BOOL renewToken) {+ withToken(^(NSString *token) {+ if (!token) {+ finish(trackID, nil, NO);+ return;+ }+ call(@"macro.subtitles.get", @{+ @"usertoken": token,+ @"track_spotify_id": trackID,+ @"namespace": @"lyrics_richsynched",+ @"subtitle_format": @"mxm",+ @"optional_calls": @"track.richsync",+ @"richsync_compact_type": @"words",+ }, ^(NSDictionary *message) {+ NSInteger status = [dig(message, @"header/status_code") integerValue];+ if (status == 401 && renewToken) {+ SGLog(@"musixmatch: token no longer accepted (hint %@), asking for a new one", dig(message, @"header/hint"));+ [NSUserDefaults.standardUserDefaults removeObjectForKey:kTokenKey];+ ask(trackID, NO);+ return;+ }+ id calls = dig(message, @"body/macro_calls");+ if (status != 200 || ![calls isKindOfClass:NSDictionary.class]) {+ finish(trackID, nil, NO);+ return;+ }+ SGMusixmatchLyrics *lyrics = fromCalls(calls);+ SGLog(@"musixmatch: %@ has %@", trackID, !lyrics ? @"no lyrics it may show"+ : lyrics.wordTimed ? [NSString stringWithFormat:@"%lu word timed lines", (unsigned long)lyrics.karaokeLines.count]+ : lyrics.synced ? [NSString stringWithFormat:@"%lu line timed lines", (unsigned long)lyrics.karaokeLines.count]+ : [NSString stringWithFormat:@"%lu untimed lines", (unsigned long)lyrics.texts.count]);+ id track = dig(calls, @"matcher.track.get/message/body/track");+ if (lyrics.wordTimed || !SGFlag(SGKeyNetEaseWordTiming, NO) || ![track isKindOfClass:NSDictionary.class] || truthy(track[@"instrumental"])) {+ finish(trackID, lyrics, YES);+ return;+ }+ id title = track[@"track_name"], artist = track[@"artist_name"];+ SGNetEaseWordLines([title isKindOfClass:NSString.class] ? title : nil, [artist isKindOfClass:NSString.class] ? artist : nil,+ [track[@"track_length"] integerValue], ^(NSArray<SGKaraokeLine *> *lines) {+ SGMusixmatchLyrics *merged = lyrics;+ if (lines) {+ merged = lyrics ?: [SGMusixmatchLyrics new];+ merged.karaokeLines = lines;+ merged.wordTimed = YES;+ }+ finish(trackID, merged, YES);+ });+ });+ });+}++void SGMusixmatchFetch(NSString *trackID, void (^done)(SGMusixmatchLyrics *lyrics)) {+ setUp();+ dispatch_async(dispatch_get_main_queue(), ^{+ id kept = sg_kept[trackID];+ if (kept) {+ done(kept == NSNull.null ? nil : kept);+ return;+ }+ NSMutableArray *waiting = sg_waiting[trackID];+ if (waiting) {+ [waiting addObject:done];+ return;+ }+ sg_waiting[trackID] = [NSMutableArray arrayWithObject:done];+ ask(trackID, YES);+ });+}++BOOL SGMusixmatchMayHave(NSString *trackID) {+ setUp();+ @synchronized (sg_missing) { return ![sg_missing containsObject:trackID]; }+}diff --git a/tweak/Sources/Features/Musixmatch/MusixmatchLyrics.x b/tweak/Sources/Features/Musixmatch/MusixmatchLyrics.xnew file mode 100644index 00000000..7bc92359--- /dev/null+++ b/tweak/Sources/Features/Musixmatch/MusixmatchLyrics.x@@ -0,0 +1,198 @@+// Spotify's /color-lyrics/v2/track/<id> answered with Musixmatch's lyrics. An NSURLProtocol, put into+// every session the app makes, takes the request over, sends it on itself and gives Spotify one reply:+// timed lines from Musixmatch first, then Spotify's timed ones, then untimed ones from Musixmatch. A+// request Spotify's server has no lyrics for (404) becomes a 200 when Musixmatch has some. Whichever+// lines win go to the karaoke page as well.+//+// It is a protocol and not a rewrite in the URLSession delegates: a 200 handed to+// Connectivity_HttpClientKit's delegate in place of a 404 still showed no lyrics, so the task's own+// response has to be the 200.+#import "Core/SGCore.h"+#import "Musixmatch.h"+#import "Features/AdBlock/Protobuf.h"+#import "Headers/SPTPlayer.h"++static NSString *const kHandledKey = @"spotifyglass.lyricsHandled";++// The page's colours when Spotify sent none to keep, ARGB.+static const uint32_t kBackground = 0xFF535353, kLine = 0xFF000000, kActiveLine = 0xFFFFFFFF;++// A protocol sees the request without its session's HTTPAdditionalHeaders, so the ones of Spotify's+// sessions are kept and put back on the request it sends.+static NSMutableDictionary<NSString *, NSString *> *sg_sessionHeaders;++static NSString *lyricsTrack(NSURL *url) {+ NSString *path = url.path;+ NSRange marker = [path rangeOfString:@"/color-lyrics/v2/track/"];+ if (marker.location == NSNotFound) return nil;+ NSString *track = [[path substringFromIndex:NSMaxRange(marker)] componentsSeparatedByString:@"/"].firstObject;+ return track.length ? track : nil;+}++static NSInteger statusOf(NSURLResponse *response) {+ return [response isKindOfClass:NSHTTPURLResponse.class] ? ((NSHTTPURLResponse *)response).statusCode : 0;+}++// Lyrics { 1 data: { 1 time_synchronized, 2 repeated line { 1 offset_ms, 2 content }, 5 provided_by },+// 2 colors { 1 background, 2 line, 3 active_line } }+static NSData *lyricsBody(SGMusixmatchLyrics *lyrics, NSData *spotify) {+ NSMutableArray<SGPBField *> *data = [NSMutableArray array];+ if (lyrics.synced) [data addObject:SGPBVarint(1, 1)];+ for (NSUInteger i = 0; i < lyrics.texts.count; i++) {+ NSData *line = SGPBSerialize(@[SGPBVarint(1, (uint64_t)MAX(lyrics.starts[i].integerValue, 0)), SGPBString(2, lyrics.texts[i])]);+ [data addObject:SGPBBytes(2, line)];+ }+ [data addObject:SGPBString(5, @"Musixmatch")];+ SGPBField *colors = SGPBFirst(SGPBParse(spotify), 2);+ if (colors.wire != 2) colors = SGPBBytes(2, SGPBSerialize(@[SGPBVarint(1, kBackground), SGPBVarint(2, kLine), SGPBVarint(3, kActiveLine)]));+ return SGPBSerialize(@[SGPBBytes(1, SGPBSerialize(data)), colors]);+}++// Musixmatch's body, or nil to hand Spotify's reply on as it came.+static NSData *chosenBody(NSString *track, SGMusixmatchLyrics *lyrics, NSData *spotify) {+ NSArray<SGKaraokeLine *> *spotifyLines = SGKaraokeLinesFromBody(spotify);+ BOOL ours = lyrics.texts.count && (lyrics.synced || !spotifyLines);+ NSArray<SGKaraokeLine *> *karaoke = lyrics.wordTimed || ours ? lyrics.karaokeLines : spotifyLines;+ if (karaoke) SGKaraokeKeepLines(track, karaoke);+ SGLog(@"musixmatch: lyrics page of %@ gets %@, %@ word timing", track, ours ? @"Musixmatch's lines" : spotify.length ? @"Spotify's own lines" : @"no lyrics",+ lyrics.wordTimed ? @"real" : @"estimated");+ return ours ? lyricsBody(lyrics, spotify) : nil;+}++@interface SGLyricsURLProtocol : NSURLProtocol+@end++@implementation SGLyricsURLProtocol {+ NSURLSessionDataTask *_inner;+ NSThread *_thread;+ NSArray<NSString *> *_modes;+ BOOL _stopped;+}+++ (BOOL)canInitWithRequest:(NSURLRequest *)request {+ return lyricsTrack(request.URL) && ![NSURLProtocol propertyForKey:kHandledKey inRequest:request];+}+++ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request {+ return request;+}+++ (NSURLSession *)innerSession {+ static NSURLSession *session;+ static dispatch_once_t once;+ dispatch_once(&once, ^{+ NSURLSessionConfiguration *configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration;+ configuration.URLCache = nil;+ session = [NSURLSession sessionWithConfiguration:configuration];+ });+ return session;+}++// The client is told things only on the thread that started the load, in its run loop mode.+- (void)onLoadingThread:(void (^)(void))block {+ [self performSelector:@selector(runOnLoadingThread:) onThread:_thread withObject:[block copy] waitUntilDone:NO modes:_modes];+}++- (void)runOnLoadingThread:(void (^)(void))block {+ if (!_stopped) block();+}++- (void)replyWith:(NSURLResponse *)response data:(NSData *)data {+ [self onLoadingThread:^{+ [self.client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];+ if (data.length) [self.client URLProtocol:self didLoadData:data];+ [self.client URLProtocolDidFinishLoading:self];+ }];+}++- (void)startLoading {+ _thread = NSThread.currentThread;+ NSString *mode = NSRunLoop.currentRunLoop.currentMode;+ _modes = mode && ![mode isEqualToString:NSDefaultRunLoopMode] ? @[NSDefaultRunLoopMode, mode] : @[NSDefaultRunLoopMode];++ NSMutableURLRequest *request = [self.request mutableCopy];+ [NSURLProtocol setProperty:@YES forKey:kHandledKey inRequest:request];+ @synchronized (sg_sessionHeaders) {+ [sg_sessionHeaders enumerateKeysAndObjectsUsingBlock:^(NSString *name, NSString *value, BOOL *stop) {+ if (![request valueForHTTPHeaderField:name]) [request setValue:value forHTTPHeaderField:name];+ }];+ }+ NSString *track = lyricsTrack(request.URL);+ _inner = [[SGLyricsURLProtocol innerSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {+ if (error) {+ [self onLoadingThread:^{ [self.client URLProtocol:self didFailWithError:error]; }];+ return;+ }+ NSInteger status = statusOf(response);+ BOOL json = data.length && ((const uint8_t *)data.bytes)[0] == '{';+ SGLog(@"musixmatch: Spotify answered %ld with %lu bytes for %@", (long)status, (unsigned long)data.length, track);+ if ((status != 200 && status < 400) || (status == 200 && json)) {+ [self replyWith:response data:data];+ return;+ }+ SGMusixmatchFetch(track, ^(SGMusixmatchLyrics *lyrics) {+ NSData *body = chosenBody(track, lyrics, status == 200 ? data : nil);+ if (!body) {+ [self replyWith:response data:data];+ return;+ }+ NSHTTPURLResponse *ok = [[NSHTTPURLResponse alloc] initWithURL:request.URL statusCode:200 HTTPVersion:@"HTTP/1.1"+ headerFields:@{@"Content-Type": @"application/protobuf", @"Content-Length": @(body.length).stringValue}];+ [self replyWith:ok data:body];+ });+ }];+ [_inner resume];+}++- (void)stopLoading {+ _stopped = YES;+ [_inner cancel];+}++@end++%hook NSURLSession++ (NSURLSession *)sessionWithConfiguration:(NSURLSessionConfiguration *)configuration delegate:(id)delegate delegateQueue:(NSOperationQueue *)queue {+ if (!configuration) return %orig;+ NSURLSessionConfiguration *withProtocol = [configuration copy];+ NSArray *classes = withProtocol.protocolClasses ?: @[];+ if (![classes containsObject:SGLyricsURLProtocol.class]) withProtocol.protocolClasses = [@[SGLyricsURLProtocol.class] arrayByAddingObjectsFromArray:classes];+ NSString *owner = delegate ? NSStringFromClass([delegate class]) : @"";+ if (configuration.HTTPAdditionalHeaders.count && ([owner isEqualToString:@"SPTDataLoaderService"] || [owner containsString:@"HttpClientURLSession"])) {+ @synchronized (sg_sessionHeaders) {+ [configuration.HTTPAdditionalHeaders enumerateKeysAndObjectsUsingBlock:^(id name, id value, BOOL *stop) {+ if ([name isKindOfClass:NSString.class] && [value isKindOfClass:NSString.class]) sg_sessionHeaders[name] = value;+ }];+ }+ }+ return %orig(withProtocol, delegate, queue);+}+%end++// The player offers the lyrics card by the track's has_lyrics.+%group AllTracks+%hook SPTPlayerTrack+- (NSDictionary *)metadata {+ NSDictionary *metadata = %orig;+ if ([metadata[@"has_lyrics"] isEqual:@"true"]) return metadata;+ id uri = self.URI;+ NSString *text = [uri isKindOfClass:NSURL.class] ? [(NSURL *)uri absoluteString] : [uri description];+ if (![text hasPrefix:@"spotify:track:"] || !SGMusixmatchMayHave([text substringFromIndex:@"spotify:track:".length])) return metadata;+ static dispatch_once_t once;+ dispatch_once(&once, ^{ SGLog(@"musixmatch: marking tracks without Spotify lyrics as having some, first %@", text); });+ NSMutableDictionary *marked = [metadata mutableCopy] ?: [NSMutableDictionary dictionary];+ marked[@"has_lyrics"] = @"true";+ return marked;+}+%end+%end++%ctor {+ if (!SGFlag(SGKeyMusixmatchLyrics, NO)) return;+ sg_sessionHeaders = [NSMutableDictionary dictionary];+ %init;+ BOOL allTracks = SGFlag(SGKeyMusixmatchAllTracks, NO);+ if (allTracks) %init(AllTracks);+ SGLog(@"musixmatch: on, every track %@", allTracks ? @"on" : @"off");+ SGRequireClasses(@[@"SPTPlayerTrack"]);+}diff --git a/tweak/Sources/Features/Musixmatch/NetEase.m b/tweak/Sources/Features/Musixmatch/NetEase.mnew file mode 100644index 00000000..c1bdd81a--- /dev/null+++ b/tweak/Sources/Features/Musixmatch/NetEase.m@@ -0,0 +1,115 @@+#import "Core/SGCore.h"+#import "Musixmatch.h"++static const NSTimeInterval kTimeout = 3;+// A NetEase recording is only taken when its length is this close to the track's, so the words fall+// on the same beat.+static const NSInteger kLengthSlack = 3;+static const NSUInteger kTriedSongs = 3;++static void get(NSString *path, NSDictionary<NSString *, NSString *> *query, void (^done)(NSDictionary *root)) {+ NSURLComponents *url = [NSURLComponents componentsWithString:[@"https://music.163.com/api/" stringByAppendingString:path]];+ NSMutableArray<NSURLQueryItem *> *items = [NSMutableArray array];+ [query enumerateKeysAndObjectsUsingBlock:^(NSString *name, NSString *value, BOOL *stop) {+ [items addObject:[NSURLQueryItem queryItemWithName:name value:value]];+ }];+ url.queryItems = items;+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url.URL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:kTimeout];+ [request setValue:@"https://music.163.com" forHTTPHeaderField:@"Referer"];+ [[NSURLSession.sharedSession dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {+ id root = data ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : nil;+ if (error || !root) SGLog(@"netease: %@ failed: status %ld, error %@", path, (long)[(NSHTTPURLResponse *)response statusCode], error);+ dispatch_async(dispatch_get_main_queue(), ^{ done([root isKindOfClass:NSDictionary.class] ? root : nil); });+ }] resume];+}++// [43060,3600](43060,120,0)To (43180,330,0)seize (43510,420,0)everything …+// A line's start and length in ms, then each piece's start and length before its text. A piece not+// ending in a space runs on into the next one ("wanted" "…"), as in richsync.+static NSArray<SGKaraokeLine *> *linesFromYrc(NSString *yrc) {+ static NSRegularExpression *header, *piece;+ static dispatch_once_t once;+ dispatch_once(&once, ^{+ header = [NSRegularExpression regularExpressionWithPattern:@"^\\[(\\d+),(\\d+)\\]" options:0 error:nil];+ piece = [NSRegularExpression regularExpressionWithPattern:@"\\((\\d+),(\\d+),-?\\d+\\)" options:0 error:nil];+ });+ NSMutableArray<SGKaraokeLine *> *lines = [NSMutableArray array];+ for (NSString *row in [yrc componentsSeparatedByString:@"\n"]) {+ NSTextCheckingResult *head = [header firstMatchInString:row options:0 range:NSMakeRange(0, row.length)];+ if (!head) continue;+ NSArray<NSTextCheckingResult *> *pieces = [piece matchesInString:row options:0 range:NSMakeRange(NSMaxRange(head.range), row.length - NSMaxRange(head.range))];+ NSMutableArray<SGKaraokeWord *> *words = [NSMutableArray array];+ SGKaraokeWord *open = nil;+ for (NSUInteger i = 0; i < pieces.count; i++) {+ NSUInteger from = NSMaxRange(pieces[i].range), to = i + 1 < pieces.count ? pieces[i + 1].range.location : row.length;+ NSString *raw = [row substringWithRange:NSMakeRange(from, to - from)];+ NSString *text = [raw stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];+ NSInteger start = [row substringWithRange:[pieces[i] rangeAtIndex:1]].integerValue;+ NSInteger end = start + [row substringWithRange:[pieces[i] rangeAtIndex:2]].integerValue;+ if (text.length && open) {+ open.text = [open.text stringByAppendingString:text];+ open.end = end;+ } else if (text.length) {+ open = [SGKaraokeWord new];+ open.text = text;+ open.start = start;+ open.end = end;+ [words addObject:open];+ }+ if (raw.length > text.length || !text.length) open = nil;+ }+ if (!words.count) continue;+ SGKaraokeLine *line = [SGKaraokeLine new];+ line.words = words;+ line.start = [row substringWithRange:[head rangeAtIndex:1]].integerValue;+ line.end = line.start + [row substringWithRange:[head rangeAtIndex:2]].integerValue;+ [lines addObject:line];+ }+ return lines.count ? lines : nil;+}++static void tryLyrics(NSArray<NSNumber *> *songs, NSUInteger index, void (^done)(NSArray<SGKaraokeLine *> *)) {+ if (index >= songs.count) {+ done(nil);+ return;+ }+ get(@"song/lyric/v1", @{@"id": songs[index].stringValue, @"lv": @"1", @"yv": @"1", @"tv": @"-1"}, ^(NSDictionary *root) {+ id yrc = [root[@"yrc"] isKindOfClass:NSDictionary.class] ? root[@"yrc"][@"lyric"] : nil;+ NSArray<SGKaraokeLine *> *lines = [yrc isKindOfClass:NSString.class] ? linesFromYrc(yrc) : nil;+ if (lines) {+ SGLog(@"netease: song %@ has %lu word timed lines", songs[index], (unsigned long)lines.count);+ done(lines);+ } else {+ tryLyrics(songs, index + 1, done);+ }+ });+}++void SGNetEaseWordLines(NSString *title, NSString *artist, NSInteger seconds, void (^done)(NSArray<SGKaraokeLine *> *lines)) {+ NSString *lead = [artist componentsSeparatedByString:@" feat"].firstObject.lowercaseString;+ if (!title.length || !lead.length || seconds <= 0) {+ done(nil);+ return;+ }+ get(@"search/get", @{@"s": [NSString stringWithFormat:@"%@ %@", title, lead], @"type": @"1", @"limit": @"10"}, ^(NSDictionary *root) {+ id songs = [root[@"result"] isKindOfClass:NSDictionary.class] ? root[@"result"][@"songs"] : nil;+ NSMutableArray<NSDictionary *> *fitting = [NSMutableArray array];+ for (NSDictionary *song in [songs isKindOfClass:NSArray.class] ? songs : @[]) {+ if (![song isKindOfClass:NSDictionary.class] || labs([song[@"duration"] integerValue] / 1000 - seconds) > kLengthSlack) continue;+ id artists = song[@"artists"];+ for (NSDictionary *credited in [artists isKindOfClass:NSArray.class] ? artists : @[]) {+ NSString *name = [credited isKindOfClass:NSDictionary.class] && [credited[@"name"] isKindOfClass:NSString.class] ? [credited[@"name"] lowercaseString] : nil;+ if (name.length && ([name containsString:lead] || [lead containsString:name])) {+ [fitting addObject:song];+ break;+ }+ }+ }+ [fitting sortUsingComparator:^NSComparisonResult(NSDictionary *a, NSDictionary *b) {+ return [@(labs([a[@"duration"] integerValue] / 1000 - seconds)) compare:@(labs([b[@"duration"] integerValue] / 1000 - seconds))];+ }];+ NSArray *ids = [[fitting valueForKey:@"id"] subarrayWithRange:NSMakeRange(0, MIN(fitting.count, kTriedSongs))];+ if (!ids.count) SGLog(@"netease: no recording of %@ by %@ within %lds of %lds", title, lead, (long)kLengthSlack, (long)seconds);+ tryLyrics(ids, 0, done);+ });+}diff --git a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.mindex aa89811a..8062e607 100644--- a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m+++ b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m@@ -6,6 +6,7 @@#import "Features/ArtistBlock/ArtistBlock.h"#import "Features/Karaoke/Karaoke.h"#import "Features/LockScreenLyrics/LockScreenLyrics.h"+#import "Features/Musixmatch/Musixmatch.h"static UIViewController *nowPlayingBarPage(void) {return [[SGModPage alloc] initWithTitle:@"Now playing bar" intro:SGRestartNote sections:@[@@ -28,10 +29,15 @@ static UIViewController *nowPlayingBarPage(void) {static UIViewController *lyricsPage(void) {return [[SGModPage alloc] initWithTitle:@"Lyrics" intro:SGRestartNote sections:@[SGSection(nil, @[- SGOptionRow(@"Apple Music style", @"Word by word on the full screen page; timing inside a line is estimated", SGKeyKaraokeLyrics),+ SGOptionRow(@"Apple Music style", @"Word by word on the full screen page; timing inside a line is estimated unless Musixmatch has it", SGKeyKaraokeLyrics),SGOptionRow(@"Glass lyrics", @"Glass card, and the page it expands into", SGKeyLyricsCard),SGOptionRow(@"Lyrics on the lock screen", @"The line being sung in place of the artist, also in the Dynamic Island, Control Center and CarPlay", SGKeyLockScreenLyrics),]),+ SGNotedSection(@"Musixmatch", @[+ SGOptionRow(@"Lyrics from Musixmatch", @"In place of Spotify's, with the time of every word where Musixmatch has it", SGKeyMusixmatchLyrics),+ SGOptionRow(@"Lyrics for every track", @"Offers the lyrics card on tracks Spotify has no lyrics for; needs Lyrics from Musixmatch", SGKeyMusixmatchAllTracks),+ SGOptionRow(@"Word timing from NetEase", @"For Apple Music style when Musixmatch has none, as for most Eminem; needs Lyrics from Musixmatch", SGKeyNetEaseWordTiming),+ ], @"Musixmatch is sent the track's id with an anonymous token, NetEase the title and artist; neither gets anything of your Spotify account."),SGSection(@"Hide in the player", @[SGHideRow(@"Lyrics card", @"The lyrics card below the player", SGHideLyricsCard),SGHideRow(@"Lyrics preview", @"The lyric lines shown under the artwork", SGHideLyricsInline),