OK - did a little more digging into the __init__.py tonight.
I was able to fix the calls to the lock/unlock shell scripts. Where you were calling os.system(path) replace with the following
os.chdir(os.path.dirname(path))
os.system('./' + str(os.path.basename(path)))
This successfully makes the call to the lock shell script and I get the expected result of the hidden library.
---------------------------------------------------------------------------------
Now onto the unlocking -woot! :D
Now that I'm starting to understand Python and Plex APIs a little better - are you expecting to see 2 buttons in the Lock channel? I only see the Lock icon, but I do see in your code an additional item for the Unlock which utilizes the prompt. I'm not seeing this guy at all (see screenshot). I'm wondering if this could be part of my problem - as I originally though they just reused that same icon/button in the channel. How does it look in Windows/MacOS implementations?
**UPDATE**
After thinking about what you said last night, I pulled up Plex on my phone and opened the channel from there. On my phone I do see the Unlock icon and I'm able to successfully unlock the hidden library and it works! Booyah! So this looks to be an issue with the web-console for Plex - are you able to confirm the unlock icon shows up for your Windows/MacOS versions? For some reason the InputDirectoryObject is not being displayed. I'll check on my Roku to see if it shows or not on there.
I think this might be our last roadblock for a working Linux version!
Thoughts?
On a side note, my $PLEX_HOME environment variable got cleared out again. So, I'm not sure if it's just my install or if that's getting cleared on PMS restart - but I would keep that in mind too. I just changed the path in your scripts to the full paths rather than referencing $PLEX_HOME
Nevermind - I forgot to add the environment variable to my server startups. Forgot I rebooted last night for updates.
Do you suggest we change the paths to full paths? I think it would be better for a n00b who wouldn't prolly set or know how to set the home path?
/iSh0w
yes and no, Plex API does state that $PLEX_HOME is the standard, so not sure why it's not set to begin with. I think it should be fine with absolute path as OOTB install goes to there. I'm not sure about other Linux distros though. The biggest downfall with that though is your code becomes tightly coupled to that path - and anyone who isn't in that install path will not be able to use your plugin without modifying your underlying code base.
To be honest, just like chmod a+x instructions, I think this would be another simple addition to the Linux install guide for the plugin. Another option is having some configuration file included or even you might be able to pull the install directory when you do the Library lookup for building the custom plugin.
Just some ideas - but I think the absolute path will work for most cases.
iSh0w - yeah, i can do that and help support the Linux side of thing. I tested your latest build - works directly calling the lock/unlock shell scripts, but the channel controls don't seem to working. I'll debug it a little further later when I have some time.
NaDs has read…
I can assist with windows support - just let me know when you need me

OK iSh0w - did some further testing - like I said, was running into issue getting successful lock/unlock from the channel again. After quite sometime of debugging - found an interesting issue (I think more related to python than the plugin). Essentially, when calling the shell scripts from the python script - the environment variables in the shell scripts were evaluating as null. This threw me for a loop for a bit. So that was very not cool since we're trying to make this as generic as possible. I had to make some changes to __init__.py, lock.sh and unlock.sh to cover all our bases here.
For __init__.py, change the shell calls to the below - this will pass the full app support path to the shell files.
os.chdir(os.path.dirname(path)) subprocess.call(['./' + str(os.path.basename(path)), Core.storage.join_path(Core.app_support_path)])
For lock.sh, update as per the below - this will cover 3 scenarios for the base path, param passed from the python script, environment variable and a default
#!/bin/bashAPP_SUPPORT=""
if [ $1 ]; then
APP_SUPPORT=$1
elif [ $PLEX_HOME ]; then
APP_SUPPORT="$PLEX_HOME/Library/Application Support"
else
APP_SUPPORT="/var/lib/plexmediaserver/Library/Application Support"
filockplex=
cd “$APP_SUPPORT/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/”
./sqlite3 “$APP_SUPPORT/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db” “$lockplex”
exit;
For unlock.sh, update as per the following - fixes the same issues as the above.
#!/bin/bashAPP_SUPPORT=""
if [ $1 ]; then
APP_SUPPORT=$1
elif [ $PLEX_HOME ]; then
APP_SUPPORT="$PLEX_HOME/Library/Application Support"
else
APP_SUPPORT="/var/lib/plexmediaserver/Library/Application Support"
fiunlockplex=
cd “$APP_SUPPORT/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/”
./sqlite3 “$APP_SUPPORT/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db” “$unlockplex”
exit;
I can lock from the web-app, but now when I try to load the channel on my android phone I get the error "This directory appears to be empty"
Shells should be fine. All I did with the code there is add it so the Plex directory can be passed from the Python scripts, thus getting rid of the problem with determining the install directory from within the script itself.
The subprocess call is actually the recommended method for executing the shell script. The os.system call you were using earlier is actually out-dated and was replaced by subprocess (see Python documentation). You can actually pass the working directory as part of the subprocess call itself, so you technically can scrap the chdir call and instead use the call below for the whole thing. You do need to change the working directory in some fashion as the shell script is in a different directory than the __init__.py script and not located as part of the overall system path.
subprocess.call(['./' + str(os.path.basename(path)), Core.storage.join_path(Core.app_support_path)], cwd=os.path.dirname(path))
-------------------------------------------------------------
As for the channel working from mobile - unlock works OK. I just get that "This directory appears to be empty" when I click on the Lock command for the channel itself. It still looks like the commands are being executed on the server as my library is still getting hidden. I sometimes get that same error when trying to open the Lock channel itself. Might be just a mobile thing - maybe we can see if someone else can confirm on their Android device.
I can't get this to work. Enter my ip on the Lock plugin generator page and it rejects it -
<strong>Error!</strong>: Pl. check the Plex Media Server IP address entered.
IP address is correct, I can access PMS from the same machine, same browser, no problem at all.
Any ideas?
I can't get this to work. Enter my ip on the Lock plugin generator page and it rejects it - Error!: Pl. check the Plex Media Server IP address entered.
IP address is correct, I can access PMS from the same machine, same browser, no problem at all.
Any ideas?
Strange, entering without http and any added special characters?
eg:- 127.0.0.1 or 192.168.1.19
Pl. let me know if it still does not work, just used it, working fine!
What OS is PMS on?
Latest version of PMS, I hope?
Most importantly, what browser are you on? (Suggest the latest Firefox)
/iSh0w
Sent from my iPhone using Tapatalk