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: a null "instrumental" in a Genius reply does not crash the song match

My-Name-Is-Jeffc22f5f67dde3
diff --git a/harness/genius-lyrics/check.m b/harness/genius-lyrics/check.m
index da98dfa6..d84a9ff5 100644
--- a/harness/genius-lyrics/check.m
+++ b/harness/genius-lyrics/check.m
@@ -111,6 +111,9 @@ static void checkPicks(void) {
@[@"Dynamite", @"BTS", reply(@[@[@5813592, @"Dynamite", @[@"BTS (방탄소년단)"]]]), @5813592],
@[@"ЗНАК (SIGN)", @"Dora", reply(@[@[@13935027, @"ЗНАК (SIGN)", @[@"Toxi$", @"Дора (Dora)"]]]), @13935027],
];
+ // A null where Genius sends a boolean is not instrumental, and does not throw.
+ NSDictionary *nullHit = @{@"result": @{@"id": @1063, @"title": @"Bohemian Rhapsody", @"primary_artists": @[@{@"name": @"Queen"}], @"instrumental": NSNull.null}};
+ CHECK([SGGeniusSongIn(@{@"sections": @[@{@"hits": @[nullHit]}]}, @"Bohemian Rhapsody", @"Queen") isEqual:@1063]);
for (NSArray *c in cases) {
NSNumber *song = SGGeniusSongIn(c[2], c[0], c[1]);
printf("%s by %s: %s\n", [c[0] UTF8String], [c[1] UTF8String], song ? song.stringValue.UTF8String : "none");
diff --git a/tweak/Sources/Shared/LyricsMeanings/Meanings.m b/tweak/Sources/Shared/LyricsMeanings/Meanings.m
index 4a38febe..028e5426 100644
--- a/tweak/Sources/Shared/LyricsMeanings/Meanings.m
+++ b/tweak/Sources/Shared/LyricsMeanings/Meanings.m
@@ -194,7 +194,7 @@ NSNumber *SGGeniusSongIn(NSDictionary *response, NSString *title, NSString *arti
NSDictionary *song = [hit isKindOfClass:NSDictionary.class] ? hit[@"result"] : nil;
if (![song isKindOfClass:NSDictionary.class] || ![song[@"id"] isKindOfClass:NSNumber.class]) continue;
NSString *hitTitle = stringIn(song[@"title"]);
- if ([song[@"instrumental"] boolValue] || ![folded(bareTitle(hitTitle)) isEqualToString:wantTitle] || !byLead(song, leads)) continue;
+ if ([song[@"instrumental"] isEqual:@YES] || ![folded(bareTitle(hitTitle)) isEqualToString:wantTitle] || !byLead(song, leads)) continue;
NSSet<NSString *> *version = versionOf(hitTitle);
NSInteger rank = [version isEqualToSet:wantVersion] ? 3 : version.count == 0 ? 2 : 1;
if (rank > bestRank) {