From c7286863b00a5004d211da1824d5850ef4d6df22 Mon Sep 17 00:00:00 2001 From: Keivan Date: Mon, 27 Sep 2010 22:35:15 -0700 Subject: [PATCH] Removed redundent classes. --- NzbDrone.Core.Test/SabControllerTest.cs | 26 +++----------- NzbDrone.Core/NzbDrone.Core.csproj | 3 +- NzbDrone.Core/Providers/IDownloadProvider.cs | 4 +-- NzbDrone.Core/Providers/SabProvider.cs | 12 +++---- NzbDrone.Core/Repository/Config.cs | 15 ++------ NzbDrone.Core/Repository/Episode.cs | 9 ++--- NzbDrone.Core/Repository/ItemInfo.cs | 21 ------------ NzbDrone.Core/Repository/Site.cs | 36 -------------------- 8 files changed, 22 insertions(+), 104 deletions(-) delete mode 100644 NzbDrone.Core/Repository/ItemInfo.cs delete mode 100644 NzbDrone.Core/Repository/Site.cs diff --git a/NzbDrone.Core.Test/SabControllerTest.cs b/NzbDrone.Core.Test/SabControllerTest.cs index 0c45c3b00..6a3060d0f 100644 --- a/NzbDrone.Core.Test/SabControllerTest.cs +++ b/NzbDrone.Core.Test/SabControllerTest.cs @@ -38,12 +38,8 @@ namespace NzbDrone.Core.Test var target = new SabProvider(config.Object, new Mock().Object, http.Object); - ItemInfo nzb = new ItemInfo(); - nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232"); - nzb.Title = "This is an Nzb"; - //Act - bool result = target.AddByUrl(nzb); + bool result = target.AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb"); //Assert Assert.AreEqual(true, result); @@ -71,12 +67,8 @@ namespace NzbDrone.Core.Test var target = new SabProvider(config.Object, new Mock().Object, http.Object); - ItemInfo nzb = new ItemInfo(); - nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232"); - nzb.Title = "This is an Nzb"; - //Act - bool result = target.AddByUrl(nzb); + bool result = target.AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb"); //Assert Assert.AreEqual(false, result); @@ -108,12 +100,8 @@ namespace NzbDrone.Core.Test var target = new SabProvider(config.Object, new Mock().Object, http.Object); - Episode episode = new Episode(); - - episode.FileName = "Ubuntu Test"; - //Act - bool result = target.IsInQueue(episode); + bool result = target.IsInQueue("Ubuntu Test"); //Assert Assert.AreEqual(true, result); @@ -145,10 +133,8 @@ namespace NzbDrone.Core.Test var target = new SabProvider(config.Object, new Mock().Object, http.Object); - Episode episode = new Episode(); - //Act - bool result = target.IsInQueue(episode); + bool result = target.IsInQueue(String.Empty); //Assert Assert.AreEqual(false, result); @@ -180,10 +166,8 @@ namespace NzbDrone.Core.Test var target = new SabProvider(config.Object, new Mock().Object, http.Object); - Episode episode = new Episode(); - //Act - bool result = target.IsInQueue(episode); + bool result = target.IsInQueue(String.Empty); //Assert Assert.AreEqual(false, result); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 847807047..d252cc87b 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -129,6 +129,7 @@ + @@ -145,9 +146,7 @@ - - diff --git a/NzbDrone.Core/Providers/IDownloadProvider.cs b/NzbDrone.Core/Providers/IDownloadProvider.cs index 50abfbc6a..99fe3a957 100644 --- a/NzbDrone.Core/Providers/IDownloadProvider.cs +++ b/NzbDrone.Core/Providers/IDownloadProvider.cs @@ -4,7 +4,7 @@ namespace NzbDrone.Core.Providers { public interface IDownloadProvider { - bool AddByUrl(ItemInfo nzb); //Should accept something other than string (NzbInfo?) returns success or failure - bool IsInQueue(Episode episode);//Should accept something other than string (Episode?) returns bool + 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 } } diff --git a/NzbDrone.Core/Providers/SabProvider.cs b/NzbDrone.Core/Providers/SabProvider.cs index 04d5a9900..eb4e41411 100644 --- a/NzbDrone.Core/Providers/SabProvider.cs +++ b/NzbDrone.Core/Providers/SabProvider.cs @@ -22,13 +22,13 @@ namespace NzbDrone.Core.Providers #region IDownloadProvider Members - public bool AddByUrl(ItemInfo nzb) + public bool AddByUrl(string url, string title) { const string mode = "addurl"; const string cat = "tv"; string priority = _config.GetValue("Priority", String.Empty, false); - string name = nzb.Link.ToString().Replace("&", "%26"); - string nzbName = HttpUtility.UrlEncode(nzb.Title); + string name = url.Replace("&", "%26"); + string nzbName = HttpUtility.UrlEncode(title); string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, name, priority, cat, nzbName); string request = GetSabRequest(action); @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Providers return false; } - public bool IsInQueue(Episode epsiode) + public bool IsInQueue(string title) { string action = "mode=queue&output=xml"; string request = GetSabRequest(action); @@ -60,9 +60,9 @@ namespace NzbDrone.Core.Providers 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(epsiode.FileName, 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}'", epsiode.FileName); + _logger.DebugFormat("Episode in queue - '{0}'", title); return true; } diff --git a/NzbDrone.Core/Repository/Config.cs b/NzbDrone.Core/Repository/Config.cs index 9832355a1..42cf82435 100644 --- a/NzbDrone.Core/Repository/Config.cs +++ b/NzbDrone.Core/Repository/Config.cs @@ -5,17 +5,8 @@ namespace NzbDrone.Core.Repository public class Config { [SubSonicPrimaryKey] - public string Key - { - get; - set; - } - - public string Value - { - get; - set; - } + public string Key { get; set; } + public string Value { get; set; } } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Episode.cs b/NzbDrone.Core/Repository/Episode.cs index a76efdae3..f7142f8ab 100644 --- a/NzbDrone.Core/Repository/Episode.cs +++ b/NzbDrone.Core/Repository/Episode.cs @@ -1,13 +1,13 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; +using System.ServiceModel.Syndication; +using SubSonic.SqlGeneration.Schema; namespace NzbDrone.Core.Repository { public class Episode { + [SubSonicPrimaryKey] + public string EpisodeId { get; set; } public string SeriesId { get; set; } public string Title { get; set; } public string Title2 { get; set; } @@ -19,5 +19,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; } } } diff --git a/NzbDrone.Core/Repository/ItemInfo.cs b/NzbDrone.Core/Repository/ItemInfo.cs deleted file mode 100644 index 6482203f4..000000000 --- a/NzbDrone.Core/Repository/ItemInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Repository -{ - public class ItemInfo - { - public string Id { get; set; } - public string Title { get; set; } - public Site Site { get; set; } - public Uri Link { get; set; } - public string Description { get; set; } - - public bool IsPassworded() - { - return Title.EndsWith("(Passworded)", StringComparison.InvariantCultureIgnoreCase); - } - } -} diff --git a/NzbDrone.Core/Repository/Site.cs b/NzbDrone.Core/Repository/Site.cs deleted file mode 100644 index 8c53795b6..000000000 --- a/NzbDrone.Core/Repository/Site.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; - -namespace NzbDrone.Core.Repository -{ - public class Site - { - private static readonly IList Sites = new List - { - new Site {Name = "nzbmatrix", Url = "nzbmatrix.com", Pattern = @"\d{6,10}"}, - new Site {Name = "nzbsDotOrg", Url = "nzbs.org", Pattern = @"\d{5,10}"}, - new Site {Name = "nzbsrus", Url = "nzbsrus.com", Pattern = @"\d{6,10}"}, - new Site {Name = "lilx", Url = "lilx.net", Pattern = @"\d{6,10}"}, - }; - - public string Name { get; set; } - public string Pattern { get; set; } - public string Url { get; set; } - - // TODO: use HttpUtility.ParseQueryString(); - // https://nzbmatrix.com/api-nzb-download.php?id=626526 - public string ParseId(string url) - { - return Regex.Match(url, Pattern).Value; - } - - public static Site Parse(string url) - { - return Sites.Where(site => url.Contains(site.Url)).SingleOrDefault() ?? - new Site { Name = "unknown", Pattern = @"\d{6,10}" }; - } - } -}