From 97370cc8b3d5c8edea5d31318522a7a6d6477e59 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 27 Sep 2014 18:39:26 -0700 Subject: [PATCH] omgwtfnzbs fixes New: connect to omgwtfnzbs over https Fixed: No results found response for omgwtfnzbs --- .../Definitions/DailyEpisodeSearchCriteria.cs | 2 +- .../Indexers/Omgwtfnzbs/Omgwtfnzbs.cs | 6 +---- .../Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs | 3 +-- src/NzbDrone.Core/Indexers/RssParser.cs | 22 +++++++++++++++++-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs index 6035f9fab..d5eeb15b7 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/DailyEpisodeSearchCriteria.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public override string ToString() { - return string.Format("[{0} : {1}", Series.Title, AirDate); + return string.Format("[{0} : {1:yyyy-MM-dd}", Series.Title, AirDate); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs index bc3e04cf7..d2fe5bb4b 100644 --- a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs +++ b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/Omgwtfnzbs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FluentValidation.Results; -using NLog; +using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Parser; diff --git a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs index 24ca33843..441ef59f9 100644 --- a/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsRequestGenerator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using NzbDrone.Common; using NzbDrone.Common.Http; @@ -15,7 +14,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs public OmgwtfnzbsRequestGenerator() { - BaseUrl = "http://rss.omgwtfnzbs.org/rss-search.php"; + BaseUrl = "https://rss.omgwtfnzbs.org/rss-search.php"; } public virtual IList> GetRecentRequests() diff --git a/src/NzbDrone.Core/Indexers/RssParser.cs b/src/NzbDrone.Core/Indexers/RssParser.cs index 094fa2a7f..d7ab279a9 100644 --- a/src/NzbDrone.Core/Indexers/RssParser.cs +++ b/src/NzbDrone.Core/Indexers/RssParser.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Text; using System.Text.RegularExpressions; using System.Xml; using System.Xml.Linq; @@ -46,7 +45,7 @@ namespace NzbDrone.Core.Indexers using (var xmlTextReader = XmlReader.Create(new StringReader(indexerResponse.Content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true })) { var document = XDocument.Load(xmlTextReader); - var items = document.Root.Element("channel").Elements("item"); + var items = GetItems(document); foreach (var item in items) { @@ -231,5 +230,24 @@ namespace NzbDrone.Core.Indexers return Convert.ToInt64(result); } + + private IEnumerable GetItems(XDocument document) + { + var root = document.Root; + + if (root == null) + { + return Enumerable.Empty(); + } + + var channel = root.Element("channel"); + + if (channel == null) + { + return Enumerable.Empty(); + } + + return channel.Elements("item"); + } } }