Skip to content

Updating to the newest Spotify API#105

Merged
devgianlu merged 161 commits intodevfrom
new-spotify-api
Nov 2, 2019
Merged

Updating to the newest Spotify API#105
devgianlu merged 161 commits intodevfrom
new-spotify-api

Conversation

@devgianlu
Copy link
Copy Markdown
Member

@devgianlu devgianlu commented Jul 5, 2019

This is a pretty consistent PR as we are switching to the new API which relies primarily on HTTPS (finally!).

TODO:

Bugs:

  • Connection drops from time to time (still haven't figured out what causes that)

@devgianlu devgianlu added the enhancement New feature or request label Jul 5, 2019
@devgianlu
Copy link
Copy Markdown
Member Author

devgianlu commented Jul 5, 2019

@sashahilton00 @ashthespy @kingosticks I thought you might be interested in this. The protocol changes are mainly here, this also contains some insights on what has changed.

@ashthespy
Copy link
Copy Markdown
Member

@devgianlu I see you got the websocket dealer also figured out. I didn't look to deeply into the code, but what all is now going through the webgate, and what all is done with mercury? From what I see, you have hm://connect-state/v1/ working?

# Conflicts:
#	api/src/main/java/xyz/gianlu/librespot/api/Main.java
#	core/src/main/java/xyz/gianlu/librespot/core/ZeroconfServer.java
@loeffelpan
Copy link
Copy Markdown

loeffelpan commented Oct 8, 2019

Did you miss my last post?
So, there are no more ideas my state issue?

However, my iOS App looses connection sometimes when playback starts or after skipping.

@devgianlu
Copy link
Copy Markdown
Member Author

I'm working on it without too much success, but I'm making progress. The connection issue has been annotated, will sort everything out at one point.

@crsmoro
Copy link
Copy Markdown
Contributor

crsmoro commented Oct 13, 2019

about this, just a feedback
it seems to be working really fine, my internet connection is really unstable this week, i saw this a couple times.. here is the latest log about it..

2019-10-13 17:24:45 TRACE CdnManager:261 - Chunk 40/60 completed, cdn: audio4-ak-spotify-com.akamaized.net, cached: false, stream: {fileId: 529E26F2F1EFA0C34C5AC38DC1B0CC5453BF06C7}
2019-10-13 17:24:57 DEBUG Player:340 - Playback halted on retrieving chunk 41.
2019-10-13 17:24:58 FATAL CdnManager:299 - Failed requesting chunk from network, index: 41, retried: false
java.net.SocketTimeoutException: timeout
        at okio.SocketAsyncTimeout.newTimeoutException(Okio.kt:159)
        at okio.AsyncTimeout.exit$jvm(AsyncTimeout.kt:203)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:163)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:349)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:222)
        at okhttp3.internal.http1.Http1ExchangeCodec.readHeaderLine(Http1ExchangeCodec.kt:210)
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:181)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:105)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:82)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:37)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
        at okhttp3.RealCall.execute(RealCall.kt:66)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.request(CdnManager.java:314)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.request(CdnManager.java:307)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.requestChunk(CdnManager.java:296)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.access$6(CdnManager.java:283)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer$InternalStream.lambda$0(CdnManager.java:366)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
        at java.net.SocketInputStream.read(SocketInputStream.java:204)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
        at sun.security.ssl.InputRecord.read(InputRecord.java:503)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
        at okio.InputStreamSource.read(Okio.kt:102)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:159)
        ... 28 more
2019-10-13 17:25:08 FATAL CdnManager:299 - Failed requesting chunk from network, index: 44, retried: false
java.net.SocketTimeoutException: timeout
        at okio.SocketAsyncTimeout.newTimeoutException(Okio.kt:159)
        at okio.AsyncTimeout.exit$jvm(AsyncTimeout.kt:203)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:163)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.kt:349)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:222)
        at okhttp3.internal.http1.Http1ExchangeCodec.readHeaderLine(Http1ExchangeCodec.kt:210)
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:181)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:105)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:82)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:37)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
        at okhttp3.RealCall.execute(RealCall.kt:66)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.request(CdnManager.java:314)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.request(CdnManager.java:307)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.requestChunk(CdnManager.java:296)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer.access$6(CdnManager.java:283)
        at xyz.gianlu.librespot.player.feeders.cdn.CdnManager$Streamer$InternalStream.lambda$0(CdnManager.java:366)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
        at java.net.SocketInputStream.read(SocketInputStream.java:204)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
        at sun.security.ssl.InputRecord.read(InputRecord.java:503)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
        at okio.InputStreamSource.read(Okio.kt:102)
        at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:159)
        ... 28 more
2019-10-13 17:25:15 WARN  DealerClient:270 - Did not receive ping in 3 seconds. Reconnecting...
2019-10-13 17:25:15 TRACE DealerClient:176 - Scheduled reconnection attempt in 10 seconds...
2019-10-13 17:25:21 TRACE CdnManager:261 - Chunk 43/60 completed, cdn: audio4-ak-spotify-com.akamaized.net, cached: false, stream: {fileId: 529E26F2F1EFA0C34C5AC38DC1B0CC5453BF06C7}

@devgianlu
Copy link
Copy Markdown
Member Author

@crsmoro Would you say it is fine now? Did it recover each time the connection dropped?

@crsmoro
Copy link
Copy Markdown
Contributor

crsmoro commented Oct 14, 2019

yes, it did

@sashahilton00
Copy link
Copy Markdown
Member

@devgianlu did you get the dealer stuff working with the {"type":"ping"} requests at 30 second intervals? I had a look at #140 and the traffic that i intercept, there is nothing that looks like an ack_id for play.spotify.com wss service, and I see no dealer traffic from the desktop client, so not really sure where the dealer stuff might be coming from?

@l3d00m
Copy link
Copy Markdown
Contributor

l3d00m commented Oct 20, 2019

I hope it's correct to report it here: The podcasts in mixed playlists aka "Daily Drive" are only played sometimes for me. If I start streaming while I'm already in the playlist, it works like it should, but if I'm in a normal playlist and then switch to the mixed playlist, all included podcasts are skipped.

I'm using the newest commit for this (3088373)

@devgianlu
Copy link
Copy Markdown
Member Author

if I'm in a normal playlist and then switch to the mixed playlist, all included podcasts are skipped.

@l3d00m Can't reproduce it, could you provide a log?

@devgianlu
Copy link
Copy Markdown
Member Author

Since #140 has been solved. I'll start squashing the last remaining bugs and hopefully merge this into a new development branch (inspired by librespot-org/librespot#385) by the end of the week.

@devgianlu devgianlu changed the base branch from master to dev November 2, 2019 10:29
@devgianlu devgianlu closed this Nov 2, 2019
@devgianlu devgianlu reopened this Nov 2, 2019
@devgianlu devgianlu merged commit c4f9e9e into dev Nov 2, 2019
@devgianlu devgianlu deleted the new-spotify-api branch November 2, 2019 10:33
@devgianlu
Copy link
Copy Markdown
Member Author

I've just released 1.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.