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 reads a Lyricsfile only when the record says it times words

My-Name-Is-Jeffa8888de8164e
diff --git a/harness/lyrics-sources/check.m b/harness/lyrics-sources/check.m
index 294bce45..c1c501e4 100644
--- a/harness/lyrics-sources/check.m
+++ b/harness/lyrics-sources/check.m
@@ -288,8 +288,8 @@ int main(int argc, char **argv) {
CHECK(!SGLyricsfileLines([wordFile stringByAppendingFormat:@"plain: |\n %@\n", [@"" stringByPaddingToLength:(1 << 20) withString:@"a" startingAtIndex:0]]));
CHECK(!SGLyricsfileLines(@"[not, yaml") && !SGLyricsfileLines(@"") && !SGLyricsfileLines(nil) && !SGLyricsfileLines((NSString *)@3));
- // LRCLIB: a record with words timed answers with them; one whose Lyricsfile cannot be read
- // answers with its LRC; the search picks the record with words over a closer one without.
+ // LRCLIB: a record with words timed answers with them; one whose Lyricsfile cannot be read, or
+ // that says it has no word sync, answers with its LRC; the search picks the record with words over a closer one without.
NSString *twoLines = @"[00:01.00]a\n[00:02.00]b\n";
__block NSDictionary *record = @{@"id": @1, @"duration": @200, @"hasWordSync": @YES, @"syncedLyrics": twoLines, @"lyricsfile": wordFile};
__block NSArray *found = nil;
@@ -303,6 +303,9 @@ int main(int argc, char **argv) {
record = @{@"id": @1, @"duration": @200, @"hasWordSync": @YES, @"syncedLyrics": twoLines, @"lyricsfile": @"version: '9'"};
SGLrcLibAsk(query, ^(SGLyricsResult *result) { got = result; });
CHECK(!got.wordTimed && got.synced && got.karaokeLines.count == 2);
+ record = @{@"id": @1, @"duration": @200, @"hasWordSync": @NO, @"syncedLyrics": twoLines, @"lyricsfile": wordFile};
+ SGLrcLibAsk(query, ^(SGLyricsResult *result) { got = result; });
+ CHECK(!got.wordTimed && got.synced && got.karaokeLines.count == 2);
record = nil;
found = @[@{@"id": @2, @"duration": @200, @"syncedLyrics": twoLines},
@{@"id": @3, @"duration": @202, @"hasWordSync": @YES, @"syncedLyrics": twoLines, @"lyricsfile": wordFile}];
diff --git a/tweak/Sources/Shared/LyricsSources/LrcLib.m b/tweak/Sources/Shared/LyricsSources/LrcLib.m
index 68eeac12..0073f1da 100644
--- a/tweak/Sources/Shared/LyricsSources/LrcLib.m
+++ b/tweak/Sources/Shared/LyricsSources/LrcLib.m
@@ -88,12 +88,15 @@ static SGLyricsResult *resultFrom(NSDictionary *record) {
result.instrumental = [record[@"instrumental"] boolValue];
if (result.instrumental) return result;
id synced = record[@"syncedLyrics"], plain = record[@"plainLyrics"];
- SGLyricsResult *worded = syncedResult(SGLyricsfileLines(record[@"lyricsfile"]));
- if (worded) {
- worded.wordTimed = YES;
- return worded;
+ // Without word sync the record's Lyricsfile only repeats its LRC's line times, so it is not read.
+ if ([record[@"hasWordSync"] isEqual:@YES]) {
+ SGLyricsResult *worded = syncedResult(SGLyricsfileLines(record[@"lyricsfile"]));
+ if (worded) {
+ worded.wordTimed = YES;
+ return worded;
+ }
+ SGLog(@"lrclib: record %@ times words in a Lyricsfile this cannot read", record[@"id"]);
}
- if ([record[@"hasWordSync"] isEqual:@YES]) SGLog(@"lrclib: record %@ times words in a Lyricsfile this cannot read", record[@"id"]);
SGLyricsResult *timed = SGLyricsLRCResult(synced);
if (timed) return timed;
// Nothing timed, but the words still beat an empty page when no other source has any.