update
This commit is contained in:
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user