Skip to content

Instantly share code, notes, and snippets.

@psyciknz
Created June 17, 2025 21:35
Show Gist options
  • Select an option

  • Save psyciknz/0a847d78aa852d82fa7e8116b8519ac6 to your computer and use it in GitHub Desktop.

Select an option

Save psyciknz/0a847d78aa852d82fa7e8116b8519ac6 to your computer and use it in GitHub Desktop.
Plex webhook debugger
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys, json
from datetime import datetime
from flask import Flask, abort, request
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
if not request.form:
abort(400)
data = json.loads(request.form['payload'])
print(data)
# Do what you need with the data here.
# In this case, we're only acting on media.play or media.resume events.
if data['event'] == 'media.play' or data['event'] == 'media.resume':
user = data['Account']['title']
artist = data['Metadata']['grandparentTitle']
title = data['Metadata']['title']
event = data['event'][6:]
# print user
print (f"{event.capitalize()} {title} by {artist}")
# print artist
# print title
# print data
return "OK"
# Set the IP address you want to bind to here, and specify the port
if __name__ == '__main__':
app.run(host='0.0.0.0', port=12345, debug=False,threaded=True)
@psyciknz
Copy link
Author

Needs flask

pip3 install flask

Run with

python3 plex.py

Then in app.plex.tv create a new webhook to http://:12345/webhook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment