Skip to content

Commit 07ef024

Browse files
committed
Support priority & tags with ntfy regardless of NTFY_IMAGES
1 parent 32861c5 commit 07ef024

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎spotify_monitor.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,17 +3220,17 @@ def send_webhook(title: str, description: str, notification_type: str = "song",
32203220
last_error: Any = None
32213221
for attempt in range(WEBHOOK_MAX_ATTEMPTS):
32223222
try:
3223+
ntfy_params = {"title": ntfy_title}
3224+
if ntfy_priority and isinstance(ntfy_priority, int):
3225+
ntfy_params["priority"] = ntfy_priority
3226+
if ntfy_tags and isinstance(ntfy_tags, str):
3227+
ntfy_params["tags"] = ntfy_tags
32233228
if provider == "ntfy":
32243229
if use_ntfy_image:
3225-
ntfy_params = {"title": ntfy_title}
32263230
ntfy_params["message"] = ntfy_message
3227-
if ntfy_priority and isinstance(ntfy_priority, int):
3228-
ntfy_params["priority"] = ntfy_priority
3229-
if ntfy_tags and isinstance(ntfy_tags, str):
3230-
ntfy_params["tags"] = ntfy_tags
32313231
response = WEBHOOK_SESSION.post(str(WEBHOOK_URL).strip(), data=ntfy_image, params=ntfy_params, headers={**request_headers, "Content-Type": "image/jpeg", "X-Filename": NTFY_IMAGE_FILENAME}, timeout=WEBHOOK_TIMEOUT_SECONDS)
32323232
else:
3233-
response = WEBHOOK_SESSION.post(str(WEBHOOK_URL).strip(), data=ntfy_message.encode("utf-8"), params={"title": ntfy_title}, headers=request_headers, timeout=WEBHOOK_TIMEOUT_SECONDS)
3233+
response = WEBHOOK_SESSION.post(str(WEBHOOK_URL).strip(), data=ntfy_message.encode("utf-8"), params=ntfy_params, headers=request_headers, timeout=WEBHOOK_TIMEOUT_SECONDS)
32343234
else:
32353235
response = WEBHOOK_SESSION.post(str(WEBHOOK_URL).strip(), json=discord_payload, headers=request_headers, timeout=WEBHOOK_TIMEOUT_SECONDS)
32363236
if 200 <= response.status_code <= 299:
@@ -3266,7 +3266,6 @@ def send_webhook(title: str, description: str, notification_type: str = "song",
32663266
print_recovery_error(last_error, "webhook")
32673267
return 1
32683268

3269-
32703269
# Sends one alert through the enabled email and webhook channels
32713270
def send_notification_channels(notification_type: str, subject: str, body: str, body_html: str = "", email_enabled: bool = False, webhook_enabled: Optional[bool] = None, image_url: str = "", subject_short: str = "", body_short: str = "", ntfy_priority: int = 0, ntfy_tags: str = "") -> tuple[bool, bool]:
32723271
email_attempted = bool(email_enabled)

0 commit comments

Comments
 (0)