Jellyfin Forum
Is there a way to validate the media info data? - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Off Topic (https://forum.jellyfin.org/f-off-topic)
+--- Forum: General Discussion (https://forum.jellyfin.org/f-general-discussion)
+--- Thread: Is there a way to validate the media info data? (/t-is-there-a-way-to-validate-the-media-info-data)



Is there a way to validate the media info data? - kodiuser - 2024-11-29

I have just seen that an anime show that I watch has been catalogued as another show I have, one that is in a different parent folder.  I have checked that my tvshow.nfo file is correct for both shows.

Is there a tool or method that can see if the metadata held for a show is correct?

For example:
    path: /anime/Chainsaw Man/Season 1/...
    metadata: title: Chainsaw Man

A tool or such would say that the data matches and is therefore correct.
Without looking at the API yet, I suppose I could use that?

Thanks


RE: Is there a way to validate the media info data? - TheDreadPirate - 2024-11-29

I am only aware of a way to see if a show/movie has not been identified at all. I am not aware of a way to check for mis-identified content. I recommend including the TMDB ID in the folder name to help prevent this from happening.

Code:
/anime/Chainsaw Man [tmdbid-114410]



RE: Is there a way to validate the media info data? - kodiuser - 2024-11-29

I have been playing and sorted it with PowerShell.  Copy this into a new file (Jellyfin_Fix.ps1) and execute it.
It will scan all your libraries that are of type "tvshow" and output a proper PowerShell object with the relevant details.

Just remember to add your API key and User ID at the bottom where indicated.

Enjoy.

----------

Code:
Clear-Host

Function Get-TVLibrary {
    Param (
        [object]$authInfo
    )

    $headers = @{}
    $headers['X-MediaBrowser-Token'] = $authInfo.ApiKey
    $response = Invoke-RestMethod -Uri "$($authInfo.Url)/Views" -Method Get -Headers $headers

    ForEach ($item In ($response.Items | Sort-Object -Property 'Name')) {
        If ($item.CollectionType -eq 'tvshows') {
            [pscustomobject]@{'Id' = $item.Id; 'Name' = $item.Name}
        }
    }
}

Function Get-LibraryItem {
    Param (
        [object]$authInfo,
        [string]$LibraryId
    )

    $headers = @{}
    $headers['X-MediaBrowser-Token'] = $authInfo.ApiKey
    $response = Invoke-RestMethod -Uri "$($authInfo.Url)/Items?=SortName%2CPath&ParentId=$LibraryId" -Method Get -Headers $headers

    ForEach ($item In ($response.Items | Sort-Object -Property 'Name')) {
        [pscustomobject]@{'Id' = $item.Id; 'Name' = $item.Name}
    }
}

Function Get-Item {
    Param (
        [object]$authInfo,
        [string]$ItemId
    )

    $headers = @{}
    $headers['X-MediaBrowser-Token'] = $authInfo.ApiKey
    Return (Invoke-RestMethod -Uri "$($authInfo.Url)/Items/$ItemId" -Method Get -Headers $headers)
}

Function Read-Library {
    Param (
        $AuthInfo,
        $Library
    )

    ForEach ($item In $Library) {
        $shows = (Get-LibraryItem -authInfo $AuthInfo -LibraryId $item.Id)
        ForEach ($show In $shows) {
            $showItem  = (Get-Item -authInfo $AuthInfo -ItemId $show.Id)
            $showItem.Name = $showItem.Name.replace(':', '').replace('!', '').replace('/', ' ').replace('?', '').replace('&', 'And').replace('*', '.')
            $showItem.Name = $showItem.Name.TrimEnd('.')    # Synology Really does not like folder names that end with a dot (.)

            $showPath = $showItem.Name
            $origPath = ($showItem.Path).split('/')[-1]
            If (-not $showItem.Name.EndsWith(')')) {
                # Discard entries with year or language suffix.  For exmaple:  "TV Show (2024)" -or- "TV Show (Korean)"
                $showPath = ($origPath) -replace "\s\((?:\d{4}|\w{1,})\)", ''
            }
#            If ($showPath -eq $origPath) { $origPath = '' }

            If (($showItem.Name) -ine ($showPath)) {
                [pscustomobject]@{
                    'Library'        = $Library.Name
                    'Jellyfin Title' = $showitem.Name
                    'Cleaned Title'  = $showPath
                    'Original Title' = $origPath
                }
            }
        }
    }
}

$authInfo = @{
    ApiKey = '3f5ab1e3a75b4830b25780cd0a772839'
    Url    = 'http://192.168.42.31:8096/Users/4fccdac58fd4477893a7f6acdb50bd71'
}

Get-TVLibrary -authInfo $authInfo | ForEach-Object {
    Read-Library -AuthInfo $authInfo -Library $_
} | Format-Table -AutoSize