updated to have apprise as a notification option

This commit is contained in:
2026-04-29 21:14:40 -05:00
parent 327cb22bfd
commit e56b2027cd
2 changed files with 22 additions and 2 deletions
+18 -1
View File
@@ -5,6 +5,9 @@
[string] $qbtUser = $ENV:QBTUSER [string] $qbtUser = $ENV:QBTUSER
[string] $qbtPassword = $ENV:QBTPASSWORD [string] $qbtPassword = $ENV:QBTPASSWORD
[string] $notificationWebhookURL = $ENV:NOTIFICATIONWEBHOOKURL [string] $notificationWebhookURL = $ENV:NOTIFICATIONWEBHOOKURL
[string] $discordWebhookURL = $ENV:DISCORDWEBHOOKURL
[string] $appriseWebhookURL = $ENV:APPRISEWEBHOOKURL
[string] $appriseWebhookTag = $ENV:APPRISEWEBHOOKTAG
while ($true) while ($true)
{ {
@@ -33,8 +36,9 @@ while ($true)
{ {
$qbtPortChangeBody = 'json={"listen_port":' + $gluetunForwardedPort + '}' $qbtPortChangeBody = 'json={"listen_port":' + $gluetunForwardedPort + '}'
$qbtPortChangeResponse = Invoke-WebRequest -Uri "http://$($qbtHost):$($qbtPort)/api/v2/app/setPreferences" -WebSession $qbtSession -Method POST -Headers $qbtHeaders -Body $qbtPortChangeBody $qbtPortChangeResponse = Invoke-WebRequest -Uri "http://$($qbtHost):$($qbtPort)/api/v2/app/setPreferences" -WebSession $qbtSession -Method POST -Headers $qbtHeaders -Body $qbtPortChangeBody
if ($notificationWebhookURL) if ($notificationWebhookURL -or $discordWebhookURL)
{ {
if ($discordWebhookURL) { $notificationWebhookURL = $discordWebhookURL }
$headers = @{ $headers = @{
"Content-Type"="application/json" "Content-Type"="application/json"
} }
@@ -44,6 +48,19 @@ while ($true)
$json = $body | ConvertTo-Json $json = $body | ConvertTo-Json
Invoke-WebRequest -URI $notificationWebhookURL -Method post -Body $json -Headers $headers Invoke-WebRequest -URI $notificationWebhookURL -Method post -Body $json -Headers $headers
} }
elseif ($appriseWebhookURL)
{
$headers = @{
"Content-Type"="application/json"
}
$body = @{
title="QBitTorrent Port Manager"
body="QBitTorrent Listening Port updated to $gluetunForwardedPort"
tags="$appriseWebhookTag"
}
$json = $body | ConvertTo-Json
Invoke-WebRequest -URI $appriseWebhookURL -Method post -Body $json -Headers $headers
}
} }
Write-Host "Sleeping for $schedule minutes..." Write-Host "Sleeping for $schedule minutes..."
Start-Sleep ($schedule * 60) Start-Sleep ($schedule * 60)
+4 -1
View File
@@ -10,6 +10,9 @@ services:
- QBTPORT=8787 # qbittorrent port - QBTPORT=8787 # qbittorrent port
- QBTUSER=admin # qbittorrent webUI username - QBTUSER=admin # qbittorrent webUI username
- QBTPASSWORD=adminpass # qbittorrent webUI password - QBTPASSWORD=adminpass # qbittorrent webUI password
- NOTIFICATIONWEBHOOKURL=https://discord.com/api/webhooks/<webhookURL> # discord notification wehook URL #- NOTIFICATIONWEBHOOKURL=https://discord.com/api/webhooks/<webhookURL> # DEPRECATED discord notification wehook URL
#- DISCORDWEBHOOKURL=https://discord.com/api/webhooks/<webhookURL> # discord notification wehook URL
#- APPRISEWEBHOOKURL=https://apprisehost/notify/config # apprise notification url
#- APPRISEWEBHOOKTAG=all # apprise notification tag
volumes: volumes:
- C:/Docker/qbittorrent/gluetun/tmp:/tmp # REQUIRED: Path to where the 'forwarded_port' file from gluetun is stored - C:/Docker/qbittorrent/gluetun/tmp:/tmp # REQUIRED: Path to where the 'forwarded_port' file from gluetun is stored