diff --git a/Invoke-QBTCleanarr.ps1 b/Invoke-QBTCleanarr.ps1 index b3559c2..b38a0e3 100644 --- a/Invoke-QBTCleanarr.ps1 +++ b/Invoke-QBTCleanarr.ps1 @@ -5,6 +5,7 @@ [string] $qbtUser = $ENV:QBTUSER [string] $qbtPassword = $ENV:QBTPASSWORD [string] $notificationWebhookURL = $ENV:NOTIFICATIONWEBHOOKURL +[string[]] $excludedTrackers = $ENV:EXCLUDEDTRACKERS -split ',' # Function to authenticate and get a session function Get-QBittorrentSession { @@ -34,6 +35,7 @@ function Get-Torrents { function Remove-Torrent { param ( [Microsoft.PowerShell.Commands.WebRequestSession]$session, + [string]$name, [string]$hash ) $qbtHeaders = @{ @@ -51,17 +53,17 @@ function Remove-Torrent { "Content-Type"="application/json" } $body = @{ - content="Removed torrent with hash $hash" + content="Removed torrent $name with hash $hash" } $json = $body | ConvertTo-Json Invoke-WebRequest -URI $notificationWebhookURL -Method post -Body $json -Headers $headers } } +# Main script +$session = Get-QBittorrentSession while ($true) { - # Main script - $session = Get-QBittorrentSession $torrents = Get-Torrents -session $session foreach ($torrent in $torrents) { @@ -74,14 +76,11 @@ while ($true) } if (-not ($trackers | Where-Object { $excludedTrackers -contains $_ })) { # Delete the torrent - Write-Host "Would delete: $($torrent.name)" - Remove-Torrent -session $session -hash $torrent.hash + Write-Host "Delete: $($torrent.name) $($toreent.hash)" + Remove-Torrent -session $session -hash $torrent.hash -name $torrent.name } } } - - # Logout (optional, but good practice) - # $session.UploadString("$qbittorrentUrl/api/v2/auth/logout", "") Write-Host "Sleeping for $schedule minutes..." Start-Sleep ($schedule * 60) diff --git a/docker-compose.yaml b/docker-compose.yaml index dcb8262..e08ab1d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,4 +10,5 @@ services: - QBTPORT=8787 # qbittorrent port - QBTUSER=admin # qbittorrent webUI username - QBTPASSWORD=adminpass # qbittorrent webUI password - - NOTIFICATIONWEBHOOKURL=https://discord.com/api/webhooks/ # discord notification wehook URL \ No newline at end of file + - NOTIFICATIONWEBHOOKURL=https://discord.com/api/webhooks/ # discord notification wehook URL + - EXCLUDEDTRACKERS=tracker1.com,tracker2.com # comma separated list of tracker names to exclude \ No newline at end of file