Skip to content

Commit 52c7d99

Browse files
committed
Added a couple of tweaks from the latest Spotify build
1 parent f5415bf commit 52c7d99

4 files changed

Lines changed: 21 additions & 9 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/core/Session.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.jetbrains.annotations.NotNull;
66
import xyz.gianlu.librespot.AbsConfiguration;
77
import xyz.gianlu.librespot.Version;
8+
import xyz.gianlu.librespot.common.Utils;
89
import xyz.gianlu.librespot.common.proto.Authentication;
910
import xyz.gianlu.librespot.common.proto.Keyexchange;
1011
import xyz.gianlu.librespot.crypto.CipherPair;
@@ -221,6 +222,10 @@ private void authenticate(@NotNull Authentication.LoginCredentials credentials)
221222
player = new Player(inner.configuration, inner.configuration, this);
222223

223224
LOGGER.info(String.format("Authenticated as %s!", apWelcome.getCanonicalUsername()));
225+
226+
byte[] bytes0x0f = new byte[20];
227+
random().nextBytes(bytes0x0f);
228+
send(Packet.Type.Unknown_0x0f, bytes0x0f);
224229
} else if (packet.is(Packet.Type.AuthFailure)) {
225230
throw new SpotifyAuthenticationException(Keyexchange.APLoginFailed.parseFrom(packet.payload));
226231
} else {
@@ -563,6 +568,9 @@ public void run() {
563568
licenseVersion.get(buffer);
564569
LOGGER.info(String.format("Received LicenseVersion: %d, %s", id, new String(buffer)));
565570
break;
571+
case Unknown_0x10:
572+
LOGGER.debug("Received 0x10: " + Utils.bytesToHex(packet.payload));
573+
break;
566574
case MercurySub:
567575
case MercuryUnsub:
568576
case MercurySubEvent:

core/src/main/java/xyz/gianlu/librespot/crypto/Packet.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ public enum Type {
5151
MercurySub(0xb3),
5252
MercuryUnsub(0xb4),
5353
MercurySubEvent(0xb5),
54-
UnknownData_AllZeros(0x1f);
54+
UnknownData_AllZeros(0x1f),
55+
Unknown_0x4f(0x4f),
56+
Unknown_0x0f(0x0f),
57+
Unknown_0x10(0x10);
5558

5659
public final byte val;
5760

core/src/main/java/xyz/gianlu/librespot/player/ChannelManager.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ void requestChunk(@NotNull ByteString fileId, int index, @NotNull AudioFile file
4545
DataOutputStream out = new DataOutputStream(bytes);
4646

4747
out.writeShort(channel.id);
48-
out.writeByte(0);
49-
out.writeByte(1);
50-
out.writeShort(0);
51-
out.writeInt(0);
52-
out.writeInt(0x00009C40);
53-
out.writeInt(0x00020000);
48+
out.writeInt(0x00000000);
49+
out.writeInt(0x00000000);
50+
out.writeInt(0x00004e20);
51+
out.writeInt(0x00030d40);
5452
fileId.writeTo(out);
5553
out.writeInt(start);
5654
out.writeInt(end);

core/src/main/java/xyz/gianlu/librespot/player/TrackHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import org.jetbrains.annotations.NotNull;
55
import org.jetbrains.annotations.Nullable;
66
import xyz.gianlu.librespot.common.Utils;
7+
import xyz.gianlu.librespot.common.proto.Metadata;
8+
import xyz.gianlu.librespot.common.proto.Spirc;
79
import xyz.gianlu.librespot.core.Session;
10+
import xyz.gianlu.librespot.crypto.Packet;
811
import xyz.gianlu.librespot.mercury.MercuryClient;
912
import xyz.gianlu.librespot.mercury.MercuryRequests;
1013
import xyz.gianlu.librespot.mercury.model.TrackId;
11-
import xyz.gianlu.librespot.common.proto.Metadata;
12-
import xyz.gianlu.librespot.common.proto.Spirc;
1314

1415
import java.io.Closeable;
1516
import java.io.IOException;
@@ -79,6 +80,8 @@ private void load(@NotNull Spirc.TrackRef ref, boolean play, int pos) throws IOE
7980
}
8081
}
8182

83+
session.send(Packet.Type.Unknown_0x4f, new byte[0]);
84+
8285
byte[] key = session.audioKey().getAudioKey(track, file);
8386
AudioFileStreaming audioStreaming = new AudioFileStreaming(session, cacheManager, file, key);
8487
audioStreaming.open();

0 commit comments

Comments
 (0)