cniw / mpv-discordRPC

Discord Rich Presence integration for mpv Media Player
MIT License
137 stars 10 forks source link

Python Pypresence better integration #15

Open StratusFearMe21 opened 3 years ago

StratusFearMe21 commented 3 years ago

Hi! It's difficult to get two languages to work together in harmony but I think I have a solution that would allow more people to use this plugin. I was having a problem where your plugin would clog up discord by opening too many instances of python at once and not closing them properly. But my solution allows for python to only be opened once, and then closed only when mpv is finished. It makes lua write to a plain text file in /dev/shm (A linux directory that writes directly to RAM) and then have python read that file every 4 seconds (to avoid asyncio problems) and update discord accordingly. At the moment my implementation only works with Linux because /dev/shm doesn't exist in Windows. But that directory should be able to be easily replaced by a variable in the config file (I don't know how those work yet so I couldn't implement it).

StratusFearMe21 commented 3 years ago

sorry, I was editing an outdated version. Should be fixed now. I also changed the filenames.