Syncplay / syncplay

Client/server to synchronize media playback on mpv/VLC/MPC-HC/MPC-BE on many computers
http://syncplay.pl/
Apache License 2.0
2.11k stars 214 forks source link

Any easy way to communicate with the Syncplay Server in Python? #137

Closed xNinjaKittyx closed 6 years ago

xNinjaKittyx commented 7 years ago

I would like to be able to connect to syncplay with a python script and grab some data from it. Is there any way currently to be able to do it? (v. 1.4.0)

Et0h commented 7 years ago

What information do you want and is it from a server you control?

Not fully up to date, but the Syncplay protocol is explained at http://syncplay.pl/about/protocol/ and Syncplay is open source.

xNinjaKittyx commented 7 years ago

I was looking at the protocol earlier, and I was wondering if it was possible to grab the "Request list of who is playing what in which room."

I was just playing around with my own server and trying to use sockets or requests. Requests just gives me "not a json encoded string" regardless of what input i give it.

Et0h commented 7 years ago

Yes, strings need to be JSON encoded.

Two relevant questions:

  1. Is --isolate-room enabled on the server?
  2. Is it a server you control?

If --isolate-room is not enabled you can just connect to the server using the same strings as Syncplay, login, perform a userlist check, then leave. Without modification you can't get the userlist without logging in first.

If the server is using --isolate-room (and if you want to avoid people seeing the script entering and exiting a room) then you will need to modify protocols.py/server.py to output the information to a local connector (e.g. through a modified version of sendList and/or handleList).

xNinjaKittyx commented 7 years ago

1) --isolate-room is not enabled 2) it is a server I am running on my own computer.

Also, through requests, I am sending JSON-compliant strings. I don't if that counts the same as what you are defining as a "JSON Encoded string".

Personally, it doesn't matter to me if the room sees the script entering and exiting. I just want to be able to grab List Messages.

Et0h commented 7 years ago

Ensure a { at the very beginning of your JSON-encoded string. A { was omitted from the protocol page for the initial hello message but that has now been corrected. If that doesn't work then please share your code (or try it using Telnet or similar).