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: the Genius match keeps a lead named before "feat." and skips titles with no words

My-Name-Is-Jeff795046d8f26b
diff --git a/harness/genius-lyrics/build.sh b/harness/genius-lyrics/build.sh
index aa1d4b0f..a64b5d2d 100755
--- a/harness/genius-lyrics/build.sh
+++ b/harness/genius-lyrics/build.sh
@@ -6,6 +6,6 @@ HERE=$(cd "$(dirname "$0")" && pwd)
SRC=$(cd "$HERE/../../tweak/Sources" && pwd)
mkdir -p "$HERE/build"
xcrun -sdk macosx clang -target arm64-apple-ios17.0-macabi -isysroot "$(xcrun --sdk macosx --show-sdk-path)" -iframework "$(xcrun --sdk macosx --show-sdk-path)/System/iOSSupport/System/Library/Frameworks" -fobjc-arc -g -Wall -I"$SRC" -DSG_VERSION=\"0.0.0\" \
- "$HERE/check.m" "$SRC/Shared/LyricsSources/Genius.m" "$SRC/Shared/LyricsSources/LrcLib.m" "$SRC/Shared/LyricsMeanings/Meanings.m" "$SRC/Shared/Lyrics/KaraokeTiming.m" "$SRC/Shared/AdBlock/Protobuf.m" \
+ "$HERE/check.m" "$SRC/Shared/LyricsSources/Genius.m" "$SRC/Shared/LyricsSources/LrcLib.m" "$SRC/Shared/LyricsSources/QQMusic.m" "$SRC/Shared/LyricsMeanings/Meanings.m" "$SRC/Shared/Lyrics/KaraokeTiming.m" "$SRC/Shared/AdBlock/Protobuf.m" \
-framework UIKit -framework Foundation -o "$HERE/build/check"
"$HERE/build/check" "$@"
diff --git a/harness/genius-lyrics/check.m b/harness/genius-lyrics/check.m
index d84a9ff5..833ce7cc 100644
--- a/harness/genius-lyrics/check.m
+++ b/harness/genius-lyrics/check.m
@@ -47,6 +47,7 @@ void SGLyricsGetJSON(NSURL *url, NSDictionary *headers, void (^done)(id root)) {
NSData *body = fetched(url);
done(body ? [NSJSONSerialization JSONObjectWithData:body options:0 error:nil] : nil);
}
+void SGLyricsPostJSON(NSURL *url, NSDictionary *headers, id body, void (^done)(id root)) { done(nil); }
void SGLyricsGetText(NSURL *url, void (^done)(NSString *text)) {
NSData *body = fetched(url);
done(body ? [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding] : nil);
@@ -109,6 +110,10 @@ static void checkPicks(void) {
@[@"Under Pressure", @"Queen, David Bowie", reply(@[@[@6868363, @"Queen & David Bowie - Under Pressure (Traducción al Español)", @[@"Genius Traducciones al Español"]], @[@152350, @"Under Pressure", @[@"Queen", @"David Bowie"]]]), @152350],
@[@"EARFQUAKE", @"Tyler, The Creator", reply(@[@[@4420287, @"EARFQUAKE", @[@"Tyler, The Creator"]]]), @4420287],
@[@"Dynamite", @"BTS", reply(@[@[@5813592, @"Dynamite", @[@"BTS (방탄소년단)"]]]), @5813592],
+ // A local file's tag naming the guest after the lead.
+ @[@"Old Town Road", @"Lil Nas X feat. Billy Ray Cyrus", oldTownRoad, @4133841],
+ // A title with no word of its own matches nothing, not every untitled hit.
+ @[@"(Untitled)", @"Lil Nas X", reply(@[@[@1, @"[Untitled]", @[@"Lil Nas X"]]]), @0],
@[@"ЗНАК (SIGN)", @"Dora", reply(@[@[@13935027, @"ЗНАК (SIGN)", @[@"Toxi$", @"Дора (Dora)"]]]), @13935027],
];
// A null where Genius sends a boolean is not instrumental, and does not throw.
diff --git a/tweak/Sources/Shared/LyricsMeanings/Meanings.m b/tweak/Sources/Shared/LyricsMeanings/Meanings.m
index 028e5426..60758cab 100644
--- a/tweak/Sources/Shared/LyricsMeanings/Meanings.m
+++ b/tweak/Sources/Shared/LyricsMeanings/Meanings.m
@@ -2,6 +2,7 @@
#import "Settings/SGModPage.h"
#import "Headers/SPTPlayer.h"
#import "Meanings.h"
+#import "Shared/LyricsSources/LyricsSources.h"
static NSString *const kReferents = @"https://genius.com/api/referents";
static const NSUInteger kMostPages = 5, kPerPage = 50;
@@ -150,9 +151,9 @@ static NSString *withoutGuests(NSString *title) {
}
// Spotify joins a track's artists with ", ", which a name can hold too ("Tyler, The Creator"), so the
-// lead artist is any run of the first names.
+// lead artist is any run of the first names; a local file's tag may name the lead before " feat." instead.
static NSSet<NSString *> *leadNames(NSString *artist) {
- NSMutableSet<NSString *> *names = [NSMutableSet set];
+ NSMutableSet<NSString *> *names = [NSMutableSet setWithObject:folded(SGLyricsLeadArtist(artist))];
NSString *run = @"";
for (NSString *part in [artist componentsSeparatedByString:@", "]) {
run = run.length ? [run stringByAppendingFormat:@" %@", folded(part)] : folded(part);
@@ -180,6 +181,7 @@ static BOOL byLead(NSDictionary *song, NSSet<NSString *> *leads) {
NSNumber *SGGeniusSongIn(NSDictionary *response, NSString *title, NSString *artist) {
if (![response isKindOfClass:NSDictionary.class] || !title.length || !artist.length) return nil;
NSString *wantTitle = folded(bareTitle(title));
+ if (!wantTitle.length) return nil;
NSSet<NSString *> *wantVersion = versionOf(withoutGuests(title));
// Genius files a song's words under the song; a track with none sung would get them anyway.
if ([wantVersion containsObject:@"instrumental"] || [wantVersion containsObject:@"karaoke"]) return nil;