diff --git a/NzbDrone.Core/Main.cs b/NzbDrone.Core/Main.cs index f05461cd9..8e22872a1 100644 --- a/NzbDrone.Core/Main.cs +++ b/NzbDrone.Core/Main.cs @@ -11,7 +11,6 @@ namespace NzbDrone.Core { public static class Main { - public static void BindKernel(IKernel kernel) { string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db")); @@ -30,4 +29,4 @@ namespace NzbDrone.Core get { return new DirectoryInfo(HttpContext.Current.Server.MapPath("\\")).Parent.FullName; } } } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/ConfigProvider.cs b/NzbDrone.Core/Providers/ConfigProvider.cs index 83af5b588..303cfeb92 100644 --- a/NzbDrone.Core/Providers/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/ConfigProvider.cs @@ -11,7 +11,6 @@ namespace NzbDrone.Core.Providers private readonly ILog _logger; private readonly IRepository _sonicRepo; - public ConfigProvider(ILog logger, IRepository dataRepository) { _logger = logger; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Providers _sonicRepo = dataRepository; } - private string GetValue(string key) { return GetValue(key, String.Empty, false); @@ -27,39 +25,23 @@ namespace NzbDrone.Core.Providers public String SeriesRoot { - get - { - return GetValue(SERIES_ROOTS); - } - - set - { - SetValue(SERIES_ROOTS, value); - } + get { return GetValue(SERIES_ROOTS); } + set { SetValue(SERIES_ROOTS, value); } } - public string GetValue(string key, object defaultValue, bool makePermanent) { string value; var dbValue = _sonicRepo.Single(key); - if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value)) - { - return dbValue.Value; - } - + if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value)) return dbValue.Value; _logger.WarnFormat("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue); - if (makePermanent) - { - SetValue(key, defaultValue.ToString()); - } + if (makePermanent) SetValue(key, defaultValue.ToString()); value = defaultValue.ToString(); - return value; } @@ -72,10 +54,7 @@ namespace NzbDrone.Core.Providers var dbValue = _sonicRepo.Single(key); - if (dbValue == null) - { - _sonicRepo.Add(new Config { Key = key, Value = value }); - } + if (dbValue == null) _sonicRepo.Add(new Config {Key = key, Value = value}); else { dbValue.Value = value; diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index 5f3a8bc66..1f059a3f0 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -6,9 +6,7 @@ namespace NzbDrone.Core.Providers { public class EpisodeProvider { - private static Regex _parseRegex = - new Regex( - @"(?.*) + private static readonly Regex _parseRegex = new Regex(@"(?.*) (?: s(?\d+)e(?\d+)-?e(?\d+) | s(?\d+)e(?\d+) @@ -23,24 +21,13 @@ namespace NzbDrone.Core.Providers | (?.*) )", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace); - public static Episode Parse(string title) { Match match = _parseRegex.Match(title); - if (!match.Success) - return null; + if (!match.Success) return null; - return new Episode - { - - Season = ParseInt(match.Groups["seasonNumber"].Value), - EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value), - EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value), - Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value), - Release = ReplaceSeparatorChars(match.Groups["release"].Value), - Proper = title.Contains("PROPER") - }; + return new Episode {Season = ParseInt(match.Groups["seasonNumber"].Value), EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value), EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value), Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value), Release = ReplaceSeparatorChars(match.Groups["release"].Value), Proper = title.Contains("PROPER")}; } private static string ReplaceSeparatorChars(string s) @@ -59,10 +46,8 @@ namespace NzbDrone.Core.Providers private static DateTime ParseAirDate(string s) { DateTime d; - if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d)) - return d; + if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d)) return d; return DateTime.MinValue; } - } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/HttpProvider.cs b/NzbDrone.Core/Providers/HttpProvider.cs index acd2a2d57..b4c153012 100644 --- a/NzbDrone.Core/Providers/HttpProvider.cs +++ b/NzbDrone.Core/Providers/HttpProvider.cs @@ -1,13 +1,12 @@ -using System; -using System.Net; +using System.Net; namespace NzbDrone.Core.Providers { - class HttpProvider : IHttpProvider + internal class HttpProvider : IHttpProvider { public string DownloadString(string request) { return new WebClient().DownloadString(request); } } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/IDownloadProvider.cs b/NzbDrone.Core/Providers/IDownloadProvider.cs index 99fe3a957..8b6c52a7c 100644 --- a/NzbDrone.Core/Providers/IDownloadProvider.cs +++ b/NzbDrone.Core/Providers/IDownloadProvider.cs @@ -1,10 +1,8 @@ -using NzbDrone.Core.Repository; - -namespace NzbDrone.Core.Providers +namespace NzbDrone.Core.Providers { public interface IDownloadProvider { bool AddByUrl(string url, string title); //Should accept something other than string (NzbInfo?) returns success or failure - bool IsInQueue(string title);//Should accept something other than string (Episode?) returns bool + bool IsInQueue(string title); //Should accept something other than string (Episode?) returns bool } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/IHttpProvider.cs b/NzbDrone.Core/Providers/IHttpProvider.cs index 00b808ffb..ae4e54ca4 100644 --- a/NzbDrone.Core/Providers/IHttpProvider.cs +++ b/NzbDrone.Core/Providers/IHttpProvider.cs @@ -4,4 +4,4 @@ { string DownloadString(string request); } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/SabProvider.cs b/NzbDrone.Core/Providers/SabProvider.cs index eb4e41411..90f6f943c 100644 --- a/NzbDrone.Core/Providers/SabProvider.cs +++ b/NzbDrone.Core/Providers/SabProvider.cs @@ -1,9 +1,8 @@ using System; using System.Linq; using System.Web; -using log4net; using System.Xml.Linq; -using NzbDrone.Core.Repository; +using log4net; namespace NzbDrone.Core.Providers { @@ -38,8 +37,7 @@ namespace NzbDrone.Core.Providers string response = _http.DownloadString(request).Replace("\n", String.Empty); _logger.DebugFormat("Queue Repsonse: [{0}]", response); - if (response == "ok") - return true; + if (response == "ok") return true; return false; } @@ -53,14 +51,14 @@ namespace NzbDrone.Core.Providers XDocument xDoc = XDocument.Parse(response); //If an Error Occurred, retuyrn) - if (xDoc.Descendants("error").Count() != 0) - return false; + if (xDoc.Descendants("error").Count() != 0) return false; - if (xDoc.Descendants("queue").Count() == 0) - return false; + if (xDoc.Descendants("queue").Count() == 0) return false; //Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue))) - if ((from s in xDoc.Descendants("slot") where s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase) select s).Count() != 0) + if ((from s in xDoc.Descendants("slot") + where s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase) + select s).Count() != 0) { _logger.DebugFormat("Episode in queue - '{0}'", title); @@ -79,9 +77,7 @@ namespace NzbDrone.Core.Providers string password = _config.GetValue("Password", String.Empty, false); string apiKey = _config.GetValue("ApiKey", String.Empty, false); - return string.Format( - @"http://{0}/sabnzbd/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", - sabnzbdInfo, apiKey, username, password).Replace("$Action", action); + return string.Format(@"http://{0}/sabnzbd/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey, username, password).Replace("$Action", action); } } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 791aa8e55..e0f75d4f1 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -36,11 +36,8 @@ namespace NzbDrone.Core.Providers return _sonioRepo.Single(s => s.TvdbId == tvdbId.ToString()); } - - public void SyncSeriesWithDisk() { - foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot)) { var cleanPath = DiskProvider.CleanPath(new DirectoryInfo(seriesFolder).FullName); @@ -50,7 +47,6 @@ namespace NzbDrone.Core.Providers AddShow(cleanPath); } } - } #endregion @@ -58,10 +54,7 @@ namespace NzbDrone.Core.Providers private void AddShow(string path) { var searchResults = _tvDb.SearchSeries(new DirectoryInfo(path).Name); - if (searchResults.Count != 0 && !_sonioRepo.Exists(s => s.TvdbId == searchResults[0].Id.ToString())) - { - AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language)); - } + if (searchResults.Count != 0 && !_sonioRepo.Exists(s => s.TvdbId == searchResults[0].Id.ToString())) AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language)); } private void AddShow(string path, TvdbSeries series) diff --git a/NzbDrone.Core/Repository/Episode.cs b/NzbDrone.Core/Repository/Episode.cs index f7142f8ab..8543a1f83 100644 --- a/NzbDrone.Core/Repository/Episode.cs +++ b/NzbDrone.Core/Repository/Episode.cs @@ -8,6 +8,7 @@ namespace NzbDrone.Core.Repository { [SubSonicPrimaryKey] public string EpisodeId { get; set; } + public string SeriesId { get; set; } public string Title { get; set; } public string Title2 { get; set; } @@ -19,6 +20,6 @@ namespace NzbDrone.Core.Repository public int Quality { get; set; } public bool Proper { get; set; } public String FileName { get; set; } - public SyndicationItem Feed { get; set; } + public SyndicationItem Feed { get; set; } } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Quality.cs b/NzbDrone.Core/Repository/Quality.cs index b1516f103..2bb406b39 100644 --- a/NzbDrone.Core/Repository/Quality.cs +++ b/NzbDrone.Core/Repository/Quality.cs @@ -2,34 +2,33 @@ namespace NzbDrone.Core.Repository { // ReSharper disable InconsistentNaming /// - /// Represents Video Quality + /// Represents Video Quality /// public enum Quality { /// - /// Quality is unknown + /// Quality is unknown /// Unknown = 0, /// - /// SD File (Source could be HD) + /// SD File (Source could be HD) /// SDTV = 1, /// - /// SD File (DVD Source) + /// SD File (DVD Source) /// DVD = 2, /// - /// HD File (HDTV Source) + /// HD File (HDTV Source) /// HDTV = 3, /// - /// HD File (Online Source) + /// HD File (Online Source) /// WEBDL = 4, /// - /// HD File (Blu-ray Source) + /// HD File (Blu-ray Source) /// Bluray = 5 - } } \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Series.cs b/NzbDrone.Core/Repository/Series.cs index afd886c99..7a28b8c0c 100644 --- a/NzbDrone.Core/Repository/Series.cs +++ b/NzbDrone.Core/Repository/Series.cs @@ -6,54 +6,21 @@ namespace NzbDrone.Core.Repository public class Series { [SubSonicPrimaryKey] - public string TvdbId - { - get; - set; - } + public string TvdbId { get; set; } - public string SeriesName - { - get; - set; - } + public string SeriesName { get; set; } - public string Status - { - get; - set; - } + public string Status { get; set; } [SubSonicLongString] - public string Overview - { - get; - set; - } + public string Overview { get; set; } - public DayOfWeek? AirsDayOfWeek - { - get; - set; - } + public DayOfWeek? AirsDayOfWeek { get; set; } - public String AirTimes - { - get; - set; - } + public String AirTimes { get; set; } - public string Language - { - get; - set; - } - - public string Path - { - get; - set; - } + public string Language { get; set; } + public string Path { get; set; } } -} +} \ No newline at end of file