Plex iNotifier: Auto-update a remote Plex Media Server when new content is added on NAS

hello

since update 1.1.0, it doesn’t work

i have only one user and no pin for this account
here log

thanks

Sortie standard/erreur : Traceback (most recent call last): File "/volume1/scripts/plex_notify.py", line 200, in <module> plex_account_token File "/volume1/scripts/plex_notify.py", line 170, in url_open return urllib.request.urlopen(req, context=ctx) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 162, in urlopen return opener.open(url, data, timeout) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 471, in open response = meth(req, response) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 581, in http_response 'http', request, response, code, msg, hdrs) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 509, in error return self._call_chain(*args) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 443, in _call_chain result = func(*args) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 589, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 401: Unauthorized

@kaizo33 said:
since update 1.1.0, it doesn’t work
i have only one user and no pin for this account

I’m not sure why you’re getting that error now with only one user and no PIN, but did you try setting the plex_account_token variable in the version 1.3 script in my first post? There are instructions in the “troubleshooting” section that explain how to set that variable.

P.S. I’m using this script with PMS v1.1.0.2611 and it’s working fine here.

thanks i have put token but i have another error
i have put token and it work fine
and for another isuue, i have renamed a library and forgot change on script.

thanks for your help

Glad to hear you got it working! :slight_smile:

So, I wrote a script to automate that (borrowed heavily from here).

Let me know if you find this useful!

Oh man… You don’t know how much you’ve helped me. Thanks so much! I’m using this to be able to run Plex as a virtual computer with a cifs mount. And this solves everything. Thanks!

Hi talisto

Firstly, thank you for the great script. I have been using version 1.3 for a while without any problem but recently it stopped working. I updated to version 1.4, initially by just copying over the modified variables (didn’t work), then by recreating the file entirely. However, whatever I try I get the same syntax error message in terminal when I run the program using ‘python plex-inotify.py’:

File “plex-inotify.py”, line 222
print(err, file=sys.stderr)
^
SyntaxError: invalid syntax

Do you know why this is happening? I have tried deleting the last command but then there is another error instead:

Traceback (most recent call last):
File “plex-inotify.py”, line 57, in
import urllib.request
ImportError: No module named request

If, using the complete script, I try ‘sudo python3 flex-inotify.py’ I get:

Traceback (most recent call last):
File “plex-inotify.py”, line 51, in
import pyinotify
ImportError: No module named ‘pyinotify’

The log file has ben created but is empty. I have deleted and reinstalled Python and the extensions (Python 3.5.1-0104 and Python Module 0108 running on Synology 713+ NAS) but am not sure where to go from here, I miss the automatic updates!

Many thanks

Hey dbutt,

@dbutt said:
File “plex-inotify.py”, line 222
print(err, file=sys.stderr)
^
SyntaxError: invalid syntax

In this case it’s because you’re running the script with Python 2, which isn’t supported.

File “plex-inotify.py”, line 51, in
import pyinotify
ImportError: No module named ‘pyinotify’

In this case you’re running the script with Python 3, which is good, but you don’t have the pyinotify module installed. If you look at my first post, you’ll see I’ve written instructions on how to install the pyinotify module, which the script depends on.

First, run: wget https://bootstrap.pypa.io/ez_setup.py -O - | python3
then run: easy_install pyinotify

If that doesn’t work, try running pip3 install pyinotify. If pip3 doesn’t exist on your system, run pip install pyinotify.

All of those commands should be run as root, or by running each command with sudo at the start of the command.

Thanks for the quick reply, I have been away and have just looked at it again today. I had followed the installation instructions again, but each time I run easy_install I get this message:

Searching for pyinotify
Best match: pyinotify 0.9.6
Processing pyinotify-0.9.6-py2.7.egg
pyinotify 0.9.6 is already the active version in easy-install.pth

Using /usr/lib/python2.7/site-packages/pyinotify-0.9.6-py2.7.egg
Processing dependencies for pyinotify
Finished processing dependencies for pyinotify

I was also getting errors - command not found - when I tried pip or pip3 to install pyinotify. Then I stupidly deleted the python2.7 folder and nothing works! pip and pip3are still not found but I cannot seem to install pip successfully. Probably going to give up.

Thanks anyway

With Synology DSM 6.0 and python 3.5 I had to use the following commands to get pip:
python3.5 -m ensurepip

and pyinotify:
python3.5 -m install pyinotify

This seems to have done the trick and I am back up and running.

@dbutt said:
This seems to have done the trick and I am back up and running.

Awesome, glad to hear you got it working!!

I have setup the script as instructed and it says:

Got Plex libraries: {"/home/files/downloads/tv/": 1, “/home/files/downloads/movies/”: 2}
Adding directories to inotify watch
Starting loop
Notification: /home/files/downloads/tv/some-file.mkv (CREATE)
Notification: /home/files/downloads/tv/some-file.mkv (CREATE)

But on plex nothing happens until the 15 minute scheduled task which picks up the files normally.

@exwizzard said:
I have setup the script as instructed and it says:

Got Plex libraries: {“/home/files/downloads/tv/”: 1, “/home/files/downloads/movies/”: 2}
Adding directories to inotify watch
Starting loop
Notification: /home/files/downloads/tv/some-file.mkv (CREATE)
Notification: /home/files/downloads/tv/some-file.mkv (CREATE)

But on plex nothing happens until the 15 minute scheduled task which picks up the files normally.

I would try removing the trailing slash on your paths in the config. I.e. change /home/files/downloads/tv/ to /home/files/downloads/tv.

Thanks for this! Will I be able to run this on Mac mini which is sharing an external drive to nvidia shield TV over smb?

I’m woefully out of my league here. I need this script (not auto-updating from a NAS is horrible) as I am just now planning to move from 2 8TB hard drives to a NAS.

I have installed PlexPy (super rad, in case anyone cared), but the instructions were incredibly detailed for me to follow. Here, they’re a little advanced. Are there any options for someone not very familiar with Terminal (but enough to follow directions) on a Mac using a Synology NAS on DSM 6.0.2?

Honestly, even trying to get the link above to start a Plex library scan would be fine. I could set that on my Android on the home screen but I get 401 Unauthorized as I have Home set up with a PIN. I tried adding my token at the end, but I then get a 404.

Thanks in advance for any assistance.

Recently updated my DSM to the latest version and somehow can’t get the script to work anymore.

Error:

root@DiskStation:~# python3.5 -m install pyinotify
/usr/local/bin/python3.5: No module named install

The steps mentioned above

With Synology DSM 6.0 and python 3.5 I had to use the following commands to get pip:
python3.5 -m ensurepip

have been working but the last step isn’t working. :frowning:

Thanx for your help

RSchally

@RSchally said:
Recently updated my DSM to the latest version and somehow can’t get the script to work anymore.

Error:

root@DiskStation:~# python3.5 -m install pyinotify
/usr/local/bin/python3.5: No module named install

The steps mentioned above

With Synology DSM 6.0 and python 3.5 I had to use the following commands to get pip:
python3.5 -m ensurepip

have been working but the last step isn’t working. :frowning:

Thanx for your help

RSchally

Use the following command instead:
‘python3 -m pip install pyinotify’

THANK YOU!!!

I have the script working finally, but I don’t know what my local paths are. I’ve tried every combination I can think of for the mounted drives, and it’s saying not found. What does a local path look like as an example?

‘/volume1/photo’ : ‘Bilder’,

before : the local path
after : name of the library in Plex

you can figure out the path if you right click on a library and go to edit. there you specify the location of the files for your library and in my case it says /volume1/photo (it’s the path on my Synology)
Just copy the path