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) - - audioCodec = episode['episodeFile']['mediaInfo']['audioCodec'] - audioCodec = SonarrFormatAudioCodec(audioCodec) + if 'videoCodec' in episode['episodeFile']['mediaInfo']: + videoCodec = episode['episodeFile']['mediaInfo']['videoCodec'] + videoCodec = SonarrFormatVideoCodec(videoCodec) + else: videoCodec = None + + 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