Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://github.com/Sonarr/Sonarr/wiki/EpisodeFile
- # https://github.com/Sonarr/Sonarr/wiki/Series
- $url = "http://127.0.0.1:8989/sonarr/api" # copy/paste your sonarr url, add API to the end of it.
- $apikey = "?apikey={SONARR API KEY}"
- $Series = Invoke-RestMethod -Uri "$($url)/series$($apikey)" -Method Get
- $csv = [ordered]@{
- Title = @()
- Season = @()
- Episode = @()
- Resolution = @()
- QualityName = @()
- QualitySrc = @()
- VideoCodec = @()
- AudioChannels = @()
- AudioCodecs = @()
- RelativePath = @()
- }
- ForEach( $s in $Series ) {
- $Episodes = Invoke-RestMethod -Uri "$($url)/episodefile$($apikey)&seriesId=$($s.id)" -Method Get
- ForEach( $e in $Episodes ) {
- if( $($e.relativePath -imatch "S\d+E\d+") ) {
- $csv.Title += @($s.title)
- $csv.Season += @($Matches[0] -replace '(S|E\d+)','')
- $csv.Episode += @($Matches[0] -replace '(E|S\d+)','')
- $csv.Resolution += @($e.quality.quality.resolution)
- $csv.QualityName += @($e.quality.quality.name)
- $csv.QualitySrc += @($e.quality.quality.source)
- $csv.VideoCodec += @($e.mediaInfo.videoCodec)
- $csv.AudioChannels += @($e.mediaInfo.audioChannels)
- $csv.AudioCodecs += @($e.mediaInfo.audioCodec)
- $csv.RelativePath += @($e.relativePath)
- }
- }
- }
- if( $csv.Title.count -gt 0 ) {
- $count = $csv.Values | ForEach-Object { $_.Count }| Select-Object -Last 1
- $keys = $csv.Keys
- 0..($count-1) | ForEach-Object {
- $props = [ordered]@{}
- foreach ($key in $keys) {
- $props[$key] = $csv[$key][$_]
- }
- New-Object -Type PSObject -Property $props
- } | Export-Csv -Path "C:$($env:HOMEPATH)\Desktop\episodelist.csv" -NoTypeInformation
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement