diff --git a/src/NzbDrone.Core/Notifications/Trakt/Trakt.cs b/src/NzbDrone.Core/Notifications/Trakt/Trakt.cs index e74436a48..3f8e199ba 100644 --- a/src/NzbDrone.Core/Notifications/Trakt/Trakt.cs +++ b/src/NzbDrone.Core/Notifications/Trakt/Trakt.cs @@ -200,119 +200,62 @@ namespace NzbDrone.Core.Notifications.Trakt private string MapMediaType(QualitySource source) { - var traktSource = string.Empty; - - switch (source) + var traktSource = source switch { - case QualitySource.BLURAY: - traktSource = "bluray"; - break; - case QualitySource.WEBDL: - traktSource = "digital"; - break; - case QualitySource.WEBRIP: - traktSource = "digital"; - break; - case QualitySource.DVD: - traktSource = "dvd"; - break; - case QualitySource.TV: - traktSource = "dvd"; - break; - } + QualitySource.BLURAY => "bluray", + QualitySource.WEBDL => "digital", + QualitySource.WEBRIP => "digital", + QualitySource.DVD => "dvd", + QualitySource.TV => "dvd", + _ => string.Empty + }; return traktSource; } private string MapResolution(int resolution, string scanType) { - var traktResolution = string.Empty; + var scanIdentifier = scanType.IsNotNullOrWhiteSpace() && TraktInterlacedTypes.InterlacedTypes.Contains(scanType) ? "i" : "p"; - var scanIdentifier = scanType.IsNotNullOrWhiteSpace() && TraktInterlacedTypes.interlacedTypes.Contains(scanType) ? "i" : "p"; - - switch (resolution) + var traktResolution = resolution switch { - case 2160: - traktResolution = "uhd_4k"; - break; - case 1080: - traktResolution = $"hd_1080{scanIdentifier}"; - break; - case 720: - traktResolution = "hd_720p"; - break; - case 576: - traktResolution = $"sd_576{scanIdentifier}"; - break; - case 480: - traktResolution = $"sd_480{scanIdentifier}"; - break; - } + 2160 => "uhd_4k", + 1080 => $"hd_1080{scanIdentifier}", + 720 => "hd_720p", + 576 => $"sd_576{scanIdentifier}", + 480 => $"sd_480{scanIdentifier}", + _ => string.Empty + }; return traktResolution; } private string MapAudio(MovieFile movieFile) { - var traktAudioFormat = string.Empty; - var audioCodec = movieFile.MediaInfo != null ? MediaInfoFormatter.FormatAudioCodec(movieFile.MediaInfo, movieFile.SceneName) : string.Empty; - switch (audioCodec) + var traktAudioFormat = audioCodec switch { - case "AC3": - traktAudioFormat = "dolby_digital"; - break; - case "EAC3": - traktAudioFormat = "dolby_digital_plus"; - break; - case "TrueHD": - traktAudioFormat = "dolby_truehd"; - break; - case "EAC3 Atmos": - traktAudioFormat = "dolby_digital_plus_atmos"; - break; - case "TrueHD Atmos": - traktAudioFormat = "dolby_atmos"; - break; - case "DTS": - case "DTS-ES": - traktAudioFormat = "dts"; - break; - case "DTS-HD MA": - traktAudioFormat = "dts_ma"; - break; - case "DTS-HD HRA": - traktAudioFormat = "dts_hr"; - break; - case "DTS-X": - traktAudioFormat = "dts_x"; - break; - case "MP3": - traktAudioFormat = "mp3"; - break; - case "MP2": - traktAudioFormat = "mp2"; - break; - case "Vorbis": - traktAudioFormat = "ogg"; - break; - case "WMA": - traktAudioFormat = "wma"; - break; - case "AAC": - traktAudioFormat = "aac"; - break; - case "PCM": - traktAudioFormat = "lpcm"; - break; - case "FLAC": - traktAudioFormat = "flac"; - break; - case "Opus": - traktAudioFormat = "ogg_opus"; - break; - } + "AC3" => "dolby_digital", + "EAC3" => "dolby_digital_plus", + "TrueHD" => "dolby_truehd", + "EAC3 Atmos" => "dolby_digital_plus_atmos", + "TrueHD Atmos" => "dolby_atmos", + "DTS" => "dts", + "DTS-ES" => "dts", + "DTS-HD MA" => "dts_ma", + "DTS-HD HRA" => "dts_hr", + "DTS-X" => "dts_x", + "MP3" => "mp3", + "MP2" => "mp2", + "Vorbis" => "ogg", + "WMA" => "wma", + "AAC" => "aac", + "PCM" => "lpcm", + "FLAC" => "flac", + "Opus" => "ogg_opus", + _ => string.Empty + }; return traktAudioFormat; } diff --git a/src/NzbDrone.Core/Notifications/Trakt/TraktInterlacedTypes.cs b/src/NzbDrone.Core/Notifications/Trakt/TraktInterlacedTypes.cs index 7459a83d9..458ef4382 100644 --- a/src/NzbDrone.Core/Notifications/Trakt/TraktInterlacedTypes.cs +++ b/src/NzbDrone.Core/Notifications/Trakt/TraktInterlacedTypes.cs @@ -5,16 +5,9 @@ namespace NzbDrone.Core.Notifications.Trakt { public static class TraktInterlacedTypes { - private static HashSet _interlacedTypes; - - static TraktInterlacedTypes() + public static readonly HashSet InterlacedTypes = new (StringComparer.OrdinalIgnoreCase) { - _interlacedTypes = new HashSet(StringComparer.OrdinalIgnoreCase) - { - "Interlaced", "MBAFF", "PAFF" - }; - } - - public static HashSet interlacedTypes => _interlacedTypes; + "Interlaced", "MBAFF", "PAFF" + }; } }