From 5e11f195eb874c68a846eb6a8139e53ce9fb389e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 15 Feb 2019 12:51:18 -0500 Subject: [PATCH] Fix for refiner when the API doesn't have all the required information. --- bazarr/get_episodes.py | 12 ++++++++---- bazarr/get_movies.py | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py index aceb74307..367e57f6c 100644 --- a/bazarr/get_episodes.py +++ b/bazarr/get_episodes.py @@ -84,11 +84,15 @@ def sync_episodes(): resolution = str(episode['episodeFile']['quality']['quality']['resolution']) + 'p' if 'mediaInfo' in episode['episodeFile']: - videoCodec = episode['episodeFile']['mediaInfo']['videoCodec'] - videoCodec = SonarrFormatVideoCodec(videoCodec) + if 'videoCodec' in episode['episodeFile']['mediaInfo']: + videoCodec = episode['episodeFile']['mediaInfo']['videoCodec'] + videoCodec = SonarrFormatVideoCodec(videoCodec) + else: videoCodec = None - audioCodec = episode['episodeFile']['mediaInfo']['audioCodec'] - audioCodec = SonarrFormatAudioCodec(audioCodec) + if 'audioCodec' in episode['episodeFile']['mediaInfo']: + audioCodec = episode['episodeFile']['mediaInfo']['audioCodec'] + audioCodec = SonarrFormatAudioCodec(audioCodec) + else: audioCodec = None else: videoCodec = None audioCodec = None diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py index 3403b749b..db56ad768 100644 --- a/bazarr/get_movies.py +++ b/bazarr/get_movies.py @@ -87,16 +87,18 @@ def update_movies(): resolution = movie['movieFile']['quality']['quality']['resolution'].lstrip('r').lower() if 'mediaInfo' in movie['movieFile']: - videoFormat = movie['movieFile']['mediaInfo']['videoFormat'] - videoCodecID = movie['movieFile']['mediaInfo']['videoCodecID'] - videoProfile = movie['movieFile']['mediaInfo']['videoProfile'] - videoCodecLibrary = movie['movieFile']['mediaInfo']['videoCodecLibrary'] + videoFormat = videoCodecID = videoProfile = videoCodecLibrary = None + if 'videoFormat' in movie['movieFile']['mediaInfo']: videoFormat = movie['movieFile']['mediaInfo']['videoFormat'] + if 'videoCodecID' in movie['movieFile']['mediaInfo']: videoCodecID = movie['movieFile']['mediaInfo']['videoCodecID'] + if 'videoProfile' in movie['movieFile']['mediaInfo']: videoProfile = movie['movieFile']['mediaInfo']['videoProfile'] + if 'videoCodecLibrary' in movie['movieFile']['mediaInfo']: videoCodecLibrary = movie['movieFile']['mediaInfo']['videoCodecLibrary'] videoCodec = RadarrFormatVideoCodec(videoFormat, videoCodecID, videoProfile, videoCodecLibrary) - audioFormat = movie['movieFile']['mediaInfo']['audioFormat'] - audioCodecID = movie['movieFile']['mediaInfo']['audioCodecID'] - audioProfile = movie['movieFile']['mediaInfo']['audioProfile'] - audioAdditionalFeatures = movie['movieFile']['mediaInfo']['audioAdditionalFeatures'] + audioFormat = audioCodec = audioProfile = audioAdditionalFeatures = None + if 'audioFormat' in movie['movieFile']['mediaInfo']: audioFormat = movie['movieFile']['mediaInfo']['audioFormat'] + if 'audioCodecID' in movie['movieFile']['mediaInfo']: audioCodecID = movie['movieFile']['mediaInfo']['audioCodecID'] + if 'audioProfile' in movie['movieFile']['mediaInfo']: audioProfile = movie['movieFile']['mediaInfo']['audioProfile'] + if 'audioAdditionalFeatures' in movie['movieFile']['mediaInfo']: audioAdditionalFeatures = movie['movieFile']['mediaInfo']['audioAdditionalFeatures'] audioCodec = RadarrFormatAudioCodec(audioFormat, audioCodecID, audioProfile, audioAdditionalFeatures) else: videoCodec = None