2017-07-12 18:19:22 +00:00
|
|
|
import psutil
|
|
|
|
import requests
|
|
|
|
|
|
|
|
# Drive letter to check if exists.
|
2018-02-21 20:37:28 +00:00
|
|
|
drive = 'F:'
|
2017-07-12 18:19:22 +00:00
|
|
|
|
|
|
|
disk = psutil.disk_partitions()
|
|
|
|
|
2018-02-21 20:37:28 +00:00
|
|
|
PLEXPY_URL = 'http://localhost:8182/' # Your PlexPy URL
|
|
|
|
PLEXPY_APIKEY = 'xxxxxx' # Enter your PlexPy API Key
|
|
|
|
AGENT_LST = [10, 11] # The PlexPy notifier agent id found here: https://github.com/drzoidberg33/plexpy/blob/master/plexpy/notifiers.py#L43
|
2017-07-12 18:19:22 +00:00
|
|
|
NOTIFY_SUBJECT = 'PlexPy' # The notification subject
|
|
|
|
NOTIFY_BODY = 'The Plex disk {0} was not found'.format(drive) # The notification body
|
|
|
|
|
|
|
|
disk_check = [True for i in disk if drive in i.mountpoint]
|
|
|
|
|
|
|
|
if not disk_check:
|
2018-02-21 20:37:28 +00:00
|
|
|
# Send the notification through PlexPy
|
|
|
|
payload = {'apikey': PLEXPY_APIKEY,
|
2017-07-12 18:19:22 +00:00
|
|
|
'cmd': 'notify',
|
|
|
|
'subject': NOTIFY_SUBJECT,
|
|
|
|
'body': NOTIFY_BODY}
|
|
|
|
|
2018-02-21 20:37:28 +00:00
|
|
|
for agent in AGENT_LST:
|
|
|
|
payload['agent_id'] = agent
|
|
|
|
requests.post(PLEXPY_URL.rstrip('/') + '/api/v2', params=payload)
|
2017-07-12 18:19:22 +00:00
|
|
|
else:
|
|
|
|
pass
|