Created
June 17, 2025 21:35
-
-
Save psyciknz/0a847d78aa852d82fa7e8116b8519ac6 to your computer and use it in GitHub Desktop.
Plex webhook debugger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs flask
Run with
Then in app.plex.tv create a new webhook to http://:12345/webhook