diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index fcc6e0f83..00e435369 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -241,7 +241,7 @@ namespace NzbDrone.Common.Disk { return TransferMode.HardLink; } - else if (!mode.HasFlag(TransferMode.Copy)) + if (!mode.HasFlag(TransferMode.Copy)) { throw new IOException("Hardlinking from '" + source + "' to '" + destination + "' failed."); } diff --git a/src/NzbDrone.Common/Disk/OsPath.cs b/src/NzbDrone.Common/Disk/OsPath.cs index e8e3abc84..bac9d03ed 100644 --- a/src/NzbDrone.Common/Disk/OsPath.cs +++ b/src/NzbDrone.Common/Disk/OsPath.cs @@ -48,25 +48,21 @@ namespace NzbDrone.Common.Disk { return OsPathKind.Windows; } - else if (path.Contains('/')) + if (path.Contains('/')) { return OsPathKind.Unix; } - else - { - return OsPathKind.Unknown; - } + return OsPathKind.Unknown; } private static String FixSlashes(String path, OsPathKind kind) { - if (kind == OsPathKind.Windows) + switch (kind) { - return path.Replace('/', '\\'); - } - else if (kind == OsPathKind.Unix) - { - return path.Replace('\\', '/'); + case OsPathKind.Windows: + return path.Replace('/', '\\'); + case OsPathKind.Unix: + return path.Replace('\\', '/'); } return path; @@ -103,14 +99,12 @@ namespace NzbDrone.Common.Disk { return _path.StartsWith(@"\\") || _path.Contains(':'); } - else if (IsUnixPath) + if (IsUnixPath) { return _path.StartsWith("/"); } - else - { - return false; - } + + return false; } } @@ -124,10 +118,8 @@ namespace NzbDrone.Common.Disk { return new OsPath(null); } - else - { - return new OsPath(_path.Substring(0, index), _kind).AsDirectory(); - } + + return new OsPath(_path.Substring(0, index), _kind).AsDirectory(); } } @@ -156,10 +148,8 @@ namespace NzbDrone.Common.Disk return path; } - else - { - return _path.Substring(index).Trim('\\', '/'); - } + + return _path.Substring(index).Trim('\\', '/'); } } @@ -211,14 +201,11 @@ namespace NzbDrone.Common.Disk { return Equals((OsPath)obj); } - else if (obj is String) + if (obj is String) { return Equals(new OsPath(obj as String)); } - else - { - return false; - } + return false; } public OsPath AsDirectory() @@ -228,18 +215,14 @@ namespace NzbDrone.Common.Disk return this; } - if (Kind == OsPathKind.Windows) + switch (Kind) { - return new OsPath(_path.TrimEnd('\\') + "\\", _kind); - } - else if (Kind == OsPathKind.Unix) - { - return new OsPath(_path.TrimEnd('/') + "/", _kind); - } - else - { - return this; + case OsPathKind.Windows: + return new OsPath(_path.TrimEnd('\\') + "\\", _kind); + case OsPathKind.Unix: + return new OsPath(_path.TrimEnd('/') + "/", _kind); } + return this; } public Boolean Contains(OsPath other) @@ -286,10 +269,7 @@ namespace NzbDrone.Common.Disk { return String.Equals(left, right, StringComparison.InvariantCultureIgnoreCase); } - else - { - return String.Equals(left, right, StringComparison.InvariantCulture); - } + return String.Equals(left, right, StringComparison.InvariantCulture); } public static Boolean operator ==(OsPath left, OsPath right) @@ -327,14 +307,11 @@ namespace NzbDrone.Common.Disk { return new OsPath(String.Join("\\", left._path.TrimEnd('\\'), right._path.TrimStart('\\')), OsPathKind.Windows); } - else if (left.Kind == OsPathKind.Unix || right.Kind == OsPathKind.Unix) + if (left.Kind == OsPathKind.Unix || right.Kind == OsPathKind.Unix) { return new OsPath(String.Join("/", left._path.TrimEnd('/'), right._path), OsPathKind.Unix); } - else - { - return new OsPath(String.Join("/", left._path, right._path), OsPathKind.Unknown); - } + return new OsPath(String.Join("/", left._path, right._path), OsPathKind.Unknown); } public static OsPath operator +(OsPath left, String right) @@ -389,10 +366,7 @@ namespace NzbDrone.Common.Disk { return new OsPath(String.Join("\\", newFragments), OsPathKind.Unknown); } - else - { - return new OsPath(String.Join("/", newFragments), OsPathKind.Unknown); - } + return new OsPath(String.Join("/", newFragments), OsPathKind.Unknown); } } diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index 9dddac5a5..cceb312fa 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -63,10 +63,7 @@ namespace NzbDrone.Common.Extensions { return parentPath.Substring(0, index); } - else - { - return null; - } + return null; } public static bool IsParentPath(this string parentPath, string childPath) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index db7aff2fc..ffc86addc 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -210,30 +210,25 @@ namespace NzbDrone.Core.Download.Clients.Deluge catch (WebException ex) { _logger.ErrorException(ex.Message, ex); - if (ex.Status == WebExceptionStatus.ConnectFailure) + switch (ex.Status) { - return new NzbDroneValidationFailure("Host", "Unable to connect") - { - DetailedDescription = "Please verify the hostname and port." - }; - } - else if (ex.Status == WebExceptionStatus.ConnectionClosed) - { - return new NzbDroneValidationFailure("UseSsl", "Verify SSL settings") - { - DetailedDescription = "Please verify your SSL configuration on both Deluge and NzbDrone." - }; - } - else if (ex.Status == WebExceptionStatus.SecureChannelFailure) - { - return new NzbDroneValidationFailure("UseSsl", "Unable to connect through SSL") - { - DetailedDescription = "Drone is unable to connect to Deluge using SSL. This problem could be computer related. Please try to configure both drone and Deluge to not use SSL." - }; - } - else - { - return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message); + case WebExceptionStatus.ConnectFailure: + return new NzbDroneValidationFailure("Host", "Unable to connect") + { + DetailedDescription = "Please verify the hostname and port." + }; + case WebExceptionStatus.ConnectionClosed: + return new NzbDroneValidationFailure("UseSsl", "Verify SSL settings") + { + DetailedDescription = "Please verify your SSL configuration on both Deluge and NzbDrone." + }; + case WebExceptionStatus.SecureChannelFailure: + return new NzbDroneValidationFailure("UseSsl", "Unable to connect through SSL") + { + DetailedDescription = "Drone is unable to connect to Deluge using SSL. This problem could be computer related. Please try to configure both drone and Deluge to not use SSL." + }; + default: + return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message); } } catch (Exception ex) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index 3c4da3d5b..d64a99b4e 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -264,11 +264,8 @@ namespace NzbDrone.Core.Download.Clients.Deluge _logger.Debug("Deluge authentication failed."); throw new DownloadClientAuthenticationException("Failed to authenticate with Deluge."); } - else - { - _logger.Debug("Deluge authentication succeeded."); - _authCookieContainer = restClient.CookieContainer; - } + _logger.Debug("Deluge authentication succeeded."); + _authCookieContainer = restClient.CookieContainer; ConnectDaemon(restClient); } diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/Transmission.cs b/src/NzbDrone.Core/Download/Clients/Transmission/Transmission.cs index 80d5bb67c..2eb1e42d9 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/Transmission.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/Transmission.cs @@ -212,10 +212,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission DetailedDescription = "Please verify the hostname and port." }; } - else - { - return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message); - } + return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message); } catch (Exception ex) { diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs index 72a6f036c..777d433bf 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs @@ -183,20 +183,21 @@ namespace NzbDrone.Core.Download.Clients.Transmission } // We expect the StatusCode = Conflict, coz that will provide us with a new session id. - if (restResponse.StatusCode == HttpStatusCode.Conflict) + switch (restResponse.StatusCode) { - var sessionId = restResponse.Headers.SingleOrDefault(o => o.Name == "X-Transmission-Session-Id"); - - if (sessionId == null) + case HttpStatusCode.Conflict: { - throw new DownloadClientException("Remote host did not return a Session Id."); - } + var sessionId = restResponse.Headers.SingleOrDefault(o => o.Name == "X-Transmission-Session-Id"); - return (String)sessionId.Value; - } - else if (restResponse.StatusCode == HttpStatusCode.Unauthorized) - { - throw new DownloadClientAuthenticationException("User authentication failed."); + if (sessionId == null) + { + throw new DownloadClientException("Remote host did not return a Session Id."); + } + + return (String)sessionId.Value; + } + case HttpStatusCode.Unauthorized: + throw new DownloadClientAuthenticationException("User authentication failed."); } restResponse.ValidateResponse(client); diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index b3a0472d9..13c3088f7 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -223,10 +223,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent DetailedDescription = "Please verify the hostname and port." }; } - else - { - return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message); - } + return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message); } catch (Exception ex) { diff --git a/src/NzbDrone.Core/Download/TorrentClientBase.cs b/src/NzbDrone.Core/Download/TorrentClientBase.cs index c348a8a7b..984d39758 100644 --- a/src/NzbDrone.Core/Download/TorrentClientBase.cs +++ b/src/NzbDrone.Core/Download/TorrentClientBase.cs @@ -108,10 +108,7 @@ namespace NzbDrone.Core.Download { return DownloadFromMagnetUrl(remoteEpisode, locationHeader); } - else - { - throw new WebException("Remote website tried to redirect without providing a location."); - } + throw new WebException("Remote website tried to redirect without providing a location."); } torrentFile = response.ResponseData; diff --git a/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs index 8a58585ed..8ad3933f7 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs @@ -47,7 +47,7 @@ namespace NzbDrone.Core.HealthCheck.Checks return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd)", "Migrating-to-Completed-Download-Handling#sabnzbd-enable-completed-download-handling"); } - else if (downloadClients.All(v => v.downloadClient is Nzbget)) + if (downloadClients.All(v => v.downloadClient is Nzbget)) { // With Nzbget we can check if the category should be changed. if (downloadClientOutputInDroneFactory) @@ -57,10 +57,7 @@ namespace NzbDrone.Core.HealthCheck.Checks return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget)", "Migrating-to-Completed-Download-Handling#nzbget-enable-completed-download-handling"); } - else - { - return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible", "Migrating-to-Completed-Download-Handling"); - } + return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible", "Migrating-to-Completed-Download-Handling"); } if (!_configService.EnableCompletedDownloadHandling && droneFactoryFolder.IsEmpty) diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 755646b41..42f83500c 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -106,10 +106,7 @@ namespace NzbDrone.Core.IndexerSearch { return v.SceneSeasonNumber.Value; } - else - { - return v.SeasonNumber; - } + return v.SeasonNumber; }).Distinct(); foreach (var sceneSeasonEpisodes in sceneSeasonGroups) diff --git a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs index 5d2079d5e..6e1b94bdf 100644 --- a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs @@ -13,21 +13,20 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet { var results = new List(); - if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.Unauthorized) + switch (indexerResponse.HttpResponse.StatusCode) { - throw new ApiKeyException("API Key invalid or not authorized"); - } - else if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound) - { - throw new IndexerException(indexerResponse, "Indexer API call returned NotFound, the Indexer API may have changed."); - } - else if (indexerResponse.HttpResponse.StatusCode == HttpStatusCode.ServiceUnavailable) - { - throw new RequestLimitReachedException("Cannot do more than 150 API requests per hour."); - } - else if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) - { - throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); + case HttpStatusCode.Unauthorized: + throw new ApiKeyException("API Key invalid or not authorized"); + case HttpStatusCode.NotFound: + throw new IndexerException(indexerResponse, "Indexer API call returned NotFound, the Indexer API may have changed."); + case HttpStatusCode.ServiceUnavailable: + throw new RequestLimitReachedException("Cannot do more than 150 API requests per hour."); + default: + if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + { + throw new IndexerException(indexerResponse, "Indexer API call returned an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); + } + break; } var jsonResponse = new HttpResponse>(indexerResponse.HttpResponse).Resource; @@ -46,7 +45,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet { var torrentInfo = new TorrentInfo(); - torrentInfo.Guid = String.Format("BTN-{0}", torrent.TorrentID.ToString()); + torrentInfo.Guid = String.Format("BTN-{0}", torrent.TorrentID); torrentInfo.Title = torrent.ReleaseName; torrentInfo.Size = torrent.Size; torrentInfo.DownloadUrl = torrent.DownloadURL; diff --git a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs index e3ad4135f..3338e0c41 100644 --- a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetRequestGenerator.cs @@ -100,16 +100,13 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet parameters.Tvrage = String.Format("{0}", searchCriteria.Series.TvRageId); return true; } - else if (searchCriteria.Series.TvdbId != 0) + if (searchCriteria.Series.TvdbId != 0) { parameters.Tvdb = String.Format("{0}", searchCriteria.Series.TvdbId); return true; } - else - { - // BTN is very neatly managed, so it's unlikely they map tvrage/tvdb wrongly. - return false; - } + // BTN is very neatly managed, so it's unlikely they map tvrage/tvdb wrongly. + return false; } private IEnumerable GetPagedRequests(Int32 maxPages, BroadcastheNetTorrentQuery parameters) diff --git a/src/NzbDrone.Core/Indexers/RssParser.cs b/src/NzbDrone.Core/Indexers/RssParser.cs index f3230deb6..c1283b0b2 100644 --- a/src/NzbDrone.Core/Indexers/RssParser.cs +++ b/src/NzbDrone.Core/Indexers/RssParser.cs @@ -147,10 +147,7 @@ namespace NzbDrone.Core.Indexers { return item.Element("enclosure").Attribute("url").Value; } - else - { - return item.Element("link").Value; - } + return item.Element("link").Value; } protected virtual string GetInfoUrl(XElement item) @@ -174,7 +171,7 @@ namespace NzbDrone.Core.Indexers { return GetEnclosureLength(item); } - else if (ParseSizeInDescription) + if (ParseSizeInDescription) { return ParseSize(item.Element("description").Value, true); } diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs index 71901ffaa..42627de70 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedEpisodesCommandService.cs @@ -74,15 +74,9 @@ namespace NzbDrone.Core.MediaFiles return _downloadedEpisodesImportService.ProcessFolder(new DirectoryInfo(message.Path)); } - else - { - return _completedDownloadService.Import(trackedDownload, message.Path); - } - } - else - { - return _downloadedEpisodesImportService.ProcessFolder(new DirectoryInfo(message.Path)); + return _completedDownloadService.Import(trackedDownload, message.Path); } + return _downloadedEpisodesImportService.ProcessFolder(new DirectoryInfo(message.Path)); } public void Execute(DownloadedEpisodesScanCommand message) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs index 9fff84570..65e8245e5 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs @@ -79,10 +79,7 @@ namespace NzbDrone.Core.MediaFiles { return TransferFile(episodeFile, localEpisode.Series, localEpisode.Episodes, filePath, TransferMode.HardLinkOrCopy); } - else - { - return TransferFile(episodeFile, localEpisode.Series, localEpisode.Episodes, filePath, TransferMode.Copy); - } + return TransferFile(episodeFile, localEpisode.Series, localEpisode.Episodes, filePath, TransferMode.Copy); } private EpisodeFile TransferFile(EpisodeFile episodeFile, Series series, List episodes, string destinationFilename, TransferMode mode) diff --git a/src/NzbDrone.Core/MetaData/Consumers/Roksbox/RoksboxMetadata.cs b/src/NzbDrone.Core/MetaData/Consumers/Roksbox/RoksboxMetadata.cs index 055902751..1c7329b95 100644 --- a/src/NzbDrone.Core/MetaData/Consumers/Roksbox/RoksboxMetadata.cs +++ b/src/NzbDrone.Core/MetaData/Consumers/Roksbox/RoksboxMetadata.cs @@ -115,11 +115,8 @@ namespace NzbDrone.Core.Metadata.Consumers.Roksbox return metadata; } - else - { - metadata.Type = MetadataType.SeriesImage; - return metadata; - } + metadata.Type = MetadataType.SeriesImage; + return metadata; } var parseResult = Parser.Parser.ParseTitle(filename); diff --git a/src/NzbDrone.Core/MetaData/Consumers/Wdtv/WdtvMetadata.cs b/src/NzbDrone.Core/MetaData/Consumers/Wdtv/WdtvMetadata.cs index 8dab10e29..32aa3d9d9 100644 --- a/src/NzbDrone.Core/MetaData/Consumers/Wdtv/WdtvMetadata.cs +++ b/src/NzbDrone.Core/MetaData/Consumers/Wdtv/WdtvMetadata.cs @@ -112,11 +112,8 @@ namespace NzbDrone.Core.Metadata.Consumers.Wdtv return metadata; } - else - { - metadata.Type = MetadataType.SeriesImage; - return metadata; - } + metadata.Type = MetadataType.SeriesImage; + return metadata; } var parseResult = Parser.Parser.ParseTitle(filename); diff --git a/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs b/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs index 31520042f..889a1acad 100644 --- a/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs @@ -17,10 +17,7 @@ namespace NzbDrone.Core.Parser.Model { return null; } - else - { - return torrentInfo.Seeds; - } + return torrentInfo.Seeds; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index b1f5b74fa..42f8f205f 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -384,10 +384,7 @@ namespace NzbDrone.Core.Parser { return String.Empty; } - else - { - return m.Value; - } + return m.Value; }); return title; diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index 0debd5d60..61d751b79 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -143,20 +143,17 @@ namespace NzbDrone.Core.Parser if (sourceMatch.Groups["bdrip"].Success || sourceMatch.Groups["brrip"].Success) { - if (resolution == Resolution._720p) + switch (resolution) { - result.Quality = Quality.Bluray720p; - return result; - } - else if (resolution == Resolution._1080p) - { - result.Quality = Quality.Bluray1080p; - return result; - } - else - { - result.Quality = Quality.DVD; - return result; + case Resolution._720p: + result.Quality = Quality.Bluray720p; + return result; + case Resolution._1080p: + result.Quality = Quality.Bluray1080p; + return result; + default: + result.Quality = Quality.DVD; + return result; } } diff --git a/src/NzbDrone.Core/Tv/SeriesService.cs b/src/NzbDrone.Core/Tv/SeriesService.cs index d79b9ab15..624d2b1e7 100644 --- a/src/NzbDrone.Core/Tv/SeriesService.cs +++ b/src/NzbDrone.Core/Tv/SeriesService.cs @@ -113,39 +113,36 @@ namespace NzbDrone.Core.Tv // no series matched return null; } - else if (list.Count == 1) + if (list.Count == 1) { // return the first series if there is only one return list.Single(); } - else - { - // build ordered list of series by position in the search string - var query = - list.Select(series => new - { - position = cleanTitle.IndexOf(series.CleanTitle), - length = series.CleanTitle.Length, - series = series - }) - .Where(s => (s.position>=0)) - .ToList() - .OrderBy(s => s.position) - .ThenByDescending(s => s.length) - .ToList(); - - // get the leftmost series that is the longest - // series are usually the first thing in release title, so we select the leftmost and longest match - var match = query.First().series; - - _logger.Debug("Multiple series matched {0} from title {1}", match.Title, title); - foreach (var entry in list) + // build ordered list of series by position in the search string + var query = + list.Select(series => new { - _logger.Debug("Multiple series match candidate: {0} cleantitle: {1}", entry.Title, entry.CleanTitle); - } + position = cleanTitle.IndexOf(series.CleanTitle), + length = series.CleanTitle.Length, + series = series + }) + .Where(s => (s.position>=0)) + .ToList() + .OrderBy(s => s.position) + .ThenByDescending(s => s.length) + .ToList(); - return match; + // get the leftmost series that is the longest + // series are usually the first thing in release title, so we select the leftmost and longest match + var match = query.First().series; + + _logger.Debug("Multiple series matched {0} from title {1}", match.Title, title); + foreach (var entry in list) + { + _logger.Debug("Multiple series match candidate: {0} cleantitle: {1}", entry.Title, entry.CleanTitle); } + + return match; } public Series FindByTitle(string title, int year) diff --git a/src/NzbDrone.Update/UpdateApp.cs b/src/NzbDrone.Update/UpdateApp.cs index 646d1fc0c..ebfd3bdbb 100644 --- a/src/NzbDrone.Update/UpdateApp.cs +++ b/src/NzbDrone.Update/UpdateApp.cs @@ -73,29 +73,27 @@ namespace NzbDrone.Update if (OsInfo.IsMono) { - if (args.Count() == 1) + switch (args.Count()) { - return startupContext; - } - - else if (args.Count() == 3) - { - startupContext.UpdateLocation = args[1]; - startupContext.ExecutingApplication = args[2]; - } - - else - { - logger.Debug("Arguments:"); - - foreach (var arg in args) + case 1: + return startupContext; + case 3: + startupContext.UpdateLocation = args[1]; + startupContext.ExecutingApplication = args[2]; + break; + default: { - logger.Debug(" {0}", arg); + logger.Debug("Arguments:"); + + foreach (var arg in args) + { + logger.Debug(" {0}", arg); + } + + var message = String.Format("Number of arguments are unexpected, expected: 3, found: {0}", args.Count()); + + throw new ArgumentOutOfRangeException("args", message); } - - var message = String.Format("Number of arguments are unexpected, expected: 3, found: {0}", args.Count()); - - throw new ArgumentOutOfRangeException("args", message); } }