update
This commit is contained in:
@@ -17,3 +17,7 @@ WIREGUARD_ADDRESSES=
|
|||||||
# Traefik Basic Auth
|
# Traefik Basic Auth
|
||||||
# Format: username:hashedpassword (from htpasswd -nB username)
|
# Format: username:hashedpassword (from htpasswd -nB username)
|
||||||
TRAEFIK_AUTH=
|
TRAEFIK_AUTH=
|
||||||
|
|
||||||
|
# Notification Configuration
|
||||||
|
# URL to send notifications to (e.g. http://localhost:8080/notify)
|
||||||
|
NOTIFICATION_URL=http://localhost:8080/notify
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import requests
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
from tidal_dl_ng.download import Download
|
from tidal_dl_ng.download import Download
|
||||||
from tidal_dl_ng.config import Settings, Tidal
|
from tidal_dl_ng.config import Settings, Tidal
|
||||||
@@ -348,10 +349,37 @@ class DownloadManager:
|
|||||||
# Move the album
|
# Move the album
|
||||||
shutil.move(str(album_dir), str(dest_album_path))
|
shutil.move(str(album_dir), str(dest_album_path))
|
||||||
moved_count += 1
|
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:
|
if moved_count > 0:
|
||||||
logger.info(f"Successfully moved {moved_count} album(s) to {dest_base}")
|
logger.info(f"Successfully moved {moved_count} album(s) to {dest_base}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to move albums: {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}")
|
||||||
|
|
||||||
|
|||||||
@@ -49,18 +49,22 @@
|
|||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="card" style="margin-top: 20px; text-align: center; color: #888;">
|
<div class="card" style="margin-top: 20px; text-align: center; color: #888;">
|
||||||
<small>System IP: <span id="system-ip">Loading...</span></small>
|
<small>System IP: <span id="system-ip">Loading...</span>
|
||||||
|
<button onclick="checkIp()" style="background: #444; color: white; border: none; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; margin-left: 10px; cursor: pointer;">Check Again</button>
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function checkIp() {
|
async function checkIp() {
|
||||||
|
const el = document.getElementById('system-ip');
|
||||||
|
el.textContent = 'Loading...';
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/system/ip');
|
const response = await fetch('/system/ip');
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
document.getElementById('system-ip').textContent = data.ip;
|
el.textContent = data.ip;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
document.getElementById('system-ip').textContent = 'Error';
|
el.textContent = 'Error';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkIp();
|
checkIp();
|
||||||
|
|||||||
Reference in New Issue
Block a user