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

chore: Spicy Lyrics is no longer a lyrics source, and the mod no longer lends anyone the Spotify token (#103)

Vojtěch Škopekf103fc56e2aa
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 38922cd8..f1e00859 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -83,13 +83,8 @@ Shared:
best answer (LyricsSources.m, the list to drag in LyricsSourcesPage.m): Apple Music's TTML from
BiniLyrics.m and Unison.m, read by SGTTML.m, which carries a second voice and the
backing vocals, and in its head Apple's translation and its pronunciation of a line, the pronunciation
- timed word by word (the translation taken in the Lyrics page's language); SpicyLyrics.m (spicylyrics.org),
- matched by Spotify's track id and carrying Apple Music's syllables, the backing vocals and the two sides
- of a duet as the TTML does, answered in a packed shape of its own (every distinct value once, then an
- opcode stream rebuilding the document) and only to a caller that sends the app's own Spotify token, which
- SGKaraokeSpotifyAuthorization() lends it — the one source told anything of the account, which is why
- the page says so; Musixmatch.m, matched by Spotify's track id with an anonymous token, word timed where
- it has richsync; NetEase.m, word timing from yrc for what the others only line time; LrcLib.m, open and
+ timed word by word (the translation taken in the Lyrics page's language); Musixmatch.m, matched by
+ Spotify's track id with an anonymous token, word timed where it has richsync; NetEase.m, word timing from yrc for what the others only line time; LrcLib.m, open and
keyless and timed by the line, the floor under the rest. color-lyrics is answered with whichever won
(LyricsHook.x): Spotify's own 200 gets our lines swapped in; a track Spotify's metadata says has none has
its request sent to a donor track that does, so the reply is a real 200 (a 404 answered as a 200 in the
diff --git a/harness/lyrics/README.md b/harness/lyrics/README.md
index be5d5b27..c764572b 100644
--- a/harness/lyrics/README.md
+++ b/harness/lyrics/README.md
@@ -25,7 +25,7 @@ The fixtures are real TTML and LRC with every word swapped for filler of the sam
- `linetimed` TTML timed by the line only (BiniLyrics' line timed shape): two voices, two lines sung
over each other at 42.4 s, a Hebrew line at 50.6 s, a 9 s break at 85.4 s, translations
- `spotify-line`, `spotify-static` Spotify's own color-lyrics JSON, LINE_SYNCED and UNSYNCED, read by
- the real `SGKaraokeLinesFromBody`; `static` plain text, as LRCLIB's plainLyrics or Spicy's Static
+ the real `SGKaraokeLinesFromBody`; `static` plain text, as LRCLIB's plainLyrics
(these four are written by `fixtures/linetimed.py` from `plain`'s timing)
- `rtl` (built in) right to left lines among left to right ones, a second voice, a break before the
last line; `rtlx` the same with translations and a romanization
diff --git a/harness/lyrics/fixtures/linetimed.py b/harness/lyrics/fixtures/linetimed.py
index ecc584be..1eb3c775 100644
--- a/harness/lyrics/fixtures/linetimed.py
+++ b/harness/lyrics/fixtures/linetimed.py
@@ -7,7 +7,7 @@ and filler words, so they carry no song's lyrics:
lines in the head, as BiniLyrics serves its line timed songs
- spotify-line.json Spotify's color-lyrics JSON, syncType LINE_SYNCED
- spotify-static.json the same, UNSYNCED, every start 0
-- static.txt plain text with stanza breaks, as LRCLIB's plainLyrics or Spicy's Static come
+- static.txt plain text with stanza breaks, as LRCLIB's plainLyrics comes
./linetimed.py # rewrites all four next to this script
"""
diff --git a/harness/spicylyrics/README.md b/harness/spicylyrics/README.md
deleted file mode 100644
index d7900680..00000000
--- a/harness/spicylyrics/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-# Spicy Lyrics harness
-
-`Shared/LyricsSources/SpicyLyrics.m` compiled and run on the Mac, with the two things it reaches
-out through — the Spotify token it borrows and the POST — replaced by ones the test drives
-(`stubs.m`). Everything else in it is the real file.
-
- ./build.sh
-
-What it is for is the packed shape the API answers in: every distinct value in the document once,
-then a stream of opcodes rebuilding it. `pack.ts` packs the test documents with the extension's
-**own packer** (cloned into `build/`), so the decoder in `SpicyLyrics.m` is checked against the only
-other implementation of that shape there is, rather than against a reading of it. The documents
-cover all three shapes the API sends — `Syllable`, `Line` and `Static` — and the `-1` and `-3`
-opcodes between them; the words in them are placeholders, not a song.
-
-It also holds the source to what the chain needs of it: a track the server has queued (a 503 inside
-a 200 envelope) counts as a failure, so `LyricsSources.m` does not keep the track as having no
-lyrics, while a 404 is an answer and does not; a reply that does not hold together is refused
-whole; and with no Spotify request seen yet to borrow a token from, nothing is sent at all.
-
-What it cannot check is the live API: it is behind Cloudflare and answers only a signed-in Spotify
-client, so the request as a whole is only proven on the phone.
diff --git a/harness/spicylyrics/build.sh b/harness/spicylyrics/build.sh
deleted file mode 100755
index 4a281ef6..00000000
--- a/harness/spicylyrics/build.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-# Runs Shared/LyricsSources/SpicyLyrics.m against replies packed by Spicy Lyrics' own packer.
-# Needs bun, and clones the extension the first time to borrow that packer.
-set -e
-HERE=$(cd "$(dirname "$0")" && pwd)
-SRC=$HERE/../../tweak/Sources
-OUT=$HERE/build
-mkdir -p "$OUT"
-
-[ -d "$OUT/spicy-lyrics" ] || git clone --depth 1 https://github.com/Spikerko/spicy-lyrics.git "$OUT/spicy-lyrics"
-(cd "$HERE" && bun run pack.ts > "$OUT/fixtures.json")
-
-clang -fobjc-arc -g -O0 -o "$OUT/spicytest" \
- "$HERE/main.m" "$HERE/stubs.m" "$SRC/Shared/LyricsSources/SpicyLyrics.m" \
- -I"$HERE/include" -I"$SRC" -I"$SRC/Shared/LyricsSources" \
- -framework Foundation
-
-cd "$OUT" && ./spicytest
diff --git a/harness/spicylyrics/include/Core/SGCore.h b/harness/spicylyrics/include/Core/SGCore.h
deleted file mode 100644
index 6f8cb55a..00000000
--- a/harness/spicylyrics/include/Core/SGCore.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#import <Foundation/Foundation.h>
-#define SGLog(fmt, ...) do { if (getenv("SGVERBOSE")) fprintf(stderr, " log: %s\n", [NSString stringWithFormat:(fmt), ##__VA_ARGS__].UTF8String); } while (0)
diff --git a/harness/spicylyrics/include/UIKit/UIKit.h b/harness/spicylyrics/include/UIKit/UIKit.h
deleted file mode 100644
index 5bef64e9..00000000
--- a/harness/spicylyrics/include/UIKit/UIKit.h
+++ /dev/null
@@ -1,4 +0,0 @@
-// Enough UIKit for the lyrics headers to parse on the Mac; the source under test draws nothing.
-#import <Foundation/Foundation.h>
-@interface UIView : NSObject @end
-@interface UIViewController : NSObject @end
diff --git a/harness/spicylyrics/main.m b/harness/spicylyrics/main.m
deleted file mode 100644
index 8293b7e3..00000000
--- a/harness/spicylyrics/main.m
+++ /dev/null
@@ -1,133 +0,0 @@
-// Runs Shared/LyricsSources/SpicyLyrics.m for real against replies packed by Spicy Lyrics' own
-// packer (../pack.ts), so the decoder and the line building are checked against the shape the
-// server actually sends rather than against my reading of it.
-#import "LyricsSources.h"
-#import "Shared/Lyrics/Lyrics.h"
-
-extern NSString *sg_token;
-extern NSURL *sg_sentTo;
-extern NSDictionary *sg_sentHeaders, *sg_sentBody;
-extern NSUInteger sg_sentCount;
-extern id sg_reply;
-extern NSInteger sg_notedFailures;
-extern NSArray<NSNumber *> *sg_estimatedStarts;
-extern NSArray<NSString *> *sg_estimatedTexts;
-
-static int failures;
-
-static void check(BOOL ok, NSString *what) {
- printf(" %s %s\n", ok ? "ok " : "FAIL", what.UTF8String);
- if (!ok) failures++;
-}
-
-static void checkEqual(id got, id want, NSString *what) {
- check([got isEqual:want], [NSString stringWithFormat:@"%@ (got %@, want %@)", what, got, want]);
-}
-
-// The one reply shape the API uses: a 200 envelope with the query's own status inside it.
-static id envelope(NSInteger status, id data) {
- return @{@"queries": @[@{@"operation": @"lyrics", @"operationId": @"0",
- @"result": @{@"httpStatus": @(status), @"format": @"json", @"data": data ?: NSNull.null}}]};
-}
-
-static SGLyricsResult *ask(NSString *trackID) {
- SGLyricsQuery *query = [SGLyricsQuery new];
- query.trackID = trackID;
- __block SGLyricsResult *answer = nil;
- __block BOOL called = NO;
- SGSpicyLyricsAsk(query, ^(SGLyricsResult *result) {
- answer = result;
- called = YES;
- });
- check(called, @"the source answered");
- return answer;
-}
-
-int main(void) {
- @autoreleasepool {
- NSData *raw = [NSData dataWithContentsOfFile:@"fixtures.json"];
- NSDictionary *packed = [NSJSONSerialization JSONObjectWithData:raw options:0 error:nil];
- NSCAssert(packed.count, @"no fixtures; run pack.ts first");
-
- printf("syllable lyrics\n");
- sg_reply = envelope(200, packed[@"syllable"]);
- SGLyricsResult *result = ask(@"0VjIjW4GlUZAMYd2vXMi3b");
- check(result != nil, @"there is a result");
- check(result.synced && result.wordTimed, @"synced and word timed");
- checkEqual(@(result.karaokeLines.count), @2, @"two lines");
- SGKaraokeLine *first = result.karaokeLines.firstObject;
- checkEqual(@(first.start), @1500, @"the line starts at its own StartTime, in ms");
- checkEqual(@(first.end), @4250, @"the line ends at its own EndTime, in ms");
- checkEqual(@(first.words.count), @3, @"three syllables are three words");
- checkEqual(@(first.words[0].start), @1500, @"the first syllable's start");
- checkEqual(@(first.words[1].end), @2400, @"a fractional second lands on the right ms");
- check(!first.words[0].joined, @"the first word of a line is never joined");
- check(first.words[1].joined, @"a syllable after IsPartOfWord is laid flush");
- check(!first.words[2].joined, @"a syllable after a whole word is not");
- checkEqual(@(first.align), @(SGKaraokeAlignLeading), @"the first voice leads");
- check(first.backing != nil, @"the line has its backing vocals");
- checkEqual(SGKaraokeLineText(first.backing), @"echo", @"the backing words");
- checkEqual(@(first.backing.start), @3000, @"the backing starts with its own first word");
- SGKaraokeLine *second = result.karaokeLines[1];
- checkEqual(@(second.align), @(SGKaraokeAlignTrailing), @"OppositeAligned puts the line on the far side");
- check(second.backing == nil, @"a line with no Background has no backing line");
- checkEqual(@(result.texts.count), @2, @"the page gets a line for each");
-
- printf("the request itself\n");
- checkEqual(sg_sentTo.absoluteString, @"https://api.spicylyrics.org/query", @"the address");
- checkEqual(sg_sentHeaders[@"SpicyLyrics-WebAuth"], sg_token, @"the token goes in the header it names");
- checkEqual(sg_sentHeaders[@"X-mode"], @"2", @"the packed shape is asked for");
- check([sg_sentHeaders[@"SpicyLyrics-Version"] length] > 0, @"a client version is sent");
- // The server reads the identity Spotify's desktop client's Chromium puts on every request,
- // and answers a caller without it with plain text instead of syllables.
- checkEqual(sg_sentHeaders[@"Origin"], @"https://xpui.app.spotify.com", @"the desktop client's origin");
- check([sg_sentHeaders[@"User-Agent"] containsString:@"Chrome/"], @"a Chromium user agent");
- check([sg_sentHeaders[@"sec-ch-ua-platform"] length] > 0, @"the client hints go with it");
- check(sg_sentHeaders[@"Accept-Encoding"] == nil, @"encoding is left to URLSession, which can decode what it asks for");
- NSDictionary *sent = [sg_sentBody[@"queries"] firstObject];
- checkEqual(sent[@"operation"], @"lyrics", @"the operation");
- checkEqual(sent[@"variables"][@"id"], @"0VjIjW4GlUZAMYd2vXMi3b", @"the track id, not a name");
- checkEqual(sent[@"variables"][@"auth"], @"SpicyLyrics-WebAuth", @"the header the token is in is named");
-
- printf("line timed lyrics\n");
- sg_reply = envelope(200, packed[@"line"]);
- result = ask(@"track2");
- check(result.synced && !result.wordTimed, @"synced but not word timed");
- checkEqual(sg_estimatedStarts, (@[@2000, @4500]), @"the estimator gets the line starts in ms");
- checkEqual(sg_estimatedTexts, (@[@"delta foxtrot", @"golf hotel"]), @"and their text");
-
- printf("static lyrics\n");
- sg_reply = envelope(200, packed[@"static"]);
- result = ask(@"track3");
- check(!result.synced, @"not synced");
- checkEqual(@(result.karaokeLines.count), @0, @"nothing to sweep");
- checkEqual(result.texts, (@[@"india", @"♪", @"juliett"]), @"the words, a break for the empty line");
- checkEqual(result.starts, (@[@0, @0, @0]), @"every start is zero");
-
- printf("what goes wrong\n");
- NSInteger before = sg_notedFailures;
- sg_reply = envelope(503, nil);
- check(ask(@"track4") == nil, @"a queued track has no lyrics yet");
- checkEqual(@(sg_notedFailures), @(before + 1), @"and the walk is told, so it is not kept as having none");
- before = sg_notedFailures;
- sg_reply = envelope(404, nil);
- check(ask(@"track5") == nil, @"a track it does not have");
- checkEqual(@(sg_notedFailures), @(before), @"which is an answer, not a failure");
- sg_reply = envelope(200, @[@[@"Type"], @[@0, @0, @0]]);
- check(ask(@"track6") == nil, @"a stream that does not hold together");
- sg_reply = envelope(200, @[packed[@"static"][0], [packed[@"static"][1] arrayByAddingObject:@0]]);
- check(ask(@"track7") == nil, @"a document with something tacked on the end");
- sg_reply = @{@"queries": @[]};
- check(ask(@"track8") == nil, @"an envelope with no answer in it");
-
- printf("with no token to borrow\n");
- NSUInteger sentBefore = sg_sentCount;
- sg_token = nil;
- sg_reply = envelope(200, packed[@"syllable"]);
- check(ask(@"track9") == nil, @"nothing is answered");
- checkEqual(@(sg_sentCount), @(sentBefore), @"and nothing is sent");
-
- printf("\n%s\n", failures ? [NSString stringWithFormat:@"%d failed", failures].UTF8String : "all passed");
- return failures ? 1 : 0;
- }
-}
diff --git a/harness/spicylyrics/pack.ts b/harness/spicylyrics/pack.ts
deleted file mode 100644
index 5999e87b..00000000
--- a/harness/spicylyrics/pack.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-// Packs test documents with Spicy Lyrics' own packer, so the ObjC decoder is checked against the
-// only implementation of this shape there is. The words are placeholders, not anyone's lyrics.
-import { SLObjPack } from "./build/spicy-lyrics/src/utils/objpack.ts";
-const packer = new SLObjPack();
-
-const syllable = {
- Type: "Syllable",
- SongWriters: ["A Writer"],
- Content: [
- {
- Type: "Vocal",
- Lead: {
- StartTime: 1.5, EndTime: 4.25,
- Syllables: [
- { Text: "al", StartTime: 1.5, EndTime: 1.9, IsPartOfWord: true },
- { Text: "pha", StartTime: 1.9, EndTime: 2.4 },
- { Text: "bravo", StartTime: 2.6, EndTime: 4.25 },
- ],
- },
- Background: [
- { StartTime: 3.0, EndTime: 4.0, Syllables: [{ Text: "echo", StartTime: 3.0, EndTime: 4.0 }] },
- ],
- },
- {
- Type: "Vocal",
- OppositeAligned: true,
- Lead: {
- StartTime: 9.0, EndTime: 11.0,
- Syllables: [{ Text: "charlie", StartTime: 9.0, EndTime: 11.0 }],
- },
- },
- ],
-};
-
-const line = {
- Type: "Line",
- Content: [
- { Type: "Vocal", Text: "delta foxtrot", StartTime: 2.0, EndTime: 4.0 },
- { Type: "Vocal", Text: "golf hotel", StartTime: 4.5, EndTime: 6.0 },
- ],
-};
-
-const staticDoc = { Type: "Static", Lines: [{ Text: "india" }, { Text: "" }, { Text: "juliett" }] };
-
-const out = {
- syllable: packer.pack(syllable),
- line: packer.pack(line),
- static: packer.pack(staticDoc),
- // Round-trip proof that the packer and its unpacker agree on these documents.
- roundTrips: [syllable, line, staticDoc].every(
- (d) => JSON.stringify(packer.unpack(packer.pack(d))) === JSON.stringify(d)
- ),
-};
-console.log(JSON.stringify(out));
diff --git a/harness/spicylyrics/stubs.m b/harness/spicylyrics/stubs.m
deleted file mode 100644
index 016782ff..00000000
--- a/harness/spicylyrics/stubs.m
+++ /dev/null
@@ -1,77 +0,0 @@
-// Just enough of the mod around SpicyLyrics.m for it to run on the Mac: the lyrics value types as
-// they really are, and the two things the source reaches out through — the borrowed Spotify token
-// and the POST — replaced by ones the test drives.
-#import "LyricsSources.h"
-#import "Shared/Lyrics/Lyrics.h"
-
-@implementation SGKaraokeWord @end
-@implementation SGKaraokeLine @end
-@implementation SGLyricsResult @end
-@implementation SGLyricsQuery @end
-@implementation SGLyricsProvider @end
-
-NSString *sg_token = @"Bearer test-token";
-NSString *SGKaraokeSpotifyAuthorization(void) { return sg_token; }
-
-// What the last request carried, and what the next one is answered with.
-NSURL *sg_sentTo;
-NSDictionary *sg_sentHeaders, *sg_sentBody;
-NSUInteger sg_sentCount;
-id sg_reply;
-NSInteger sg_notedFailures;
-
-void SGLyricsNoteReply(NSURLResponse *response, NSError *error) {
- NSInteger status = [response isKindOfClass:NSHTTPURLResponse.class] ? ((NSHTTPURLResponse *)response).statusCode : 0;
- if (error || status == 429 || status >= 500) sg_notedFailures++;
-}
-
-void SGLyricsPostJSON(NSURL *url, NSDictionary<NSString *, NSString *> *headers, id body, void (^done)(id root)) {
- sg_sentTo = url;
- sg_sentHeaders = headers;
- sg_sentBody = body;
- sg_sentCount++;
- // The real one refuses a body it cannot write, so hold this one to the same bar.
- NSCAssert([NSJSONSerialization isValidJSONObject:body], @"the body is not JSON");
- done(sg_reply);
-}
-
-// The page lines are LyricsSources.m's own, proven work; here they only need to be countable.
-void SGLyricsPageLines(NSArray<SGKaraokeLine *> *lines, NSArray<NSNumber *> **starts, NSArray<NSString *> **texts) {
- NSMutableArray<NSNumber *> *at = [NSMutableArray array];
- NSMutableArray<NSString *> *said = [NSMutableArray array];
- for (SGKaraokeLine *line in lines) {
- [at addObject:@(line.start)];
- [said addObject:SGKaraokeLineText(line)];
- }
- *starts = at;
- *texts = said;
-}
-
-// The estimator is Shared/Lyrics' own; what matters here is what the source hands it.
-NSArray<NSNumber *> *sg_estimatedStarts;
-NSArray<NSString *> *sg_estimatedTexts;
-
-NSArray<SGKaraokeLine *> *SGKaraokeEstimatedLines(NSArray<NSNumber *> *starts, NSArray<NSString *> *texts) {
- sg_estimatedStarts = starts;
- sg_estimatedTexts = texts;
- NSMutableArray<SGKaraokeLine *> *lines = [NSMutableArray array];
- for (NSUInteger i = 0; i < texts.count; i++) {
- SGKaraokeWord *word = [SGKaraokeWord new];
- word.text = texts[i];
- word.start = starts[i].integerValue;
- SGKaraokeLine *line = [SGKaraokeLine new];
- line.words = @[word];
- line.start = word.start;
- [lines addObject:line];
- }
- return lines.count ? lines : nil;
-}
-
-NSString *SGKaraokeLineText(SGKaraokeLine *line) {
- NSMutableString *text = [NSMutableString string];
- for (SGKaraokeWord *word in line.words) {
- if (text.length && !word.joined) [text appendString:@" "];
- [text appendString:word.text];
- }
- return text;
-}
diff --git a/tweak/Sources/App/Donate/Donate.m b/tweak/Sources/App/Donate/Donate.m
index 40f743f3..99aaef58 100644
--- a/tweak/Sources/App/Donate/Donate.m
+++ b/tweak/Sources/App/Donate/Donate.m
@@ -366,7 +366,7 @@ static char kCardGlassKey;
UIButton *later = [UIButton buttonWithConfiguration:config primaryAction:nil];
[later addTarget:self action:@selector(later) forControlEvents:UIControlEventTouchUpInside];
- UILabel *thanks = [self label:@"Also built on Spicy Lyrics, JamesDSP and EeveeSpotify. Thank you to everyone behind them."
+ UILabel *thanks = [self label:@"Also built on JamesDSP and EeveeSpotify. Thank you to everyone behind them."
font:[UIFont systemFontOfSize:11] color:[UIColor colorWithWhite:1 alpha:0.38]];
UIStackView *column = [[UIStackView alloc] initWithArrangedSubviews:@[hero, eyebrow, title, body, donate, later, thanks]];
diff --git a/tweak/Sources/Shared/Lyrics/KaraokeSource.x b/tweak/Sources/Shared/Lyrics/KaraokeSource.x
index 1a7f67d5..153589de 100644
--- a/tweak/Sources/Shared/Lyrics/KaraokeSource.x
+++ b/tweak/Sources/Shared/Lyrics/KaraokeSource.x
@@ -103,10 +103,6 @@ NSArray<SGKaraokeLine *> *SGKaraokeLinesForTrack(NSString *trackID) {
return trackID ? sg_lyrics[trackID] : nil;
}
-NSString *SGKaraokeSpotifyAuthorization(void) {
- return sg_spclientHeaders[@"authorization"];
-}
-
static void requestFromSpotify(NSString *trackID) {
NSDictionary<NSString *, NSString *> *headers = sg_spclientHeaders;
if (!headers) return;
diff --git a/tweak/Sources/Shared/Lyrics/Lyrics.h b/tweak/Sources/Shared/Lyrics/Lyrics.h
index 66056684..bc0eee00 100644
--- a/tweak/Sources/Shared/Lyrics/Lyrics.h
+++ b/tweak/Sources/Shared/Lyrics/Lyrics.h
@@ -101,10 +101,6 @@ void SGKaraokeRequestLyrics(NSString *trackID);
// Asks Spotify's JSON lyrics for the track once, and keeps its lines only if they are more finely
// timed than the ones kept: the lyrics view was left with plain text, and Spotify may have it timed.
void SGKaraokeAskSpotifyForTiming(NSString *trackID);
-// The Authorization header Spotify's own requests carry, "Bearer ..." and the account's own token;
-// nil until one has gone out. Only for a source that answers no one who cannot show they are a
-// signed-in Spotify client, and only with the mod's user having switched that source on.
-NSString *SGKaraokeSpotifyAuthorization(void);
NSString *SGKaraokePlayingTrack(void); // the base62 id, nil before the player reported
NSInteger SGKaraokePositionMs(void); // negative when unknown
void SGKaraokeSeek(NSInteger ms);
diff --git a/tweak/Sources/Shared/LyricsSources/LyricsSources.h b/tweak/Sources/Shared/LyricsSources/LyricsSources.h
index 186a7b44..ddf476e2 100644
--- a/tweak/Sources/Shared/LyricsSources/LyricsSources.h
+++ b/tweak/Sources/Shared/LyricsSources/LyricsSources.h
@@ -4,8 +4,7 @@
// later one that times every word.
//
// SGTTML.m reads the TTML that Apple Music's own lyrics are written in, which is what BiniLyrics and
-// Unison serve. It and Spicy Lyrics are the only shapes carrying a second voice and the (oh, aye)
-// sung under a line; every other source times lines, or the words inside them, and nothing more.
+// Unison serve. It is the only shape carrying a second voice and the (oh, aye) sung under a line; every other source times lines, or the words inside them, and nothing more.
#import <UIKit/UIKit.h>
#import "Shared/Lyrics/Lyrics.h"
@@ -57,7 +56,7 @@ typedef void (^SGLyricsAsk)(SGLyricsQuery *query, void (^done)(SGLyricsResult *r
@property (nonatomic, copy) NSString *name; // "BiniLyrics", what the credit reads
@property (nonatomic, copy) NSString *detail; // one line under the name on the Lyrics page
// Searches by title and artist, so it has nothing to ask with until someone has named the track.
-// Musixmatch and Spicy Lyrics match by Spotify's id and can go without.
+// Musixmatch matches by Spotify's id and can go without.
@property (nonatomic) BOOL needsName;
@property (nonatomic, copy) SGLyricsAsk ask;
@end
@@ -126,6 +125,5 @@ extern SGLyricsAsk SGMusixmatchAsk;
extern SGLyricsAsk SGUnisonAsk;
extern SGLyricsAsk SGNetEaseAsk;
extern SGLyricsAsk SGLrcLibAsk;
-extern SGLyricsAsk SGSpicyLyricsAsk;
UIViewController *SGLyricsSourcesPage(void); // the ordered list on the Lyrics page
diff --git a/tweak/Sources/Shared/LyricsSources/LyricsSources.m b/tweak/Sources/Shared/LyricsSources/LyricsSources.m
index b4484114..ce415923 100644
--- a/tweak/Sources/Shared/LyricsSources/LyricsSources.m
+++ b/tweak/Sources/Shared/LyricsSources/LyricsSources.m
@@ -144,12 +144,11 @@ NSArray<SGLyricsProvider *> *SGLyricsAllProviders(void) {
provider.detail = detail;
// A source that matches by Spotify's own track id has everything it needs from the
// start; the rest wait for the player to name the track before they can search.
- provider.needsName = ![@[@"musixmatch", @"spicylyrics"] containsObject:key];
+ provider.needsName = ![key isEqualToString:@"musixmatch"];
provider.ask = ask;
return provider;
};
all = @[
- make(@"spicylyrics", @"Spicy Lyrics", @"Syllable timing, uses your Spotify token", SGSpicyLyricsAsk),
make(@"binilyrics", @"BiniLyrics", @"Apple Music word timing", SGBiniLyricsAsk),
make(@"musixmatch", @"Musixmatch", @"Spotify's licensed catalogue", SGMusixmatchAsk),
make(@"unison", @"Unison", @"Hand-timed, few tracks", SGUnisonAsk),
diff --git a/tweak/Sources/Shared/LyricsSources/LyricsSourcesPage.m b/tweak/Sources/Shared/LyricsSources/LyricsSourcesPage.m
index 0d2ef21f..489e9bfc 100644
--- a/tweak/Sources/Shared/LyricsSources/LyricsSourcesPage.m
+++ b/tweak/Sources/Shared/LyricsSources/LyricsSourcesPage.m
@@ -42,8 +42,8 @@ typedef NS_ENUM(NSInteger, SGSourcesSection) {
[self read];
self.tableView.editing = YES;
self.tableView.allowsSelectionDuringEditing = YES;
- _footer = SGNote(@"Asked top to bottom until one has word timing. Spicy Lyrics is sent your Spotify "
- "access token; the others get only the track, never your account.");
+ _footer = SGNote(@"Asked top to bottom until one has word timing. Sources get only the track, never "
+ "your account.");
self.tableView.tableFooterView = _footer;
}
diff --git a/tweak/Sources/Shared/LyricsSources/SpicyLyrics.m b/tweak/Sources/Shared/LyricsSources/SpicyLyrics.m
deleted file mode 100644
index 3bb422df..00000000
--- a/tweak/Sources/Shared/LyricsSources/SpicyLyrics.m
+++ /dev/null
@@ -1,413 +0,0 @@
-// Spicy Lyrics, the source behind the Spicetify extension of the same name (spicylyrics.org). Like
-// Musixmatch it is asked by Spotify's own track id rather than by name, so it never answers with a
-// live cut of the song by mistake; unlike Musixmatch, what it has is Apple Music's syllable timing,
-// down to the backing vocals and the two sides of a duet.
-//
-// Two things about it are like nothing else here. It answers no one who cannot show they are a
-// signed-in Spotify client, so the request carries the same Authorization header Spotify's own
-// requests carry — the account's own access token. That is more than any other source is told, which
-// is why the Lyrics page says so plainly and why this source, like the rest, is off until you turn it
-// on. And it answers in a packed shape rather than plain JSON: every distinct value in the document
-// once, then a stream of opcodes rebuilding it. unpack() below puts it back together.
-#import "Core/SGCore.h"
-#import "LyricsSources.h"
-#import "Shared/Lyrics/Lyrics.h"
-
-static NSString *const kAPI = @"https://api.spicylyrics.org/query";
-// The header the token rides in. The request names it in the query's variables as well, which is how
-// the server is told which of the headers it accepts this caller is using.
-static NSString *const kAuthHeader = @"SpicyLyrics-WebAuth";
-// The extension release this file was written against. The server reads it to tell old clients from
-// new, so it moves when the shapes read below do.
-static NSString *const kClientVersion = @"6.3.20";
-// Only one query goes out per ask, and the reply names its answers by the index they came in at.
-static NSString *const kOperationID = @"0";
-
-#pragma mark - the packed shape
-
-// A reply is [values, stream]: every distinct string, number, boolean and null in the document, and
-// a stream of integers rebuilding it. A number at or above zero is an index into the values; below
-// zero it opens a structure. Straight from the extension's own packer, which is the only writer of
-// this shape there is.
-typedef NS_ENUM(NSInteger, SGSpicyOp) {
- SGSpicyOpObject = -1, // key count, that many key indexes, then that many values
- SGSpicyOpArray = -2, // item count, then that many values
- SGSpicyOpRows = -3, // item count, key count, the keys once, then the rows' values
- SGSpicyOpEmptyArray = -4,
- SGSpicyOpOneItemArray = -5, // the one value
- SGSpicyOpEmptyObject = -6,
-};
-
-// Deep enough for any lyrics document and shallow enough that a malformed reply cannot run the
-// stack out: the shape below nests six levels, not sixty.
-static const NSUInteger kMaxDepth = 64;
-
-@interface SGSpicyReader : NSObject {
-@public
- NSArray *values, *stream;
- NSUInteger cursor;
- BOOL bad; // the reply did not hold together; whatever has been read of it is thrown away
-}
-@end
-
-@implementation SGSpicyReader
-@end
-
-static NSInteger nextNumber(SGSpicyReader *reader) {
- if (reader->cursor >= reader->stream.count) {
- reader->bad = YES;
- return 0;
- }
- id number = reader->stream[reader->cursor++];
- if (![number isKindOfClass:NSNumber.class]) {
- reader->bad = YES;
- return 0;
- }
- return [number integerValue];
-}
-
-static id valueAt(SGSpicyReader *reader, NSInteger index) {
- if (index < 0 || (NSUInteger)index >= reader->values.count) {
- reader->bad = YES;
- return nil;
- }
- return reader->values[index];
-}
-
-static NSString *nextKey(SGSpicyReader *reader) {
- id key = valueAt(reader, nextNumber(reader));
- if (![key isKindOfClass:NSString.class]) {
- reader->bad = YES;
- return nil;
- }
- return key;
-}
-
-static id decode(SGSpicyReader *reader, NSUInteger depth) {
- if (reader->bad || depth > kMaxDepth) {
- reader->bad = YES;
- return nil;
- }
- NSInteger op = nextNumber(reader);
- if (reader->bad) return nil;
- if (op >= 0) return valueAt(reader, op);
- // A count is read before anything is built with it, so a reply claiming a million keys cannot
- // have a million slots reserved for it before the stream is found to be shorter than that.
- NSInteger count = op == SGSpicyOpObject || op == SGSpicyOpArray || op == SGSpicyOpRows ? nextNumber(reader) : 0;
- if (reader->bad || count < 0 || (NSUInteger)count > reader->stream.count) {
- reader->bad = YES;
- return nil;
- }
- switch (op) {
- case SGSpicyOpObject: {
- NSMutableArray<NSString *> *keys = [NSMutableArray arrayWithCapacity:count];
- for (NSInteger i = 0; i < count; i++) {
- NSString *key = nextKey(reader);
- if (reader->bad) return nil;
- [keys addObject:key];
- }
- NSMutableDictionary *object = [NSMutableDictionary dictionaryWithCapacity:count];
- for (NSInteger i = 0; i < count; i++) {
- id value = decode(reader, depth + 1);
- if (reader->bad) return nil;
- object[keys[i]] = value;
- }
- return object;
- }
- case SGSpicyOpArray: {
- NSMutableArray *items = [NSMutableArray arrayWithCapacity:count];
- for (NSInteger i = 0; i < count; i++) {
- id item = decode(reader, depth + 1);
- if (reader->bad) return nil;
- [items addObject:item];
- }
- return items;
- }
- // A run of objects sharing their keys — every line of a song — with the keys written once.
- case SGSpicyOpRows: {
- NSInteger keyCount = nextNumber(reader);
- if (reader->bad || keyCount < 0 || (NSUInteger)keyCount > reader->stream.count) {
- reader->bad = YES;
- return nil;
- }
- NSMutableArray<NSString *> *keys = [NSMutableArray arrayWithCapacity:keyCount];
- for (NSInteger i = 0; i < keyCount; i++) {
- NSString *key = nextKey(reader);
- if (reader->bad) return nil;
- [keys addObject:key];
- }
- NSMutableArray *rows = [NSMutableArray arrayWithCapacity:count];
- for (NSInteger i = 0; i < count; i++) {
- NSMutableDictionary *row = [NSMutableDictionary dictionaryWithCapacity:keyCount];
- for (NSInteger k = 0; k < keyCount; k++) {
- id value = decode(reader, depth + 1);
- if (reader->bad) return nil;
- row[keys[k]] = value;
- }
- [rows addObject:row];
- }
- return rows;
- }
- case SGSpicyOpEmptyArray: return @[];
- case SGSpicyOpOneItemArray: {
- id only = decode(reader, depth + 1);
- return reader->bad ? nil : @[only];
- }
- case SGSpicyOpEmptyObject: return @{};
- }
- reader->bad = YES;
- return nil;
-}
-
-static id unpack(id packed) {
- // Should the server ever answer a caller of ours with the document itself, it is already what
- // the rest of this file wants.
- if ([packed isKindOfClass:NSDictionary.class]) return packed;
- if (![packed isKindOfClass:NSArray.class] || [packed count] != 2) return nil;
- id values = packed[0], stream = packed[1];
- if (![values isKindOfClass:NSArray.class] || ![stream isKindOfClass:NSArray.class]) return nil;
- SGSpicyReader *reader = [SGSpicyReader new];
- reader->values = values;
- reader->stream = stream;
- id document = decode(reader, 0);
- // Anything left in the stream means it was not the document it claimed to be.
- if (reader->bad || reader->cursor != reader->stream.count) {
- SGLog(@"spicy: the packed reply did not hold together, %lu of %lu read",
- (unsigned long)reader->cursor, (unsigned long)reader->stream.count);
- return nil;
- }
- return document;
-}
-
-#pragma mark - the document as lines
-
-// The API times in seconds, the mod in milliseconds.
-static NSInteger msIn(id seconds) {
- return [seconds isKindOfClass:NSNumber.class] ? (NSInteger)llround([seconds doubleValue] * 1000.0) : 0;
-}
-
-static NSDictionary *dictionaryIn(id value) {
- return [value isKindOfClass:NSDictionary.class] ? value : nil;
-}
-
-static NSArray *arrayIn(id value) {
- return [value isKindOfClass:NSArray.class] ? value : nil;
-}
-
-// One voice's syllables as words. A syllable is a piece of a word — the API marks the ones that run
-// into the next with IsPartOfWord, which is the same thing the mod calls a word being joined to the
-// one before it, read from the other end.
-static NSArray<SGKaraokeWord *> *wordsFrom(NSArray *syllables) {
- NSMutableArray<SGKaraokeWord *> *words = [NSMutableArray array];
- BOOL joinToPrevious = NO;
- for (id raw in syllables ?: @[]) {
- NSDictionary *syllable = dictionaryIn(raw);
- if (!syllable) continue;
- BOOL runsOn = [syllable[@"IsPartOfWord"] boolValue];
- id text = syllable[@"Text"];
- NSString *said = [text isKindOfClass:NSString.class]
- ? [text stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet] : nil;
- if (said.length) {
- SGKaraokeWord *word = [SGKaraokeWord new];
- word.text = said;
- word.start = msIn(syllable[@"StartTime"]);
- word.end = msIn(syllable[@"EndTime"]);
- word.joined = joinToPrevious && words.count > 0;
- [words addObject:word];
- }
- joinToPrevious = runsOn;
- }
- return words;
-}
-
-static SGKaraokeLine *lineFrom(NSArray<SGKaraokeWord *> *words, id start, id end) {
- if (!words.count) return nil;
- SGKaraokeLine *line = [SGKaraokeLine new];
- line.words = words;
- // The line's own times where it has them; the words it is made of where it does not.
- line.start = start ? msIn(start) : words.firstObject.start;
- line.end = end ? msIn(end) : words.lastObject.end;
- return line;
-}
-
-// Content: [ { Type: "Vocal", OppositeAligned, Lead: { StartTime, EndTime, Syllables }, Background } ]
-static NSArray<SGKaraokeLine *> *linesFromSyllables(NSArray *content) {
- NSMutableArray<SGKaraokeLine *> *lines = [NSMutableArray array];
- for (id raw in content ?: @[]) {
- NSDictionary *vocal = dictionaryIn(raw);
- NSDictionary *lead = dictionaryIn(vocal[@"Lead"]);
- if (!lead) continue;
- SGKaraokeLine *line = lineFrom(wordsFrom(arrayIn(lead[@"Syllables"])), lead[@"StartTime"], lead[@"EndTime"]);
- if (!line) continue;
- // The (oh, aye) sung under the line. The API keeps it in groups, one per run of it; the page
- // has one backing line under each line, so the runs read on as one.
- NSMutableArray<SGKaraokeWord *> *backing = [NSMutableArray array];
- for (id rawGroup in arrayIn(vocal[@"Background"]) ?: @[]) {
- NSDictionary *group = dictionaryIn(rawGroup);
- if (group) [backing addObjectsFromArray:wordsFrom(arrayIn(group[@"Syllables"]))];
- }
- line.backing = lineFrom(backing, nil, nil);
- // The far side of a duet. The API says outright which lines belong to the second voice, so
- // unlike TTML there are no voices here to work an alignment out from.
- if ([vocal[@"OppositeAligned"] boolValue] || [lead[@"OppositeAligned"] boolValue]) {
- line.align = SGKaraokeAlignTrailing;
- }
- [lines addObject:line];
- }
- return lines.count ? lines : nil;
-}
-
-// Content: [ { Type: "Vocal", Text, StartTime, EndTime } ] — timed by the line, the words inside it
-// left to the mod's own estimate, as Spotify's own lines and LRCLIB's are.
-static NSArray<SGKaraokeLine *> *linesFromLines(NSArray *content) {
- NSMutableArray<NSNumber *> *starts = [NSMutableArray array];
- NSMutableArray<NSString *> *texts = [NSMutableArray array];
- for (id raw in content ?: @[]) {
- NSDictionary *vocal = dictionaryIn(raw);
- id text = vocal[@"Text"];
- if (![text isKindOfClass:NSString.class]) continue;
- [starts addObject:@(msIn(vocal[@"StartTime"]))];
- [texts addObject:text];
- }
- return SGKaraokeEstimatedLines(starts, texts);
-}
-
-// What the server actually sent, named rather than quoted: the field names and counts, never the
-// words. For telling a document that has no timing from one whose timing we failed to read.
-static NSString *shapeOf(NSDictionary *document) {
- NSMutableString *shape = [NSMutableString stringWithFormat:@"Type=%@ keys=[%@]",
- document[@"Type"], [document.allKeys componentsJoinedByString:@" "]];
- NSArray *content = arrayIn(document[@"Content"]);
- if (content) [shape appendFormat:@" Content=%lu", (unsigned long)content.count];
- NSDictionary *first = dictionaryIn(content.firstObject);
- if (first) [shape appendFormat:@" Content[0]=[%@]", [first.allKeys componentsJoinedByString:@" "]];
- NSDictionary *lead = dictionaryIn(first[@"Lead"]);
- if (lead) [shape appendFormat:@" Lead=[%@] syllables=%lu", [lead.allKeys componentsJoinedByString:@" "],
- (unsigned long)arrayIn(lead[@"Syllables"]).count];
- NSDictionary *syllable = dictionaryIn(arrayIn(lead[@"Syllables"]).firstObject);
- if (syllable) [shape appendFormat:@" Syllable[0]=[%@]", [syllable.allKeys componentsJoinedByString:@" "]];
- NSArray *staticLines = arrayIn(document[@"Lines"]);
- if (staticLines) [shape appendFormat:@" Lines=%lu", (unsigned long)staticLines.count];
- // Whose words these are, where the document says so: a static reply is text Spicy is passing on
- // from somewhere else, and its name tells us why it came without timing.
- if (document[@"source"]) [shape appendFormat:@" source=%@", document[@"source"]];
- NSDictionary *staticLine = dictionaryIn(staticLines.firstObject);
- if (staticLine) [shape appendFormat:@" Lines[0]=[%@]", [staticLine.allKeys componentsJoinedByString:@" "]];
- return shape;
-}
-
-#pragma mark - the source
-
-// The API answers a browser. The extension runs inside Spotify's desktop client, which is Chromium,
-// and the server reads the identity Chromium puts on every request by itself — none of which a
-// native URLSession sends. Without it the reply is the plain-text tier rather than Apple Music's
-// syllables, which is why hundreds of tracks came back Type=Static.
-//
-// Spicy Lyrics' author was asked directly (2026-09-20) and allowed the mod to present itself this
-// way, on the one condition that it stays open source, which spoti.pw is. He said he would not add a
-// client of his own for us, and that this is the way, as EeveeSpotify already does it.
-static NSDictionary<NSString *, NSString *> *desktopClient(void) {
- return @{
- @"Origin": @"https://xpui.app.spotify.com",
- @"Referer": @"https://xpui.app.spotify.com/",
- @"User-Agent": @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
- "Chrome/146.0.7680.179 Spotify/1.2.92.148 Safari/537.36",
- @"sec-ch-ua": @"\"Not-A.Brand\";v=\"24\", \"Chromium\";v=\"146\"",
- @"sec-ch-ua-mobile": @"?0",
- @"sec-ch-ua-platform": @"\"Windows\"",
- @"sec-fetch-site": @"cross-site",
- @"sec-fetch-mode": @"cors",
- @"sec-fetch-dest": @"empty",
- @"Accept": @"*/*",
- @"Accept-Language": @"en-Latn-US,en-US;q=0.9,en-Latn;q=0.8,en;q=0.7",
- @"priority": @"u=1, i",
- // Accept-Encoding is deliberately left to NSURLSession, which asks for what it can actually
- // decode. Claiming br and zstd as the browser does risks a body nothing here can read.
- };
-}
-
-SGLyricsAsk SGSpicyLyricsAsk = ^(SGLyricsQuery *query, void (^done)(SGLyricsResult *result)) {
- NSString *authorization = SGKaraokeSpotifyAuthorization();
- if (!query.trackID.length || !authorization.length) {
- SGLog(@"spicy: nothing to ask with for %@%@", query.trackID,
- authorization.length ? @"" : @", no request of Spotify's own seen yet to borrow the token from");
- done(nil);
- return;
- }
- NSDictionary *body = @{
- @"queries": @[@{@"operation": @"lyrics", @"variables": @{@"id": query.trackID, @"auth": kAuthHeader}}],
- @"client": @{@"version": kClientVersion},
- };
- NSURL *url = [NSURL URLWithString:kAPI];
- NSMutableDictionary<NSString *, NSString *> *headers = [desktopClient() mutableCopy];
- headers[@"X-mode"] = @"2"; // answer in the packed shape unpack() reads
- headers[@"SpicyLyrics-Version"] = kClientVersion;
- headers[kAuthHeader] = authorization; // already a "Bearer ..." of Spotify's own making
- SGLyricsPostJSON(url, headers, body, ^(id root) {
- NSDictionary *job = nil;
- for (id raw in arrayIn(dictionaryIn(root)[@"queries"]) ?: @[]) {
- if ([dictionaryIn(raw)[@"operationId"] isEqual:kOperationID]) {
- job = raw;
- break;
- }
- }
- NSDictionary *answer = dictionaryIn(job[@"result"]);
- NSInteger status = [answer[@"httpStatus"] integerValue];
- if (!answer) {
- SGLog(@"spicy: no answer to the query for %@", query.trackID);
- done(nil);
- return;
- }
- // The query's own status rides inside an envelope that is a 200 either way, so the walk is
- // told here about a server too busy to answer: a 503 means the lyrics are being prepared and
- // a later ask will have them, which must not stick to the track as "this one has none".
- if (status == 429 || status >= 500) {
- SGLyricsNoteReply([[NSHTTPURLResponse alloc] initWithURL:url statusCode:status HTTPVersion:nil headerFields:nil], nil);
- }
- if (status != 200) {
- SGLog(@"spicy: %@ answered %ld", query.trackID, (long)status);
- done(nil);
- return;
- }
- NSDictionary *document = dictionaryIn(unpack(answer[@"data"]));
- SGLog(@"spicy: %@ came back as %@", query.trackID, shapeOf(document));
- NSString *type = [document[@"Type"] isKindOfClass:NSString.class] ? document[@"Type"] : nil;
- NSArray *content = arrayIn(document[@"Content"]);
- BOOL wordTimed = [type isEqualToString:@"Syllable"];
- NSArray<SGKaraokeLine *> *lines = wordTimed ? linesFromSyllables(content)
- : [type isEqualToString:@"Line"] ? linesFromLines(content) : nil;
- SGLyricsResult *result = [SGLyricsResult new];
- if (lines) {
- result.synced = YES;
- result.wordTimed = wordTimed;
- result.karaokeLines = lines;
- NSArray<NSNumber *> *starts;
- NSArray<NSString *> *texts;
- SGLyricsPageLines(lines, &starts, &texts);
- result.starts = starts;
- result.texts = texts;
- } else if ([type isEqualToString:@"Static"]) {
- // The words with nothing to time them by: the page shows them, and a source under this
- // one in the order can still time them.
- NSMutableArray<NSNumber *> *starts = [NSMutableArray array];
- NSMutableArray<NSString *> *texts = [NSMutableArray array];
- for (id raw in arrayIn(document[@"Lines"]) ?: @[]) {
- id text = dictionaryIn(raw)[@"Text"];
- if (![text isKindOfClass:NSString.class]) continue;
- [starts addObject:@0];
- [texts addObject:[text length] ? text : @"♪"];
- }
- result.starts = starts;
- result.texts = texts;
- result.karaokeLines = SGKaraokeStaticLines(texts);
- }
- if (!result.texts.count) {
- SGLog(@"spicy: %@ came back as %@ with nothing the page could show", query.trackID, type ?: @"no shape at all");
- done(nil);
- return;
- }
- SGLog(@"spicy: %@ has %lu %@ lines", query.trackID, (unsigned long)result.texts.count,
- result.wordTimed ? @"word timed" : result.synced ? @"line timed" : @"untimed");
- done(result);
- });
-};