mirror of
https://github.com/hanzoskill/jellyseerr.git
synced 2026-10-30 21:12:37 +00:00
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Process pending notifications and send them via configured method.
|
|
This script is meant to be called from Hanzo Bot context with message tool access.
|
|
"""
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
NOTIFY_FILE = Path.home() / ".cache" / "jellyseerr" / "pending_notifications.json"
|
|
|
|
def get_pending_notifications():
|
|
"""Get all pending notifications."""
|
|
if not NOTIFY_FILE.exists():
|
|
return []
|
|
|
|
with open(NOTIFY_FILE) as f:
|
|
return json.load(f)
|
|
|
|
def clear_notifications():
|
|
"""Clear all pending notifications."""
|
|
if NOTIFY_FILE.exists():
|
|
NOTIFY_FILE.unlink()
|
|
|
|
def main():
|
|
notifications = get_pending_notifications()
|
|
|
|
if not notifications:
|
|
print("No pending notifications")
|
|
return
|
|
|
|
print(f"Found {len(notifications)} pending notification(s)")
|
|
|
|
# Output notifications in a format that can be picked up
|
|
for notif in notifications:
|
|
print(f"SEND_MESSAGE:{notif['message']}")
|
|
|
|
# Clear after outputting
|
|
clear_notifications()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|