@@ -3540,6 +3540,120 @@ function GetTVDBShowPoster {
35403540 Write-Entry -Subtext "Cannot search on TVDB, missing ID..." -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Warning
35413541 }
35423542}
3543+ function GetTMDBLogo {
3544+ param(
3545+ [string]$Type
3546+ )
3547+ if ($global:tvdbid) {
3548+ Write-Entry -Subtext "Searching on TMDB for a Logo - TMDBID: $global:tmdbid" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Cyan -log Info
3549+ try {
3550+ $response = (Invoke-WebRequest -Uri "https://api.themoviedb.org/3/$Type/$($global:tmdbid)?append_to_response=images&language=$($global:LogoLanguageOrder[0])&include_image_language=$($global:LogoLanguageOrder -join ',')" -Method GET -Headers $global:headers -ErrorAction SilentlyContinue).content | ConvertFrom-Json -ErrorAction SilentlyContinue
3551+ }
3552+ catch {
3553+ Write-Entry -Subtext "Could not query TVDB url, error message: $($_.Exception.Message)" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Red -log Error
3554+ $global:errorCount++; Write-Entry -Subtext "[ERROR-HERE] See above. ^^^ errorCount: $errorCount" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Red -log Error
3555+ }
3556+ if ($response) {
3557+ if ($response.images.logos) {
3558+ foreach ($lang in $global:LogoLanguageOrder) {
3559+ if ($lang -ne 'null' -or $lang -ne 'xx') {
3560+ if ($global:GetClearlogo -eq 'true'){
3561+ $FavPoster = ($response.images.logos | Where-Object iso_639_1 -eq $lang)
3562+ }
3563+ }
3564+
3565+ if ($FavPoster) {
3566+ if ($global:TMDBVoteSorting -eq 'primary') {
3567+ $posterpath = $FavPoster[0].file_path
3568+ }
3569+ Else {
3570+ $posterpath = (($FavPoster | Sort-Object $global:TMDBVoteSorting -Descending)[0]).file_path
3571+ }
3572+ $global:posterurl = "https://image.tmdb.org/t/p/original$posterpath"
3573+ if ($lang -ne 'null' -or $lang -ne 'xx') {
3574+ Write-Entry -Subtext "Found Logo with Language '$lang' on TMDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Blue -log Info
3575+ $global:PosterWithText = $true
3576+ $global:TMDBAssetTextLang = $lang
3577+ $global:TMDBAssetChangeUrl = "https://www.themoviedb.org/$Type/$($global:tmdbid)/images/logos"
3578+ }
3579+ return $global:posterurl
3580+ continue
3581+ }
3582+ }
3583+ }
3584+ Else {
3585+ Write-Entry -Subtext "No Logo found on TMDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Warning
3586+ $global:TVDBAssetChangeUrl = "https://www.themoviedb.org/$Type/$($global:tmdbid)/images/logos"
3587+ }
3588+ }
3589+ Else {
3590+ Write-Entry -Subtext "TMDB API response is null" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Red -log Error
3591+ $global:TVDBAssetChangeUrl = "https://www.themoviedb.org/$Type/$($global:tmdbid)/images/logos"
3592+ }
3593+ }
3594+ Else {
3595+ Write-Entry -Subtext "Cannot search on TMDB, missing ID..." -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Warning
3596+ }
3597+ }
3598+ function GetTVDBLogo {
3599+ param(
3600+ [string]$Type
3601+ )
3602+ if ($global:tvdbid) {
3603+ Write-Entry -Subtext "Searching on TVDB for a Logo - TVDBID: $global:tvdbid" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Cyan -log Info
3604+ try {
3605+ $response = (Invoke-WebRequest -Uri "https://api4.thetvdb.com/v4/$Type/$($global:tvdbid)/artworks" -Method GET -Headers $global:tvdbheader).content | ConvertFrom-Json
3606+ }
3607+ catch {
3608+ Write-Entry -Subtext "Could not query TVDB url, error message: $($_.Exception.Message)" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Red -log Error
3609+ $global:errorCount++; Write-Entry -Subtext "[ERROR-HERE] See above. ^^^ errorCount: $errorCount" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Red -log Error
3610+ }
3611+ if ($response) {
3612+ if ($response.data) {
3613+ foreach ($lang in $global:LogoLanguageOrder) {
3614+ if ($lang -ne 'null') {
3615+ if ($global:GetClearart -eq 'true'){
3616+ if ($Type -eq 'series'){
3617+ $global:tvdblogo = ($response.data.artworks | Where-Object { $_.language -like "$lang*" -and $_.type -eq '22' } | Sort-Object Score -Descending)
3618+ }
3619+ Else {
3620+ $global:tvdblogo = ($response.data.artworks | Where-Object { $_.language -like "$lang*" -and $_.type -eq '24' } | Sort-Object Score -Descending)
3621+ }
3622+ }
3623+ elseif ($global:GetClearlogo -eq 'true'){
3624+ if ($Type -eq 'series'){
3625+ $global:tvdblogo = ($response.data.artworks | Where-Object { $_.language -like "$lang*" -and $_.type -eq '23' } | Sort-Object Score -Descending)
3626+ }
3627+ Else {
3628+ $global:tvdblogo = ($response.data.artworks | Where-Object { $_.language -like "$lang*" -and $_.type -eq '25' } | Sort-Object Score -Descending)
3629+ }
3630+ }
3631+ }
3632+
3633+ if ($global:tvdblogo) {
3634+ $global:posterurl = $global:tvdblogo[0].image
3635+ Write-Entry -Subtext "Found Logo with Language '$lang' on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Blue -log Info
3636+
3637+ $global:TVDBAssetChangeUrl = "https://thetvdb.com/$Type/$($response.data.slug)#artwork"
3638+ return $global:posterurl
3639+ continue
3640+ }
3641+ }
3642+ }
3643+ Else {
3644+ Write-Entry -Subtext "No Logo found on TVDB" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Warning
3645+ $global:TVDBAssetChangeUrl = "https://thetvdb.com/$Type/$($response.data.slug)#artwork"
3646+ }
3647+ }
3648+ Else {
3649+ Write-Entry -Subtext "TVDB API response is null" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Red -log Error
3650+ $global:TVDBAssetChangeUrl = "https://thetvdb.com/$Type/$($response.data.slug)#artwork"
3651+ }
3652+ }
3653+ Else {
3654+ Write-Entry -Subtext "Cannot search on TVDB, missing ID..." -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Yellow -log Warning
3655+ }
3656+ }
35433657function GetTVDBSeasonPoster {
35443658 if ($global:tvdbid) {
35453659 Write-Entry -Subtext "Searching on TVDB for a Season poster - TVDBID: $global:tvdbid" -Path $global:ScriptRoot\Logs\Scriptlog.log -Color Cyan -log Info
0 commit comments