mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-22 22:15:17 -04:00
Added RSS support for torrents
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user