Skip to content

Commit

Permalink
bug: fix tvdb movie background search
Browse files Browse the repository at this point in the history
if textless was preferred and not found it has thrown an error, now it will continue the search for other langs in config.
  • Loading branch information
fscorrupt committed Jul 25, 2024
1 parent 60d64ed commit 62392ea
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
44 changes: 39 additions & 5 deletions Posterizarr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ param (
[string]$mediatype
)

$CurrentScriptVersion = "1.2.44"
$CurrentScriptVersion = "1.2.45"
$global:HeaderWritten = $false
$ProgressPreference = 'SilentlyContinue'

Expand Down Expand Up @@ -1841,10 +1841,44 @@ function GetTVDBMovieBackground {
}
if ($response) {
if ($response.data.artworks) {
$global:posterurl = ($response.data.artworks | Where-Object { $_.language -eq $null -and $_.type -eq '15' } | Sort-Object Score)[0].image
Write-Entry -Subtext "Found Textless Background on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Blue -log Info
$global:TVDBAssetChangeUrl = "https://thetvdb.com/movies/$($response.data.slug)#artwork"
return $global:posterurl
$NoLangArtwork = $response.data.artworks | Where-Object { $null -eq $_.language -and $_.type -eq '15' }
if ($NoLangArtwork){
$global:posterurl = ($NoLangArtwork | Sort-Object Score)[0].image
Write-Entry -Subtext "Found Textless Background on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Blue -log Info
$global:TVDBAssetChangeUrl = "https://thetvdb.com/movies/$($response.data.slug)#artwork"
return $global:posterurl
}
Else {
# Trying other languages
foreach ($lang in $global:PreferredLanguageOrderTVDB) {
if ($lang -eq 'null') {
$LangArtwork = ($response.data.artworks | Where-Object { $_.language -like "" -and $_.type -eq '15' } | Sort-Object Score)
}
Else {
$LangArtwork = ($response.data.artworks | Where-Object { $_.language -like "$lang*" -and $_.type -eq '15' } | Sort-Object Score)
}
if ($LangArtwork) {
$global:posterurl = $LangArtwork[0].image
if ($lang -eq 'null') {
Write-Entry -Subtext "Found Background without Language on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Blue -log Info
}
Else {
Write-Entry -Subtext "Found Background with Language '$lang' on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Blue -log Info
}
if ($lang -ne 'null') {
$global:PosterWithText = $true
$global:TVDBAssetTextLang = $lang
}
$global:TVDBAssetChangeUrl = "https://thetvdb.com/movies/$($response.data.slug)#artwork"
return $global:posterurl
continue
}
}
if (!$global:posterurl) {
Write-Entry -Subtext "No background found on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Warning
$global:TVDBAssetChangeUrl = "https://thetvdb.com/movies/$($response.data.slug)#artwork"
}
}
}
Else {
Write-Entry -Subtext "No Background found on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Warning
Expand Down
2 changes: 1 addition & 1 deletion Release.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.44
1.2.45

0 comments on commit 62392ea

Please sign in to comment.