[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Path, [string]$Csv ) $ErrorActionPreference = 'Stop' $resolved = Resolve-Path -LiteralPath $Path -ErrorAction Stop if (-not (Test-Path -LiteralPath $resolved -PathType Container)) { throw "Укажите папку библиотеки: $resolved" } $issues = [System.Collections.Generic.List[object]]::new() $videoExtensions = @('.mkv', '.mp4', '.avi', '.mov', '.m4v') $shows = Join-Path $resolved 'Shows' if (-not (Test-Path -LiteralPath $shows -PathType Container)) { $shows = Join-Path $resolved 'TV Shows' } if (Test-Path -LiteralPath $shows -PathType Container) { foreach ($show in Get-ChildItem -LiteralPath $shows -Directory -ErrorAction SilentlyContinue) { $seasons = @(Get-ChildItem -LiteralPath $show.FullName -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^Season \d{2}$' }) if ($seasons.Count -eq 0) { $issues.Add([pscustomobject]@{ Area = 'Shows'; Item = $show.FullName; Problem = 'Нет папок Season NN' }) continue } foreach ($season in $seasons) { foreach ($file in Get-ChildItem -LiteralPath $season.FullName -File -ErrorAction SilentlyContinue) { if ($file.Extension -notin $videoExtensions) { continue } if ($file.Name -match '(?i)(sample|trailer|teaser)') { $issues.Add([pscustomobject]@{ Area = 'Shows'; Item = $file.FullName; Problem = 'Похоже на служебный файл' }) } if ($file.Name -notmatch '(?i)S\d{2}E\d{2,3}') { $issues.Add([pscustomobject]@{ Area = 'Shows'; Item = $file.FullName; Problem = 'Нет SxxEyy в имени' }) } } } } } else { $issues.Add([pscustomobject]@{ Area = 'Shows'; Item = $shows; Problem = 'Папка Shows не найдена' }) } $music = Join-Path $resolved 'Music' if (Test-Path -LiteralPath $music -PathType Container) { foreach ($artist in Get-ChildItem -LiteralPath $music -Directory -ErrorAction SilentlyContinue) { $albums = @(Get-ChildItem -LiteralPath $artist.FullName -Directory -ErrorAction SilentlyContinue) if ($albums.Count -eq 0) { $issues.Add([pscustomobject]@{ Area = 'Music'; Item = $artist.FullName; Problem = 'Нет папок альбомов' }) } } } else { $issues.Add([pscustomobject]@{ Area = 'Music'; Item = $music; Problem = 'Папка Music не найдена' }) } if ($issues.Count -eq 0) { Write-Host 'Явных проблем структуры Jellyfin не найдено.' exit 0 } $issues | Format-Table -AutoSize -Wrap Write-Host "Проблем: $($issues.Count)" if ($Csv) { $issues | Export-Csv -LiteralPath $Csv -NoTypeInformation -Encoding UTF8 Write-Host "Отчёт сохранён: $Csv" }