Skip to content

Commit

Permalink
upgradinatorr.ps1 - Fix notification fields for Lidarr
Browse files Browse the repository at this point in the history
  • Loading branch information
angrycuban13 committed Jan 3, 2025
1 parent 368866a commit 8353677
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Upgradinatorr/upgradinatorr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ foreach ($application in $applicationList) {

# Start the search for media items
if ($PSCmdlet.ShouldProcess($applicationName, "Starting search for media items")) {
# Sonarr's API only supports searching one series at a time, so we need to loop through each media item in $mediaToSearch
# Sonarr/Lidarr API only supports searching one item at a time, so we need to loop through each media item in $mediaToSearch
if ($applicationName -match 'sonarr|lidarr') {
foreach ($mediaItem in $mediaToSearch) {
Start-StarrMediaSearch -ApiKey $applicationConfiguration.ApiKey -ApiVersion $applicationConfiguration.ApiVersion -Application $applicationName -Media $mediaItem -Url $applicationConfiguration.Url
Expand All @@ -1965,6 +1965,8 @@ foreach ($application in $applicationList) {

# Send a notification to the enabled services
if ($PSCmdlet.ShouldProcess($applicationName, "Sending notification to enabled services")) {
$titleList = [System.Collections.Generic.List[string]]::new()

switch -Regex ($application) {
"radarr" {
$thumbnail = 'https://gh.notifiarr.com/images/icons/radarr.png'
Expand Down Expand Up @@ -1999,8 +2001,16 @@ foreach ($application in $applicationList) {
$descriptionField = @"
Search started for $($mediaToSearch.Count) media items in $applicationName`:
"@
foreach ($media in $mediaToSearch) {
$descriptionField += "`r`n- $($media.title)"

foreach ($mediaItem in $mediaToSearch) {
if ($application -match $lidarr) {
$descriptionField += "`r`n- $($mediaItem.artistName)"
$titleList.Add("`n- $($mediaItem.artistName)")
}
else {
$descriptionField += "`r`n- $($mediaItem.title)"
$titleList.Add("`n- $($mediaItem.title)")
}
}

if ($descriptionField.Length -gt 4096) {
Expand Down Expand Up @@ -2032,11 +2042,6 @@ foreach ($application in $applicationList) {
Send-NotifiarrPassThroughNotification @params
}

$titleList = [System.Collections.Generic.List[string]]::new()

foreach ($media in $mediaToSearch) {
$titleList.Add("`n- $($media.title)")
}
Write-Host "Search started for $($mediaToSearch.Count) media items in $applicationName`:$titleList`n" -ForegroundColor Green
}
}

0 comments on commit 8353677

Please sign in to comment.