Skip to content

Commit 1d9e846

Browse files
author
werwolf2303
committed
Switch to internal spotify api
1 parent 483fb36 commit 1d9e846

376 files changed

Lines changed: 264665 additions & 236972 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Tests

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
1. Request to https://gew4-spclient.spotify.com/playlist/v2/playlist/7ChqjfazL6j5Xf02mayf1g/changes
2+
New playlist id: 7ChqjfazL6j5Xf02mayf1g
3+
4+
Protobuf payload (JSON):
5+
"ListChanges": {
6+
"1 base_revision": "\u0000\u0000\u0000\u0000root",
7+
"2 Delta": {
8+
"2 Op": {
9+
"1 Kind (enum)": 6, (Equals to Kind UPDATE_LIST_ATTRIBUTES)
10+
"6 UpdateListAttributes": {
11+
"1 ListAttributesPartialState": {
12+
"1 ListAttributes": {
13+
"1 name": "Test"
14+
}
15+
}
16+
}
17+
},
18+
"4 Change Info": {
19+
"1 user (not username e.g. gianlucabeil)": "sgwrs6tv9om7cyitvvlv8208w",
20+
"2 timestamp in epoch": 1767941125000
21+
}
22+
},
23+
"3 want_resulting_revisions": 1,
24+
"4 want_sync_result": 1,
25+
"6 nonces": 1
26+
}
27+
28+
Response payload (JSON):
29+
{
30+
"1 base_revision": "\u0000\u0000\u0000\u0001Q���!$N���f��\u0007<\u0013,��F",
31+
"7 Diff": {
32+
"1 from_revision": "\u0000\u0000\u0000\u0001Q���!$N���f��\u0007<\u0013,��F",
33+
"3 to_revision": "\u0000\u0000\u0000\u0001Q���!$N���f��\u0007<\u0013,��F"
34+
},
35+
"8 resulting_revisions": "\u0000\u0000\u0000\u0001Q���!$N���f��\u0007<\u0013,��F"
36+
}
37+
38+
39+
40+
Image uploading to playlist.
41+
42+
Client makes request to: https://gew4-spclient.spotify.com/playlist/v2/playlist/7ChqjfazL6j5Xf02mayf1g/register-image
43+
Playlist id: 7ChqjfazL6j5Xf02mayf1g
44+
45+
Payload x-www-form-urlencoded:
46+
47+
oab67706c21f54c3a237fefd7f752b85d.1767962651825.7e7ec4d056fdf4def6ae32c1058498e0e6524df0a222ddefe97985d8d639c9f3
48+
49+
separated by dots
50+
51+
oab67706c21f54c3a237fefd7f752b85d = ?
52+
1767962651825 = unix timestamp (epoch)
53+
7e 7e c4 d0 56 fd f4 de f6 ae 32 c1 05 84 98 e0 e6 52 4d f0 a2 22 dd ef e9 79 85 d8 d6 39 c9 f3 = ?
54+

available_svgs_viewer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from tkinter import *
2-
import tkinter
31
import os
2+
import tkinter
43
import tksvg
4+
from tkinter import *
55
from tkscrolledframe import ScrolledFrame
66

77
gui = tkinter.Tk()

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import subprocess
33
import sys
44
import zipfile
5-
from init import doInit
65

6+
from init import doInit
77

88
JAR_PATH = "target/NTify.jar"
99

i18nhelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import os
3-
import sys
43
import re
4+
import sys
55

66
root = "src/main/java"
77
langf = "src/main/resources/lang/"

init.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import shutil, errno
2-
import os
3-
import fnmatch
1+
import errno
42
import fileinput
3+
import fnmatch
4+
import os
5+
import shutil
56
import sys
67

78

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
<artifactId>commons-io</artifactId>
2222
<version>2.14.0</version>
2323
</dependency>
24-
<dependency>
25-
<groupId>org.json</groupId>
26-
<artifactId>json</artifactId>
27-
<version>20231013</version>
28-
</dependency>
2924
<dependency>
3025
<groupId>com.formdev</groupId>
3126
<artifactId>flatlaf</artifactId>

searchv2.txt

Lines changed: 50201 additions & 0 deletions
Large diffs are not rendered by default.

src/main/java/com/spotifyxp/Initiator.java

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
import com.spotifyxp.theming.ThemeLoader;
4141
import com.spotifyxp.updater.Updater;
4242
import com.spotifyxp.updater.UpdaterUI;
43-
import com.spotifyxp.utils.*;
43+
import com.spotifyxp.utils.ApplicationUtils;
44+
import com.spotifyxp.utils.ArchitectureDetection;
45+
import com.spotifyxp.utils.GraphicalMessage;
46+
import com.spotifyxp.utils.Utils;
4447
import okhttp3.*;
4548
import org.jetbrains.annotations.NotNull;
4649
import org.jetbrains.annotations.Nullable;
@@ -64,62 +67,68 @@ public class Initiator {
6467
static final Thread hook = new Thread(PlayerArea::saveCurrentState, "Save play state");
6568

6669
public static void main(String[] args) {
67-
PublicValues.argParser.parseArguments(args); //Parsing the arguments
68-
initEvents(); //Initializing the event support
69-
new SplashPanel().show(); //Initializing the splash panel
70-
System.setProperty("http.agent", ApplicationUtils.getUserAgent()); //Setting the user agent string that SpotifyXP uses
71-
checkDebug(); //Checking if debug is enabled
72-
detectOS(); //Detecting the operating system
73-
detectArchitecture();
74-
checkSetup();
75-
initLanguageSupport(); //Initializing the language support
76-
initConfig(); //Initializing the configuration
7770
try {
78-
PublicValues.cache = new Cache(); //Initialize cache
79-
} catch (IOException e) {
80-
GraphicalMessage.sorryErrorExit("Failed to create cache: " + e.getMessage());
81-
}
82-
checkLogPrintStream(); //Checking some stuff after config is available
83-
setLanguage(); //Set the language to the one specified in the config
84-
creatingLock(); //Creating the 'LOCK' file
85-
PublicValues.defaultHttpClient = new OkHttpClient.Builder()
86-
.addNetworkInterceptor(new Interceptor() {
87-
@Override
88-
public @NotNull Response intercept(@NotNull Interceptor.Chain chain) throws IOException {
89-
if(chain.request().headers().get("User-Agent").contains("Spotify/")) return chain.proceed(chain.request());
90-
return chain.proceed(chain.request().newBuilder()
91-
.header("User-Agent", ApplicationUtils.getUserAgent())
92-
.build());
93-
}
94-
})
95-
.build(); //Creating the default http client
96-
initProxy();
97-
checkTrustStore();
98-
checkUpdate();
99-
if(Flags.videoPlaybackSupport) initializeVideoPlayback();
100-
loadExtensions(); //Loading extensions if there are any
101-
initGEH(); //Initializing the global exception handler
102-
storeArguments(args); //Storing the program arguments in PublicValues.class
103-
parseAudioQuality(); //Parsing the audio quality
104-
initThemes(); //Initializing the theming support
105-
addShutdownHook(); //Adding the shutdown hook
106-
initAPI(); //Initializing all the apis used
107-
if (PublicValues.enableMediaControl)
108-
createKeyListener(); //Starting the key listener (For Play/Pause/Previous/Next)
109-
initTrayIcon(); //Creating the tray icon
110-
try {
111-
initGUI(); //Initializing the GUI
112-
} catch (IOException e) {
71+
PublicValues.argParser.parseArguments(args); //Parsing the arguments
72+
initEvents(); //Initializing the event support
73+
new SplashPanel().show(); //Initializing the splash panel
74+
System.setProperty("http.agent", ApplicationUtils.getUserAgent()); //Setting the user agent string that SpotifyXP uses
75+
checkDebug(); //Checking if debug is enabled
76+
detectOS(); //Detecting the operating system
77+
detectArchitecture();
78+
checkSetup();
79+
initLanguageSupport(); //Initializing the language support
80+
initConfig(); //Initializing the configuration
81+
try {
82+
PublicValues.cache = new Cache(); //Initialize cache
83+
} catch (IOException e) {
84+
GraphicalMessage.sorryErrorExit("Failed to create cache: " + e.getMessage());
85+
}
86+
checkLogPrintStream(); //Checking some stuff after config is available
87+
setLanguage(); //Set the language to the one specified in the config
88+
creatingLock(); //Creating the 'LOCK' file
89+
PublicValues.defaultHttpClient = new OkHttpClient.Builder()
90+
.addNetworkInterceptor(new Interceptor() {
91+
@Override
92+
public @NotNull Response intercept(@NotNull Interceptor.Chain chain) throws IOException {
93+
if (chain.request().headers().get("User-Agent").contains("Spotify/"))
94+
return chain.proceed(chain.request());
95+
return chain.proceed(chain.request().newBuilder()
96+
.header("User-Agent", ApplicationUtils.getUserAgent())
97+
.build());
98+
}
99+
})
100+
.build(); //Creating the default http client
101+
initProxy();
102+
checkTrustStore();
103+
checkUpdate();
104+
if (Flags.videoPlaybackSupport) initializeVideoPlayback();
105+
loadExtensions(); //Loading extensions if there are any
106+
initGEH(); //Initializing the global exception handler
107+
storeArguments(args); //Storing the program arguments in PublicValues.class
108+
parseAudioQuality(); //Parsing the audio quality
109+
initThemes(); //Initializing the theming support
110+
addShutdownHook(); //Adding the shutdown hook
111+
initAPI(); //Initializing all the apis used
112+
if (PublicValues.enableMediaControl)
113+
createKeyListener(); //Starting the key listener (For Play/Pause/Previous/Next)
114+
initTrayIcon(); //Creating the tray icon
115+
try {
116+
initGUI(); //Initializing the GUI
117+
} catch (IOException e) {
118+
ConsoleLogging.Throwable(e);
119+
GraphicalMessage.sorryError("Critical exception in GUI initialization");
120+
}
121+
SplashPanel.hide(); //Hiding the splash panel
122+
}catch (Exception e) {
113123
ConsoleLogging.Throwable(e);
114-
GraphicalMessage.sorryError("Critical exception in GUI initialization");
124+
GraphicalMessage.openException(e);
115125
}
116-
SplashPanel.hide(); //Hiding the splash panel
117126
}
118127

119128
static void checkTrustStore() {
120129
try {
121130
Request request = new Request.Builder()
122-
.url("https://spclient.wg.spotify.com/live-events-view/spotify.liveeventsview.v2.LiveEventsFeedService/GetPage")
131+
.url("https://spclient.wg.spotify.com/reachability/check")
123132
.build();
124133

125134
PublicValues.defaultHttpClient.newCall(request).execute();
@@ -128,7 +137,7 @@ static void checkTrustStore() {
128137
int response = JOptionPane.showConfirmDialog(null, "", "", JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
129138
if (response == JOptionPane.OK_OPTION) {
130139
try {
131-
ConnectionUtils.openBrowser("https://github.com/JohnTHaller/RootCertificateUpdatesForLegacyWindows");
140+
Utils.openBrowser("https://github.com/JohnTHaller/RootCertificateUpdatesForLegacyWindows");
132141
} catch (URISyntaxException | IOException ex) {
133142
throw new RuntimeException(ex);
134143
}
@@ -214,7 +223,7 @@ static void checkDebug() {
214223
}
215224
}
216225

217-
static void detectOS() {
226+
static void detectOS() throws IOException {
218227
SplashPanel.linfo.setText("Detecting operating system...");
219228
PublicValues.osType = libDetect.getDetectedOS();
220229
new SupportModuleLoader().loadModules();
@@ -242,7 +251,7 @@ static void checkLogPrintStream() {
242251
PublicValues.logPrintStream.checkLogFiles();
243252
}
244253

245-
static void initializeVideoPlayback() {
254+
static void initializeVideoPlayback() throws IOException {
246255
if(Flags.videoPlaybackSupport) {
247256
try {
248257
Class<?> util = Class.forName("com.spotifyxp.deps.uk.co.caprica.vlcj.SPXPInit");
@@ -262,7 +271,7 @@ static void initEvents() {
262271

263272
static void checkUpdate() {
264273
try {
265-
if(new Resources().readToInputStream("commit_id.txt") == null) {
274+
if (Initiator.class.getResourceAsStream("commit_id.txt") == null) {
266275
PublicValues.updaterDisabled = true;
267276
return;
268277
}
@@ -373,9 +382,7 @@ static void createKeyListener() {
373382

374383
static void initAPI() {
375384
SplashPanel.linfo.setText("Creating api...");
376-
InstanceManager.getSpotifyAPI();
377385
InstanceManager.getPlayer();
378-
InstanceManager.getPkce();
379386
SplashPanel.linfo.setText("Create advanced api key...");
380387
InstanceManager.getUnofficialSpotifyApi();
381388
}

src/main/java/com/spotifyxp/PublicValues.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import javax.swing.*;
4444
import java.awt.*;
4545
import java.io.File;
46+
import java.io.IOException;
4647
import java.util.ArrayList;
4748

4849
@SuppressWarnings("CanBeFinal")
@@ -60,16 +61,32 @@ public static Dimension getApplicationDimensions() {
6061

6162
public static ArchitectureDetection.Architecture architecture = ArchitectureDetection.Architecture.x86;
6263
public static libLanguage language = null;
63-
public static String fileslocation = System.getenv("appdata") + File.separator + ApplicationUtils.getName();
64+
public static String fileslocation;
65+
66+
static {
67+
try {
68+
fileslocation = System.getenv("appdata") + File.separator + ApplicationUtils.getName();
69+
} catch (IOException e) {
70+
throw new RuntimeException(e);
71+
}
72+
}
73+
6474
public static String configfilepath = fileslocation + File.separator + "config.json";
6575
public static Config config = null;
6676
public static Session session;
6777
public static boolean debug = false;
6878
public static Quality quality = null;
6979
public static String[] args = null;
70-
@Deprecated
71-
public static String appLocation = fileslocation;
72-
public static String deviceName = ApplicationUtils.getName();
80+
public static String deviceName;
81+
82+
static {
83+
try {
84+
deviceName = ApplicationUtils.getName();
85+
} catch (IOException e) {
86+
throw new RuntimeException(e);
87+
}
88+
}
89+
7390
public static Theme theme = null;
7491
public static libDetect.OSType osType;
7592
public static boolean foundSetupArgument = false;

src/main/java/com/spotifyxp/api/GitHubAPI.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
import com.google.gson.Gson;
1919
import com.google.gson.reflect.TypeToken;
20-
import com.spotifyxp.utils.ConnectionUtils;
20+
import com.spotifyxp.PublicValues;
21+
import okhttp3.Request;
2122

2223
import java.io.IOException;
2324
import java.io.Serializable;
24-
import java.util.HashMap;
2525
import java.util.List;
2626

2727
public class GitHubAPI {
@@ -39,7 +39,10 @@ public static class Asset implements Serializable {
3939
}
4040

4141
public static List<Release> getReleases() throws IOException {
42-
List<Release> release = new Gson().fromJson(ConnectionUtils.makeGet("https://api.github.com/repos/NTifyApp/NTify/releases", new HashMap<>()), new TypeToken<List<Release>>(){}.getType());
42+
List<Release> release = new Gson().fromJson(PublicValues.defaultHttpClient.newCall(new Request.Builder()
43+
.url("https://api.github.com/repos/NTifyApp/NTify/releases")
44+
.get()
45+
.build()).execute().body().string(), new TypeToken<List<Release>>(){}.getType());
4346
for (Release r : release) {
4447
if(r.assets.isEmpty()) continue;
4548
r.assets.get(0).url = "https://github.com/NTifyApp/NTify/releases/download/" + r.tag_name + "/NTify.jar";

0 commit comments

Comments
 (0)