Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

fix: LRCLIB's search no longer crashes on a null LRC when the track's length is unknown

My-Name-Is-Jeff7c7f29536d01
diff --git a/harness/lyrics-sources/check.m b/harness/lyrics-sources/check.m
index c9d1c628..e7c48d4b 100644
--- a/harness/lyrics-sources/check.m
+++ b/harness/lyrics-sources/check.m
@@ -320,6 +320,12 @@ int main(int argc, char **argv) {
@{@"id": @3, @"duration": @202, @"hasWordSync": @YES, @"syncedLyrics": twoLines, @"lyricsfile": wordFile}];
SGLrcLibAsk(query, ^(SGLyricsResult *result) { got = result; });
CHECK(got.wordTimed && got.karaokeLines.count == 1);
+ // With no length to go on, a record whose LRC is null against one whose LRC is empty: the plain text wins.
+ query.seconds = 0;
+ found = @[@{@"id": @4, @"syncedLyrics": NSNull.null, @"plainLyrics": @"x"}, @{@"id": @5, @"syncedLyrics": @"", @"plainLyrics": @"y\nz"}];
+ got = nil;
+ SGLrcLibAsk(query, ^(SGLyricsResult *result) { got = result; });
+ CHECK(got && !got.synced);
for (int i = 1; i < argc; i++) checkLive(@(argv[i]));
printf("lyrics-sources: all checks passed\n");
diff --git a/tweak/Sources/Shared/LyricsSources/LrcLib.m b/tweak/Sources/Shared/LyricsSources/LrcLib.m
index 0073f1da..aea0fbb2 100644
--- a/tweak/Sources/Shared/LyricsSources/LrcLib.m
+++ b/tweak/Sources/Shared/LyricsSources/LrcLib.m
@@ -131,7 +131,7 @@ static BOOL betterRecord(NSDictionary *record, NSDictionary *best, NSInteger sec
}
NSString *text = record[@"syncedLyrics"] ?: record[@"plainLyrics"] ?: @"";
NSString *wasText = best[@"syncedLyrics"] ?: best[@"plainLyrics"] ?: @"";
- return [text isKindOfClass:NSString.class] && [text length] > [wasText length];
+ return [text isKindOfClass:NSString.class] && (![wasText isKindOfClass:NSString.class] || text.length > wasText.length);
}
static NSDictionary *bestOf(id found, NSInteger seconds) {