Skip to content

Instantly share code, notes, and snippets.

@hemanth22
Forked from JonnyWong16/notify_ifttt_by_user.py
Created January 19, 2019 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hemanth22/21b003a20163803eb287a6cc1e3188ad to your computer and use it in GitHub Desktop.
Save hemanth22/21b003a20163803eb287a6cc1e3188ad to your computer and use it in GitHub Desktop.
Send an IFTTT notification for a specific username
### WARNING: This script has not been tested! ###
# 1. Install the requests module for python.
# pip install requests
# 2. Add script arguments in PlexPy.
# {user} {action}
import requests
import sys
user = sys.argv[1]
action = sys.argv[2]
## EDIT THESE SETTINGS ##
PLEXPY_URL = 'http://localhost:8181/' # Your PlexPy URL
PLEXPY_APIKEY = '#####' # Enter your PlexPy API Key
AGENT_ID = 12 # The PlexPy notifier agent id found here: https://github.com/drzoidberg33/plexpy/blob/master/plexpy/notifiers.py#L43
NOTIFY_SUBJECT = 'PlexPy' # The notification subject
NOTIFY_BODY = 'Some body text' # The notification body
USERNAME = 'MyUsername' # Your username to filter out
## CODE BELOW ##
# Check if the username matches
if user == USERNAME:
# Send notification to PlexPy using the API
payload = {'apikey': PLEXPY_APIKEY,
'cmd': 'notify',
'agent_id': AGENT_ID,
'subject': NOTIFY_SUBJECT,
'body': NOTIFY_BODY,
'notify_action': action.lower()}
r = requests.post(PLEXPY_URL.rstrip('/') + '/api/v2', params=payload)
else:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment