diff --git a/.env.example b/.env.example index f17a08f..0dc9845 100644 --- a/.env.example +++ b/.env.example @@ -17,3 +17,7 @@ WIREGUARD_ADDRESSES= # Traefik Basic Auth # Format: username:hashedpassword (from htpasswd -nB username) TRAEFIK_AUTH= + +# Notification Configuration +# URL to send notifications to (e.g. http://localhost:8080/notify) +NOTIFICATION_URL=http://localhost:8080/notify diff --git a/app/services/download_manager.py b/app/services/download_manager.py index 15c6be1..1b8c306 100644 --- a/app/services/download_manager.py +++ b/app/services/download_manager.py @@ -5,6 +5,7 @@ import sys import os import shutil import pathlib +import requests from typing import Dict, List from tidal_dl_ng.download import Download from tidal_dl_ng.config import Settings, Tidal @@ -348,10 +349,37 @@ class DownloadManager: # Move the album shutil.move(str(album_dir), str(dest_album_path)) moved_count += 1 - + + # Notification + try: + name_parts = album_dir.name.split(" - ", 1) + if len(name_parts) == 2: + content = f"{name_parts[1]} by {name_parts[0]} has been added to Navidrome" + else: + content = f"{album_dir.name} has been added to Navidrome" + + self._send_notification(content) + except Exception as e: + logger.error(f"Error preparing notification: {e}") + if moved_count > 0: logger.info(f"Successfully moved {moved_count} album(s) to {dest_base}") except Exception as e: logger.error(f"Failed to move albums: {e}") + def _send_notification(self, content): + url = os.getenv("NOTIFICATION_URL") + if not url: + return + + try: + payload = { + "service_name": "tidal-dl-ng", + "content": content, + "level": "info" + } + requests.post(url, json=payload, timeout=5) + except Exception as e: + logger.error(f"Failed to send notification: {e}") + diff --git a/app/templates/index.html b/app/templates/index.html index 73bff91..0bcddcc 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -49,18 +49,22 @@
- System IP: Loading... + System IP: Loading... + +