Проверить структуру библиотеки Jellyfin
Проверяет сезоны, имена эпизодов и музыкальные альбомы, предупреждая о sample и trailer.
Что делает скрипт
Скрипт смотрит папки шоу, наличие каталогов сезонов и шаблон SxxEyy в файлах. Для музыки ожидается схема Исполнитель/Альбом/трек. Отчёт помогает подготовить библиотеку к сканированию, но не меняет файлы.
Быстрый старт
powershell -File Test-JellyfinStructure.ps1 -Path D:\Media
Скачайте файл, откройте терминал в папке со скриптом и выполните команду. Запускайте в PowerShell 5.1 или PowerShell 7.
Другие варианты
powershell -File Test-JellyfinStructure.ps1 -Path D:\Mediapowershell -File Test-JellyfinStructure.ps1 -Path D:\Media -Csv jellyfin.csvpowershell -File Test-JellyfinStructure.ps1 -Path E:\Library
Что понадобится
Встроен в Windows 10/11 (PowerShell 5.1)
Test-JellyfinStructure.ps1
[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"
}
Скрипты работают с файлами и настройками системы. Перед запуском прочитайте код и проверьте пути. Особенно если скрипт удаляет, перезаписывает или перемещает данные.