parent
54c36e9264
commit
966b9d62b7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Nzbx
|
||||
{
|
||||
public class Nzbx : IndexerBase
|
||||
{
|
||||
public override IParseFeed Parser
|
||||
{
|
||||
get
|
||||
{
|
||||
return new NzbxParser();
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "nzbx"; }
|
||||
}
|
||||
|
||||
public override IEnumerable<string> RecentFeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return new[] { String.Format("https://nzbx.co/api/recent?category=tv") };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
yield return String.Format("https://nzbx.co/api/search?q={0}+S{1:00}E{2:00}", seriesTitle, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
|
||||
{
|
||||
yield return String.Format("https://nzbx.co/api/search?q={0}+{1:yyyy MM dd}", seriesTitle, date);
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
|
||||
{
|
||||
yield return String.Format("https://nzbx.co/api/search?q={0}+S{1:00}", seriesTitle, seasonNumber);
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
|
||||
{
|
||||
yield return String.Format("https://nzbx.co/api/search?q={0}+S{1:00}E{2}", seriesTitle, seasonNumber, episodeWildcard);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Nzbx
|
||||
{
|
||||
public class NzbxParser : IParseFeed
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private readonly JsonSerializer _serializer;
|
||||
|
||||
public NzbxParser()
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_serializer = new JsonSerializer();
|
||||
}
|
||||
|
||||
public IEnumerable<ReportInfo> Process(Stream source)
|
||||
{
|
||||
var result = new List<ReportInfo>();
|
||||
var jsonReader = new JsonTextReader(new StreamReader(source));
|
||||
var feed = _serializer.Deserialize<List<NzbxRecentItem>>(jsonReader);
|
||||
|
||||
foreach (var item in feed.Where(c => !string.IsNullOrWhiteSpace(c.Name)))
|
||||
{
|
||||
try
|
||||
{
|
||||
var reportInfo = new ReportInfo();
|
||||
reportInfo.Age = DateTime.Now.Date.Subtract(item.PostDate).Days;
|
||||
reportInfo.Title = item.Name;
|
||||
reportInfo.NzbUrl = String.Format("http://nzbx.co/nzb?{0}*|*{1}", item.Guid, item.Name);
|
||||
reportInfo.NzbInfoUrl = String.Format("http://nzbx.co/d?{0}", item.Guid);
|
||||
reportInfo.Size = item.Size;
|
||||
|
||||
result.Add(reportInfo);
|
||||
}
|
||||
catch (Exception itemEx)
|
||||
{
|
||||
itemEx.Data.Add("Item", item.Name);
|
||||
_logger.ErrorException("An error occurred while processing feed item", itemEx);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue