diff options
author | morpheus65535 <[email protected]> | 2022-01-01 16:41:00 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2022-01-01 16:41:00 -0500 |
commit | e239fc282619d0f79ee34086b76961c6db2263fe (patch) | |
tree | 997662c7e10903d2b44f72773b2864c318e8ebc1 | |
parent | d8f14560e3db044dce044cb1feba3855bd458ecc (diff) | |
download | bazarr-e239fc282619d0f79ee34086b76961c6db2263fe.tar.gz bazarr-e239fc282619d0f79ee34086b76961c6db2263fe.zip |
Fixed exception thrown when Radarr (and potentially Sonarr) return a null audio or video codec for a movie. #1657
-rw-r--r-- | bazarr/get_episodes.py | 72 | ||||
-rw-r--r-- | bazarr/get_movies.py | 93 |
2 files changed, 95 insertions, 70 deletions
diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py index c93f2a693..a71f49acf 100644 --- a/bazarr/get_episodes.py +++ b/bazarr/get_episodes.py @@ -217,43 +217,49 @@ def sync_one_episode(episode_id): def SonarrFormatAudioCodec(audio_codec): - if audio_codec == 'AC-3': - return 'AC3' - if audio_codec == 'E-AC-3': - return 'EAC3' - if audio_codec == 'MPEG Audio': - return 'MP3' - - return audio_codec + if type(audio_codec) is not str: + return audio_codec + else: + if audio_codec == 'AC-3': + return 'AC3' + elif audio_codec == 'E-AC-3': + return 'EAC3' + elif audio_codec == 'MPEG Audio': + return 'MP3' + else: + return audio_codec def SonarrFormatVideoCodec(video_codec): - if video_codec == 'x264' or video_codec == 'AVC': - return 'h264' - elif video_codec == 'x265' or video_codec == 'HEVC': - return 'h265' - elif video_codec.startswith('XviD'): - return 'XviD' - elif video_codec.startswith('DivX'): - return 'DivX' - elif video_codec == 'MPEG-1 Video': - return 'Mpeg' - elif video_codec == 'MPEG-2 Video': - return 'Mpeg2' - elif video_codec == 'MPEG-4 Video': - return 'Mpeg4' - elif video_codec == 'VC-1': - return 'VC1' - elif video_codec.endswith('VP6'): - return 'VP6' - elif video_codec.endswith('VP7'): - return 'VP7' - elif video_codec.endswith('VP8'): - return 'VP8' - elif video_codec.endswith('VP9'): - return 'VP9' - else: + if type(video_codec) is not str: return video_codec + else: + if video_codec == 'x264' or video_codec == 'AVC': + return 'h264' + elif video_codec == 'x265' or video_codec == 'HEVC': + return 'h265' + elif video_codec.startswith('XviD'): + return 'XviD' + elif video_codec.startswith('DivX'): + return 'DivX' + elif video_codec == 'MPEG-1 Video': + return 'Mpeg' + elif video_codec == 'MPEG-2 Video': + return 'Mpeg2' + elif video_codec == 'MPEG-4 Video': + return 'Mpeg4' + elif video_codec == 'VC-1': + return 'VC1' + elif video_codec.endswith('VP6'): + return 'VP6' + elif video_codec.endswith('VP7'): + return 'VP7' + elif video_codec.endswith('VP8'): + return 'VP8' + elif video_codec.endswith('VP9'): + return 'VP9' + else: + return video_codec def episodeParser(episode): diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py index 3ff4bd951..3b54fefac 100644 --- a/bazarr/get_movies.py +++ b/bazarr/get_movies.py @@ -282,49 +282,68 @@ def profile_id_to_language(id, profiles): def RadarrFormatAudioCodec(audioFormat, audioCodecID, audioProfile, audioAdditionalFeatures): - if audioFormat == "AC-3": return "AC3" - if audioFormat == "E-AC-3": return "EAC3" - if audioFormat == "AAC": - if audioCodecID == "A_AAC/MPEG4/LC/SBR": - return "HE-AAC" - else: - return "AAC" - if audioFormat.strip() == "mp3": return "MP3" - if audioFormat == "MPEG Audio": - if audioCodecID == "55" or audioCodecID == "A_MPEG/L3" or audioProfile == "Layer 3": return "MP3" - if audioCodecID == "A_MPEG/L2" or audioProfile == "Layer 2": return "MP2" - if audioFormat == "MLP FBA": - if audioAdditionalFeatures == "16-ch": - return "TrueHD Atmos" + if type(audioFormat) is not str: + return audioFormat + else: + if audioFormat == "AC-3": + return "AC3" + elif audioFormat == "E-AC-3": + return "EAC3" + elif audioFormat == "AAC": + if audioCodecID == "A_AAC/MPEG4/LC/SBR": + return "HE-AAC" + else: + return "AAC" + elif audioFormat.strip() == "mp3": + return "MP3" + elif audioFormat == "MPEG Audio": + if audioCodecID == "55" or audioCodecID == "A_MPEG/L3" or audioProfile == "Layer 3": + return "MP3" + if audioCodecID == "A_MPEG/L2" or audioProfile == "Layer 2": + return "MP2" + elif audioFormat == "MLP FBA": + if audioAdditionalFeatures == "16-ch": + return "TrueHD Atmos" + else: + return "TrueHD" else: - return "TrueHD" - - return audioFormat + return audioFormat def RadarrFormatVideoCodec(videoFormat, videoCodecID, videoCodecLibrary): - if videoFormat == "x264": return "h264" - if videoFormat == "AVC" or videoFormat == "V.MPEG4/ISO/AVC": return "h264" - if videoCodecLibrary and (videoFormat == "HEVC" or videoFormat == "V_MPEGH/ISO/HEVC"): - if videoCodecLibrary.startswith("x265"): return "h265" - if videoCodecID and videoFormat == "MPEG Video": - if videoCodecID == "2" or videoCodecID == "V_MPEG2": + if type(videoFormat) is not str: + return videoFormat + else: + if videoFormat == "x264": + return "h264" + elif videoFormat == "AVC" or videoFormat == "V.MPEG4/ISO/AVC": + return "h264" + elif videoCodecLibrary and (videoFormat == "HEVC" or videoFormat == "V_MPEGH/ISO/HEVC"): + if videoCodecLibrary.startswith("x265"): + return "h265" + elif videoCodecID and videoFormat == "MPEG Video": + if videoCodecID == "2" or videoCodecID == "V_MPEG2": + return "Mpeg2" + else: + return "Mpeg" + elif videoFormat == "MPEG-1 Video": + return "Mpeg" + elif videoFormat == "MPEG-2 Video": return "Mpeg2" + elif videoCodecLibrary and videoCodecID and videoFormat == "MPEG-4 Visual": + if videoCodecID.endswith("XVID") or videoCodecLibrary.startswith("XviD"): + return "XviD" + if videoCodecID.endswith("DIV3") or videoCodecID.endswith("DIVX") or videoCodecID.endswith( + "DX50") or videoCodecLibrary.startswith("DivX"): + return "DivX" + elif videoFormat == "VC-1": + return "VC1" + elif videoFormat == "WMV2": + return "WMV" + elif videoFormat == "DivX" or videoFormat == "div3": + return "DivX" else: - return "Mpeg" - if videoFormat == "MPEG-1 Video": return "Mpeg" - if videoFormat == "MPEG-2 Video": return "Mpeg2" - if videoCodecLibrary and videoCodecID and videoFormat == "MPEG-4 Visual": - if videoCodecID.endswith("XVID") or videoCodecLibrary.startswith("XviD"): return "XviD" - if videoCodecID.endswith("DIV3") or videoCodecID.endswith("DIVX") or videoCodecID.endswith( - "DX50") or videoCodecLibrary.startswith("DivX"): return "DivX" - if videoFormat == "VC-1": return "VC1" - if videoFormat == "WMV2": - return "WMV" - if videoFormat == "DivX" or videoFormat == "div3": - return "DivX" - - return videoFormat + return videoFormat def get_tags(): |