Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

User exits

moody_bluemoody_blue Posts: 2,267 Plex Pass

Would it be possible to implement user exits in PlexConnect ? More specifically, I would love to call a script to launch PMS when I enters trailers because PMS is not allowing my Syno to sleep. Other users have similar needs, such as sending WOL magic packet.


  • baabaa Posts: 3,954 Forum Mod

    When you enter trailers, PlexConnect is notified as "application.js" is requested. Later the discovery takes place (as requested by application.js/atv.onAppEntry), another place to hook into - see also https://forums.plex.tv/discussion/98634/sending-wol-magic-packet

    Currently there is no indication to PlexConnect when you exit trailers - though there might be a similar aTV/js function, something like atv.onAppExit but I don't know for sure. That function would need to communicate to the python side...

    How do you want to specify these externals (plugins?)? Just doing something like
    if exists("enter.bat") run("enter.bat") - same with exit? Have settings to allow/disable that feature along with a list of commands to run?

    Thinking about it, it might be easier to implement some timeout detection, ie. I haven't been called for like 5 minutes? But then we have to make sure to not shut down the NAS as long as the movie is actually played.

  • moody_bluemoody_blue Posts: 2,267 Plex Pass
    edited December 2015

    I don't know about others, maybe you can initiate a poll to ask, but I don't need a user exit to switch off PMS. I prefer to put a rule in the Syno to switch PMS off every day at 2AM, for example, but leave the NAS running 24x7 and let it sleep according to other rules.

    I agree with your approach of if exists("enter.bat") run("enter.bat") but maybe a py function would be more platform independent. Ideally with a new parameter in Settings.cfg to indicate which folder contains the user functions.

    Timeout exit can be dangerous to switch off PMS. It's not only the question of "am I playing anything" but also "is PMS streaming to other devices as well". But such exit could be helpfull for other purposes (cannot imagine which ones, I don't have the need).

  • moody_bluemoody_blue Posts: 2,267 Plex Pass
    edited December 2015

    What do you think about DNSServer.py (following line 370) to put a user exit to start (or wake up) PMS ?

  • moody_bluemoody_blue Posts: 2,267 Plex Pass

    I've modified DNSServer.py and now it suits my needs:

    • Added import os after import sys
    • Added os.system('sh restartplex.sh') after dprint(name, 1, "***intercept request")
      For Synology the script to start PMS can be as follows

    service=$(/var/packages/Plex\ Media\ Server/scripts//start-stop-status status)
    if [ "$service" == "Plex is running" ]
    echo "Plex is running" > ./plexstatus.log
    echo "Plex is not running" > ./plexstatus.log
    /var/packages/Plex\ Media\ Server/scripts//start-stop-status start
    echo "Starting Plex" >> ./plexstatus.log

Sign In or Register to comment.