Public/QualityProfile/Get-SonarrQualityDefinition.ps1
|
function Get-SonarrQualityDefinition { <# .SYNOPSIS Retrieves quality definitions from Sonarr. .DESCRIPTION Retrieves the quality definitions configured in Sonarr. A quality definition describes a single quality (e.g. 'WEBDL-720p') along with its weight (the order Sonarr ranks it in) and the minimum, maximum and preferred file sizes per minute of runtime. These are the qualities that can be referenced by name when building a quality profile with New-SonarrQualityProfile. .PARAMETER Id The quality definition ID to retrieve. Note that this is the definition ID, which is not the same as the ID of the quality it describes (available as the 'quality.id' property). .PARAMETER Name The name of the quality to retrieve the definition for, e.g. 'WEBDL-720p'. .EXAMPLE Get-SonarrQualityDefinition .EXAMPLE Get-SonarrQualityDefinition -Name 'WEBDL-720p' .EXAMPLE Get-SonarrQualityDefinition | Sort-Object -Property weight | Select-Object -ExpandProperty quality .NOTES When no parameters are specified, all quality definitions in Sonarr are returned. #> [CmdletBinding(DefaultParameterSetName = 'All')] param( [Parameter(Mandatory = $false, ParameterSetName = 'Id')] [String]$Id, [Parameter(Mandatory = $false, ParameterSetName = 'Name')] [String]$Name ) #################################################################################################### #Region Import configuration try { Import-Configuration -ErrorAction Stop } catch { throw $_ } #EndRegion #################################################################################################### #Region Define the path try { $Path = '/qualitydefinition' if($PSCmdlet.ParameterSetName -eq 'Id' -and $Id) { $Path += "/$Id" } } catch { throw $_ } #EndRegion #################################################################################################### #Region make the main request try { $Data = Invoke-SonarrRequest -Path $Path -Method GET -SuppressWhatIf -ErrorAction Stop if($Data) { if($Name) { $Data = $Data | Where-Object { $_.quality.name -eq $Name } } return $Data } } catch { throw $_ } #EndRegion } |