kodi-community-addons / plugin.audio.spotify

Unofficial spotify plugin for Kodi
GNU General Public License v3.0
295 stars 103 forks source link

Change for Python 3 #144

Open ldsz opened 4 years ago

ldsz commented 4 years ago

Change to make the plugin compatible with Python 3 and Kodi 19

zzggbb commented 3 years ago

Hey I appreciate this fork a ton, thank you for putting all this work into it! It is working great. My only problem is that I can't use the kodi machine through spotify connect. my kodi machine shows up on my phone under the list of devices to connect to, but it says "Can't play this right now".

Screen Shot 2021-03-04 at 1 21 26 AM
ldsz commented 3 years ago

Hi, spotify connect was experimental and I didn't make any changes. On my side, device is available but nothing is playing. I'll try to look at it.

zzggbb commented 3 years ago

I've also been able to connect to the kodi machine through my spotify phone app, but couldn't play or do anything. But sometimes it just says "Can't play this right now".

Another bit of feedback: After clicking on a song to play, sometimes it takes a while to actually start playing (5-10 seconds). There is a spinning animation that displays after clicking but before the song plays. Also, there is the same delay (5-10 seconds) before the next song in a playlist automatically plays after a song ends. This playlist delay doesn't happen every time, but the song-clicking delay happens very frequently.

ldsz commented 3 years ago

You're right, I have the same issue. Maybe it's linked to Spotify rate limiting. If we send to much request, we have to wait a number of second before we can try again.

david-morris commented 3 years ago

Hi, I am looking into the issue with spotify connect, is that blocking this merge? Right now I'm looking at spotty, and I'm seeing that that project hasn't had any commits in 17 months (which still means the included version is obsolete), while the upstream librespot has had commits as of 20 days ago.

If using librespot directly is feasible, how should we go about making it easier to update? It's written in rust. I'm thinking maybe a submodule and update_librespot.sh situation, but this is a new problem to me.

david-morris commented 3 years ago

I've looked at librespot and spotty. It looks like replacing spotty with upstream librespot would require writing a new integration bridge in rust. That seems like it should be in a different pull request.

ldsz commented 3 years ago

Hi, in this plugin, Spotty is used to control a LMS server. To use Spotify Connect, a second service of Spotty is started. I don't know why the same service is not used ... That second service might be replaced by libspot but I thing it's better to make a choose between librespot and spotty to control everything.

ldsz commented 3 years ago

I've just updated a new version on my fork. i've made some progress with Spotify Connect. It plays song but pause/resume and volume are not working.

Feenichs commented 3 years ago

Hi! I could use some advise on how to install this in kodi. Thanks for your work. Kind regards!

glk1001 commented 3 years ago

Hi, I'm also having trouble with playback. Everything else seems fine until I select track and hit play. Spinning cursor icon comes up then after about 30 seconds gives up. I'm using Kodi 19.1 on Ubuntu 20.04.2. The relevant part of the Kodi log follows. I'm happy to do more ongoing testing if you want some help.

Thanks, glk

============ 2021-06-10 19:43:32.304 T:5900 INFO : plugin.audio.spotify --> b'reported architecture: x86_64' 2021-06-10 19:43:32.304 T:5900 INFO : plugin.audio.spotify --> b'Architecture detected. Using spotty binary /home/xxx/.kodi/addons/plugin.audio.spotify/resources/lib/spotty/x86-linux/spotty-x86_64' 2021-06-10 19:43:32.312 T:5900 INFO : plugin.audio.spotify --> b'ok spotty v0.20.0\n{"debug":false,"lms-auth":true,"ogg-direct":true,"version":"0.20.0","volume-normalisation":true}\n' 2021-06-10 19:43:32.314 T:5913 ERROR : [10/Jun/2021:19:43:32] ENGINE Bus STARTING

2021-06-10 19:43:32.315 T:5900 INFO : plugin.audio.spotify --> b'started webproxy at port 52308' 2021-06-10 19:43:32.315 T:5913 ERROR : [10/Jun/2021:19:43:32] ENGINE Started monitor thread 'Autoreloader'.

2021-06-10 19:43:32.318 T:5900 INFO : plugin.audio.spotify --> b'Retrieving auth token....' 2021-06-10 19:43:32.417 T:5913 ERROR : [10/Jun/2021:19:43:32] ENGINE Serving on http://127.0.0.1:52308

2021-06-10 19:43:32.417 T:5913 ERROR : [10/Jun/2021:19:43:32] ENGINE Bus STARTED

2021-06-10 19:43:33.360 T:5900 INFO : plugin.audio.spotify --> b'request_token_spotty stdout: b\'{"accessToken":"yyy","expiresIn":3600,"tokenType":"Bearer","scope":["user-read-playback-state","user-read-currently-playing","user-modify-playback-state","playlist-read-private","playlist-read-collaborative","playlist-modify-public","playlist-modify-private","user-follow-modify","user-follow-read","user-library-read","user-library-modify","user-read-private","user-read-email","user-read-birthdate","user-top-read"]}\n\'' 2021-06-10 19:43:33.364 T:5900 INFO : plugin.audio.spotify --> b'Retrieved auth token' 2021-06-10 19:43:33.581 T:5900 INFO : plugin.audio.spotify --> b'Logged in to Spotify - Username: zzz' 2021-06-10 19:43:33.581 T:5933 INFO : plugin.audio.spotify --> b'Start Spotify Connect Daemon' 2021-06-10 19:43:33.581 T:5933 INFO : plugin.audio.spotify --> b'trying AP Port 443' 2021-06-10 19:43:35.988 T:5875 INFO : Loading skin file: MyMusicNav.xml, load type: KEEP_IN_MEMORY 2021-06-10 19:43:36.012 T:5875 INFO : Loading skin file: DialogConfirm.xml, load type: KEEP_IN_MEMORY 2021-06-10 19:43:36.016 T:5946 INFO : initializing python engine. 2021-06-10 19:43:36.954 T:5901 INFO : CPythonInvoker(1, /home/xxx/.kodi/addons/service.xbmc.versioncheck/resources/lib/runner.py): script successfully run 2021-06-10 19:43:37.019 T:5901 INFO : Python interpreter stopped 2021-06-10 19:43:39.674 T:5946 INFO : CPythonInvoker(2, /home/xxx/.kodi/addons/plugin.audio.spotify/plugin.py): script successfully run 2021-06-10 19:43:39.702 T:5946 INFO : Python interpreter stopped 2021-06-10 19:44:04.657 T:5950 INFO : initializing python engine. 2021-06-10 19:44:05.138 T:5950 INFO : CPythonInvoker(3, /home/xxx/.kodi/addons/plugin.audio.spotify/plugin.py): script successfully run 2021-06-10 19:44:05.182 T:5950 INFO : Python interpreter stopped 2021-06-10 19:44:07.132 T:5953 INFO : initializing python engine. 2021-06-10 19:44:07.859 T:5953 INFO : CPythonInvoker(4, /home/xxx/.kodi/addons/plugin.audio.spotify/plugin.py): script successfully run 2021-06-10 19:44:07.902 T:5953 INFO : Python interpreter stopped 2021-06-10 19:44:12.026 T:5922 INFO : plugin.audio.spotify --> b'!! Full File. Size : 59094044 ' 2021-06-10 19:44:12.028 T:5922 INFO : plugin.audio.spotify --> b'start transfer for track 1i5lXpzjo8qBAVRvEoBl7Z - range: 0' 2021-06-10 19:44:12.040 T:5922 INFO : plugin.audio.spotify --> b'Infos : Track : 1i5lXpzjo8qBAVRvEoBl7Z' 2021-06-10 19:44:13.807 T:5921 INFO : plugin.audio.spotify --> b'!! Full File. Size : 59094044 ' 2021-06-10 19:44:13.808 T:5921 INFO : plugin.audio.spotify --> b'WHOOPS!!! Running spotty still handling same request - leave it alone.' 2021-06-10 19:44:23.895 T:5893 ERROR : CCurlFile::FillBuffer - Failed: Transferred a partial file(18) 2021-06-10 19:44:23.895 T:5893 ERROR : Open - Error, could not open file http://localhost:52308/track/1i5lXpzjo8qBAVRvEoBl7Z/335.335 2021-06-10 19:44:23.895 T:5893 ERROR : Init: Error creating demuxer 2021-06-10 19:44:23.895 T:5893 ERROR : CAudioDecoder: Unable to Init Codec while loading file http://localhost:52308/track/1i5lXpzjo8qBAVRvEoBl7Z/335.335 2021-06-10 19:44:23.895 T:5893 WARNING : PAPlayer::QueueNextFileEx - Failed to create the decoder 2021-06-10 19:44:23.897 T:5922 ERROR : [10/Jun/2021:19:44:23] NATIVE_ADAPTER Traceback (most recent call last): File "/home/xxx/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cpnative_server.py", line 89, in respond self.send_response( File "/home/xxx/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cpnative_server.py", line 117, in send_response req.write(seg) File "/home/xxx/.kodi/addons/plugin.audio.spotify/resources/lib/cheroot/server.py", line 1133, in write self.conn.wfile.write(chunk) File "/home/xxx/.kodi/addons/plugin.audio.spotify/resources/lib/cheroot/makefile.py", line 438, in write res = super().write(val, *args, **kwargs) File "/home/xxx/.kodi/addons/plugin.audio.spotify/resources/lib/cheroot/makefile.py", line 36, in write self._flush_unlocked() File "/home/xxx/.kodi/addons/plugin.audio.spotify/resources/lib/cheroot/makefile.py", line 45, in _flush_unlocked n = self.raw.write(bytes(self._write_buf)) File "/usr/lib/python3.8/socket.py", line 687, in write return self._sock.send(b) ConnectionResetError: [Errno 104] Connection reset by peer

2021-06-10 19:44:23.898 T:5922 INFO : plugin.audio.spotify --> b'FINISH transfer for track 1i5lXpzjo8qBAVRvEoBl7Z - range 0 - written 2621440' 2021-06-10 19:44:24.080 T:5875 INFO : ADDON: Dll Destroyed - Goom 2021-06-10 19:44:26.954 T:5875 INFO : Stopping player