Added RSS support for torrents

This commit is contained in:
Keivan Beigi
2013-09-13 16:17:58 -07:00
parent 89d603d71c
commit 82b06bab7a
59 changed files with 577 additions and 268 deletions
+21 -2
View File
@@ -11,7 +11,6 @@ namespace NzbDrone.Core.Indexers
{
public static class XElementExtensions
{
private static readonly Logger Logger = NzbDroneLogger.GetLogger();
private static readonly Regex RemoveTimeZoneRegex = new Regex(@"\s[A-Z]{2,4}$", RegexOptions.Compiled);
@@ -21,6 +20,21 @@ namespace NzbDrone.Core.Indexers
return item.TryGetValue("title", "Unknown");
}
public static XElement StripNameSpace(this XElement root)
{
var res = new XElement(
root.Name.LocalName,
root.HasElements ?
root.Elements().Select(StripNameSpace) :
(object)root.Value
);
res.ReplaceAttributes(
root.Attributes().Where(attr => (!attr.IsNamespaceDeclaration)));
return res;
}
public static DateTime PublishDate(this XElement item)
{
string dateString = item.TryGetValue("pubDate");
@@ -33,7 +47,7 @@ namespace NzbDrone.Core.Indexers
dateString = RemoveTimeZoneRegex.Replace(dateString, "");
result = DateTime.Parse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal);
}
return result.ToUniversalTime();
return result.ToUniversalTime().Date;
}
catch (FormatException e)
{
@@ -59,6 +73,11 @@ namespace NzbDrone.Core.Indexers
return item.TryGetValue("comments");
}
public static long Length(this XElement item)
{
return long.Parse(item.TryGetValue("length"));
}
private static string TryGetValue(this XElement item, string elementName, string defaultValue = "")
{
var element = item.Element(elementName);