This will eventually be a complete PowerShell module for quickly issuing Sonarr PVR API calls. The module was completely redesigned from the ground up in PowerShell Core, and I'm happy to say it works (has been tested) in Ubuntu 16.04 and Ubuntu 18.04 as well as Windows.
- Includes all the changes from the prerelease versions.
- Fixed these issues:
(3/18/2020)
- Fix major bug with
Connect-SonarrInstance
that has existed since 'beta'. When-NoApiPrefix
is not used, the TagManager object creation during connection no longer shows an error and tag management will work again.
(3/16/2020)
- Fixed mandatory parameter requirement for
Get-SonarrCalendar
. DayOfWeek is no longer required (as it should never have been...). Get-SonarrTag
no longer returns all tags when used in the pipeline.Get-SonarrSize
has been removed. (It was no longer needed)- NEW CMDLET:
- Update-SonarrQualityProfile (Set-SonarrQualityProfile/Update-SonarrProfile/Set-SonarrProfile)
(3/10/2020)
-
Dropping support for PowerShell 6 in favor of 7 - v1.3.0 will be the last version to include the binaries for running on PowerShell 6.x.x versions. To use the newer versions going forward, upgrade to PowerShell 7.
-
NEW CMDLETS:
- Get-SonarrSize (Returns the total file size of a Series, Season, or EpisodeFile)
- New-SonarrDelayProfile
- New-SonarrPlexNotification (New-PlexConnection)
- Restart-SonarrInstance (Restart-Sonarr)
- Set-SonarrDelayProfile
- Update-SonarrDownloadClient
-
TAGS (Better Tag Management)
- DelayProfile, Notification (Connection), Restriction, and Series objects can have their tags queried, added to, changed, or removed now very easily with:
Add-SonarrTag
Get-SonarrTag
Remove-SonarrTag
Get-SonarrSeries "brooklyn*" | Add-SonarrTag -Tag "my favorite" Get-SonarrSeries "*Agents of S*" | Remove-SonarrTag -ClearAll
- DelayProfile, Notification (Connection), Restriction, and Series objects can have their tags queried, added to, changed, or removed now very easily with:
-
Add-SonarrSeries
now accepts a[SearchSeries]
object from the pipeline, instead of properties by name. It also adds a parameter,-Type
to denote the type of series ("Anime", "Daily", "Standard"). -
Added
-Today
and-Tomorrow
switch parameters toGet-SonarrCalendar
. -
Series, Episode, and EpisodeFile ID's are now treated as
[int]
value types. -
Get-SonarrEpisode
has new switches for filtering results:-Downloaded
and-HasAired
. -
Get-SonarrEpisodeFile
is now piped from an[EpisodeResult]
instead of by property name. -
Get-SonarrLog
has added lots of new parameters for custom filtering log entries. -
Changed
Get-SonarrQualityProfile
's-Id
parameter to be-ProfileId
to allow for ValueFromPipelineByPropertyName to work properly. -
Changed
Remove-SonarrSeries
to accept a[SeriesResult]
from the pipeline as opposed to using values from properties. -
Search-SonarrDirectory
has a new switch parameter:-ExcludeFiles
. This tells the query to only return directories. -
PowerShell format file changes.
(1/13/2020)
Version 1.3.0 will be a major update (even though it's a minor revision :P) as the entire backend for issuing the API calls was overhauled. The biggest deal was that now every command will have a WriteDebug part prior to issuing any API request. It also simplified the requesting process and did away the need for explicit type casting on the responses.
Another big error of improvement was the handling of exceptions that may occur on the server end. Before, exceptions may have been cryptic/vague rendering them utterly useless. Now, exceptions are either thrown directly, or the exception response(s) from the API request are directly translated to PowerShell ErrorRecord(s).
In addition to the backend changes, improvements were made to the cmdlets as well as introducing new cmdlets. There are a total of 18 new cmdlets in this release (see Cmdlets section for the complete list).
To get started, connect to Sonarr with "Connect-SonarrInstance" (Connect-Sonarr) cmdlet:
# By Server and Port -- (8989 is the default port)
Connect-Sonarr -Server "MEDIASERVER" -ApiKey "xxxxxxxxxxxxxxxx" -PassThru
Version Authentication Url StartupPath
------- -------------- --- -----------
2.0.0.5322 forms http://MEDIASERVER:8989/ C:\ProgramData\NzbDrone\bin
# By explicit URL
Connect-Sonarr -Url "https://sonarr-api.cloud.com" -ApiKey "xxxxxxxxxxxx" -PassThru
# If you have a reverse proxy that strips away the "/api" path, use the "-NoApiPrefix" switch.
# If you have a reverse proxy URL base set, include that in the -SonarrUrl parameter or use the new "-ReverseProxyUrlBase" parameter when combined with a HostName.
Connect-Sonarr -Url "http://sonarr:8989/sonarr" ...
# or
Connect-Sonarr -HostName "mediaserver" -ReverseProxyUrlBase "sonarr" ...
See the wiki for more information about reverse proxy situations.
An example of some commands in action:
# Set Season 3 of a series to 'Not Monitored'
$series = Get-SonarrSeries -Name 24
$series.Seasons[2].Monitored = $false
$series | Update-SonarrSeries
# Search for a particular series and add it to Sonarr
Search-SonarrSeries "The X-Files" | Add-SonarrSeries -RootFolderPath "\\NAS\Shows" -IgnoreEpisodesWithFiles -SearchForMissingEpisodes -UseSeasonFolders
As of 3/20/2020, I'm still missing the following commands:
- DownloadedEpisodesScan
- MissingEpisodeSearch
- RenameFiles
- RenameSeries
The following is the list of the working cmdlets:
- Commands in bold are new in v1.3.0
- Aliases and notes are italicized
- Add-SonarrRelease
- Add-SonarrSeries
- Add-SonarrTag
- Clear-SonarrLog
- Connect-SonarrInstance - (Connect-Sonarr)
- Get-SonarrBackup
- Get-SonarrCalendar
- Get-SonarrCommand - (Get-SonarrJob)
- Get-SonarrDelayProfile
- Get-SonarrDiskspace
- Get-SonarrDownloadClient
- Get-SonarrEpisode
- Get-SonarrEpisodeFile
- Get-SonarrHistory
- Get-SonarrHostConfig
- Get-SonarrLog
- Get-SonarrLogFile
- Get-SonarrMapping
- Get-SonarrMediaManagement
- Get-SonarrMetadata
- Get-SonarrNotification - (Get-SonarrConnection)
- Get-SonarrQualityProfile - (Get-SonarrProfile)
- Get-SonarrQueue
- Get-SonarrRelease - * renamed to Search-SonarrRelease (left behind as alias...)
- Get-SonarrRestriction
- Get-SonarrRootFolder
- Get-SonarrSeries
- Get-SonarrStatus
- Get-SonarrTag
- Get-SonarrUpdate
- Get-SonarrWantedMissing
- Invoke-SonarrBackup - (Backup-Sonarr)
- Invoke-SonarrEpisodeSearch
- Invoke-SonarrRssSync
- Invoke-SonarrSeasonSearch
- Invoke-SonarrSeriesRefresh
- Invoke-SonarrSeriesRescan
- Invoke-SonarrSeriesSearch
- New-SonarrDelayProfile
- New-SonarrMapping
- New-SonarrPlexNotification - (New-PlexNotification)
- New-SonarrQualityProfile - (New-SonarrProfile)
- New-SonarrReleasePush
- New-SonarrRestriction
- New-SonarrTag
- Register-SonarrRootFolder (New-SonarrRootFolder)
- Remove-SonarrEpisodeFile
- Remove-SonarrMapping
- Remove-SonarrQualityProfile - (Remove-SonarrProfile)
- Remove-SonarrQueueItem
- Remove-SonarrRestriction
- Remove-SonarrRootFolder
- Remove-SonarrSeries
- Remove-SonarrTag
- Rename-SonarrTag - * (was Set-SonarrTag)
- Restart-SonarrInstance - (Restart-Sonarr)
- Save-SonarrLogFile
- Search-SonarrDirectory
- Search-SonarrRelease
- Search-SonarrSeries
- Set-SonarrDelayProfile
- Set-SonarrEpisode
- Set-SonarrHostConfig
- Set-SonarrMapping
- Set-SonarrRestriction
- Set-SonarrSeries - * (was Update-SonarrSeries)
- Set-SonarrTag - * (renamed to Rename-SonarrTag; left behind as alias)
- Update-SonarrDownloadClient
- Update-SonarrMediaManagement
- Update-SonarrMetadata
- Update-SonarrQualityProfile (Set-SonarrQualityProfile/Update-SonarrProfile/Set-SonarrProfile)
- Update-SonarrRestriction
- Update-SonarrSeries - * (renamed to Set-SonarrSeries; left behind as alias)