iamkroot / trakt-scrobbler

Scrobbler for trakt.tv that supports VLC, Plex, MPC-HC, and MPV.
https://github.com/iamkroot/trakt-scrobbler/wiki
GNU General Public License v2.0
450 stars 30 forks source link

[BUG] trakt-scrobbler are not working with syncplay@mpv #266

Closed soredake closed 8 months ago

soredake commented 9 months ago

Describe the bug https://github.com/Syncplay/syncplay/issues/529

After each start input-ipc-path value will be different: изображение

Desktop (please complete the following information):

To Reproduce

Steps to reproduce the behavior:

  1. Install syncplay, trakt-scrobbler and mpv.net from microsoft store
  2. trakts config set players.monitored mpv syncplay@mpv; trakts config set players.mpv.ipc_path \\.\pipe\mpvsocket
  3. Set --input-ipc-server=\\.\pipe\mpvsocket as player arguments in syncplay for mpv.net
  4. Join room, add some media file.
  5. See error in log file

Log file

Click to see log contents

``` 2023-11-24 19:42:37,245 - INFO - MainThread - scrobbler - Started scrobbler thread. 2023-11-24 19:42:37,272 - INFO - MainThread - monitor - Started monitor for mpv 2023-11-24 19:42:37,274 - INFO - mpv - mpv - Unable to connect to MPV. Check ipc path. 2023-11-24 19:42:37,279 - DEBUG - MainThread - monitor - Autoloaded syncplay@mpv ipc_path = \\\\.\\pipe\\mpvsocket 2023-11-24 19:42:37,279 - INFO - MainThread - monitor - Started monitor for syncplay@mpv 2023-11-24 19:42:37,280 - INFO - syncplay@mpv - mpv - Unable to connect to MPV. Check ipc path. ```

I think the problem lies in syncplay, when i set --input-ipc-server=\\.\pipe\mpvsocket as player argument it results in double input-ipc-server изображение

Maybe related https://github.com/Syncplay/syncplay/issues/529

iamkroot commented 8 months ago

Yeah, this looks more like a syncplay bug.

I can think of some ways to go forward-

  1. Making syncplay respect the user config (as suggested in https://github.com/Syncplay/syncplay/issues/529) is definitely the best way to do it IMO. This was already working in previous versions of syncplay (we don't clash with their code) and should be relatively easy to fix from their end.
  2. Bypass the IPC server entirely- write a MPV plugin in Lua/JS that listens for the events we care about (like start, pause, etc.), and sends them over to our monitor via IPC (essentially reinventing the IPC server)
  3. In general, I have been considering implementing a MPRIS monitor - this would allow us to support any player that exposes current media info via that protocol. Main issue would be ensuring we get all the needed info we care about (file paths, etc.). Another big one is that this is also Linux-only, so need to find a Windows equivalent.

Both 2 and 3 are pretty big projects, I'd rather try getting https://github.com/Syncplay/syncplay/issues/529 resolved first.

iamkroot commented 8 months ago

Ok, looking more closely, I think this is a separate issue from https://github.com/Syncplay/syncplay/issues/529

Specifically, according to this-

I think the problem lies in syncplay, when i set --input-ipc-server=\\.\pipe\mpvsocket as player argument it results in double input-ipc-server изображение

The bug seems to be somewhere inside syncplay's configuration parsing/storage. It should not have duplicated the values.

@soredake Could you please try resetting this value to something like the following- image

Save config, then try restarting the scrobbler (and also syncplay if you wish). See if the path is still duplicated.

soredake commented 8 months ago

Without --input-ipc-server=\\.\pipe\mpvsocket: image

With --input-ipc-server=\\.\pipe\mpvsocket: image

Log remains the same:

2024-01-01 19:27:24,929 - DEBUG - MainThread - notifier - Notifications enabled for categories: exception, misc, scrobble.pause, scrobble.resume, scrobble.start, scrobble.stop, trakt
2024-01-01 19:27:25,190 - INFO - MainThread - scrobbler - Started scrobbler thread.
2024-01-01 19:27:25,202 - INFO - MainThread - monitor - Started monitor for mpv
2024-01-01 19:27:25,203 - INFO - mpv - mpv - Unable to connect to MPV. Check ipc path.
2024-01-01 19:27:25,205 - DEBUG - MainThread - monitor - Autoloaded syncplay@mpv ipc_path = \\\\.\\pipe\\mpvsocket
2024-01-01 19:27:25,205 - INFO - MainThread - monitor - Started monitor for syncplay@mpv
2024-01-01 19:27:25,206 - INFO - syncplay@mpv - mpv - Unable to connect to MPV. Check ipc path.
soredake commented 8 months ago

As a workaround i set ipc_path to \\.\pipe\\\.\pipe\mpvsocket and now it works.

iamkroot commented 8 months ago

Without --input-ipc-server=\\.\pipe\mpvsocket: image

Wait, so when you don't provide --input-ipc-server, after a restart, this is shown in the Syncplay UI?

soredake commented 8 months ago

this is shown in the Syncplay UI?

Not in syncplay ui, i use this tool to see what arguments are applied when starting mpv

iamkroot commented 8 months ago

ah that makes more sense. Then I'm pretty sure this is a syncplay bug- it is messing up the args somehow. Closing on our side.

Et0h commented 7 months ago

As per discussion at https://github.com/Syncplay/syncplay/issues/529 I have created https://github.com/Syncplay/syncplay/pull/669 that means that when the user specifies which port mpv should use it will set input-ipc-server it to socket again which should allow a second connection on that socket.

However, looking at https://github.com/iamkroot/trakt-scrobbler/blob/7eef02fcfdefb665de6a77dfba403464f024f2ff/trakt_scrobbler/player_monitors/mpv_wrappers.py it looks like some further changes will be required to get it to work reliably via trakt-scrobbler.

Firstly, if there is a Syncplay.ini or .Syncplay folder in the Syncplay folder then Syncplay will use that in preference to the file in the APPDATA folder. This is what distinguishes the installed version of Syncplay from the portable version of Syncplay.

Secondly, someone can have multiple different player entries for perplayerarguments depending on the path of the player. You can get the perplayerargument for the currently selected player by first looking at the value of playerpath and then use that as the key for which which perplayerargument to use.

Thirdly, it can be set as input-ipc-server rather than --input-ipc-server so just looking for --input-ipc-server might not find it.

In any case, I've now updated Syncplay so that it will automatically create a secondary socket called mpvSyncplaySocket (AKA \\.\\pipe\\mpvSyncplaySocket) if no value for input-ipc-server is specified in the perPlayerArguments for that player. This should make it easier for trakt-scrobbler and other tools to support Syncplay. You can download this build at: https://github.com/Syncplay/syncplay/actions/runs/7766691704