ldsz / plugin.audio.spotify

Unofficial spotify plugin for Kodi 19
GNU General Public License v3.0
47 stars 17 forks source link

Some fixes for spotify connect in my fork #4

Closed Elkropac closed 3 years ago

Elkropac commented 3 years ago

Hi i did some fixes to make this plugin work for me. (spotify connect was not working for me - there was no sound)

Are you interested in merging some of them?

https://github.com/Elkropac/plugin.audio.spotify/commits/master

I could create pull request, if you find some of it useful

ldsz commented 3 years ago

Hi, of course, we can merge the spotty running test and decode UTF removed, Can you tell me why you expose lms ? what was the error ? About the killall Spotty, I think we have to find the architecture first, the following test is made inside utils.py : if architecture.startswith('AMD64') or architecture.startswith('x86_64'):

Elkropac commented 3 years ago

I will use your new version and base my commits on it.

Without lms exposed, i get no sound , when i use spotify connect from other device. On other hand, with lms exposed i get some conflicts with spotty launched twice over itself?

I have no logs now of error on lms, but i remember, there was something in logs when i started debugging it.

Ah, i remembered, i captured packets using tshark and got this, without lms exposed

POST /lms/jsonrpc.js HTTP/1.1
Host: localhost:52308
X-Scanner: 1
Content-Type: application/json
Content-Length: 81

{"id": 1,"method":"slim.request","params":["None",["spottyconnect","volume",50]]}HTTP/1.1 404 Not Found
Content-Type: text/html;charset=utf-8
Server: CherryPy/unknown
Date: Sat, 17 Apr 2021 18:09:17 GMT
Content-Length: 1670

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
    <title>404 Not Found</title>
    <style type="text/css">
    #powered_by {
        margin-top: 20px;
        border-top: 2px solid black;
        font-style: italic;
    }

    #traceback {
        color: red;
    }
    </style>
</head>
    <body>
        <h2>404 Not Found</h2>
        <p>The path '/lms/jsonrpc.js' was not found.</p>
        <pre id="traceback">Traceback (most recent call last):
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cprequest.py", line 630, in respond
    self._do_respond(path_info)
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cprequest.py", line 689, in _do_respond
    response.body = self.handler()
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/lib/encoding.py", line 221, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/lib/jsontools.py", line 58, in json_handler
    value = cherrypy.serving.request._json_inner_handler(*args, **kwargs)
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cperror.py", line 416, in __call__
    raise self
cherrypy._cperror.NotFound: (404, "The path '/lms/jsonrpc.js' was not found.")
</pre>
    <div id="powered_by">
      <span>
        Powered by <a href="http://www.cherrypy.org">CherryPy unknown</a>
      </span>
    </div>
    </body>
</html>
Elkropac commented 3 years ago

I noticed, you removed "/lms" from arguments in connect_daemon.py

ldsz commented 3 years ago

yes, it's to correct this issues. The lms path doesn't exist.

Elkropac commented 3 years ago

Well, it does not like it with "localhost:52308/" in connect_daemon.py, line 35 :)

POST //jsonrpc.js HTTP/1.1
Host: localhost:52308
X-Scanner: 1
Content-Type: application/json
Content-Length: 81

{"id": 1,"method":"slim.request","params":["None",["spottyconnect","volume",50]]}HTTP/1.1 400 Bad Request
Content-Length: 50
Content-Type: text/plain

Absolute URI not allowed if server is not a proxy.

and after removing "/" from connect_daemon.py, line 35 , I get this , again

POST /jsonrpc.js HTTP/1.1
Host: localhost:52308
X-Scanner: 1
Content-Type: application/json
Content-Length: 76

{"id": 1,"method":"slim.request","params":["None",["spottyconnect","stop"]]}HTTP/1.1 404 Not Found
Content-Type: text/html;charset=utf-8
Server: CherryPy/unknown
Date: Sun, 18 Apr 2021 10:15:54 GMT
Content-Length: 1463

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
    <title>404 Not Found</title>
    <style type="text/css">
    #powered_by {
        margin-top: 20px;
        border-top: 2px solid black;
        font-style: italic;
    }

    #traceback {
        color: red;
    }
    </style>
</head>
    <body>
        <h2>404 Not Found</h2>
        <p>The path '/jsonrpc.js' was not found.</p>
        <pre id="traceback">Traceback (most recent call last):
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cprequest.py", line 638, in respond
    self._do_respond(path_info)
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/lib/encoding.py", line 219, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/home/prehravac/.kodi/addons/plugin.audio.spotify/resources/lib/cherrypy/_cperror.py", line 416, in __call__
    raise self
cherrypy._cperror.NotFound: (404, "The path '/jsonrpc.js' was not found.")
</pre>
    <div id="powered_by">
      <span>
        Powered by <a href="http://www.cherrypy.org">CherryPy unknown</a>
      </span>
    </div>
    </body>
</html>
ldsz commented 3 years ago

can you try with version 1.2.2 ?

Elkropac commented 3 years ago

I was testing with code, you merged today from my branch, ie with 1.2.2 . When I expose lms in httpproxy.py and /lms in connect_daemon.py , i get sound from kodi, when i use "spotify connect" from my mobile. Without this modification, i get no sound (spotify on my mobile connects to kodi, it shows, it's playing, but there is no sound).

On other hand (with lms exposed), i have some zombie spotty processes, when i want to play music directly from kodi spotify plugin. I don't know, if it's related

ldsz commented 3 years ago

With up-to-date code or 1.2.2, I get sound with spotify connect if I select Kodi as playback device inside the plugin menu first. Is it the same for you or with lms expose you don't have to select kodi in the plugin ?

Elkropac commented 3 years ago

I have "Local playback on this device" selected in plugin

jmbreuer commented 3 years ago

I have "Local playback on this device" selected in plugin

Sounds like a viable fix to the issue I'm also experiencing then

ldsz commented 3 years ago

@Elkropac Thank you for your PRs, I'm now able to use Spotify Connect at start, without device's selection.

Elkropac commented 3 years ago

@ldsz Thanks for your merges. Hope, everything works ok.