2013-04-07 07:30:37 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-04-07 22:40:13 +00:00
|
|
|
|
using System.Linq;
|
2013-05-02 01:59:09 +00:00
|
|
|
|
using NzbDrone.Common;
|
2013-05-12 15:18:17 +00:00
|
|
|
|
using NzbDrone.Common.Serializer;
|
2013-04-07 07:30:37 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.Newznab
|
|
|
|
|
{
|
2013-05-02 01:59:09 +00:00
|
|
|
|
public class Newznab : IndexerWithSetting<NewznabSettings>
|
2013-04-07 07:30:37 +00:00
|
|
|
|
{
|
2013-05-02 01:59:09 +00:00
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
2013-04-07 07:30:37 +00:00
|
|
|
|
|
2013-05-02 01:59:09 +00:00
|
|
|
|
public Newznab()
|
2013-04-07 07:30:37 +00:00
|
|
|
|
{
|
2013-05-02 01:59:09 +00:00
|
|
|
|
_jsonSerializer = new JsonSerializer();
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-05-02 01:59:09 +00:00
|
|
|
|
public override IEnumerable<IndexerDefinition> DefaultDefinitions
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var list = new List<IndexerDefinition>();
|
|
|
|
|
|
|
|
|
|
list.Add(new IndexerDefinition
|
|
|
|
|
{
|
|
|
|
|
Enable = false,
|
|
|
|
|
Name = "Nzbs.org",
|
|
|
|
|
Implementation = GetType().Name,
|
|
|
|
|
Settings = GetSettings("http://nzbs.org")
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.Add(new IndexerDefinition
|
|
|
|
|
{
|
|
|
|
|
Enable = false,
|
|
|
|
|
Name = "Nzb.su",
|
|
|
|
|
Implementation = GetType().Name,
|
|
|
|
|
Settings = GetSettings("https://nzb.su")
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
list.Add(new IndexerDefinition
|
|
|
|
|
{
|
|
|
|
|
Enable = false,
|
|
|
|
|
Name = "Dognzb.cr",
|
|
|
|
|
Implementation = GetType().Name,
|
|
|
|
|
Settings = GetSettings("https://dognzb.cr")
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetSettings(string url)
|
|
|
|
|
{
|
|
|
|
|
return _jsonSerializer.Serialize(new NewznabSettings { Url = url });
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-07 07:30:37 +00:00
|
|
|
|
public override IEnumerable<string> RecentFeed
|
|
|
|
|
{
|
2013-05-02 01:59:09 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var url = String.Format("{0}/api?t=tvsearch&cat=5030,5040,5070,5090s", Settings.Url);
|
|
|
|
|
|
|
|
|
|
if (String.IsNullOrWhiteSpace(Settings.ApiKey))
|
|
|
|
|
{
|
|
|
|
|
url += "&apikey=" + Settings.ApiKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield return url;
|
|
|
|
|
}
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
|
|
|
|
{
|
2013-04-07 22:40:13 +00:00
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}&ep={3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, episodeNumber));
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
|
|
|
|
|
{
|
2013-04-07 22:40:13 +00:00
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2:yyyy}&ep={2:MM/dd}", url, NewsnabifyTitle(seriesTitle), date)).ToList();
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
|
|
|
|
|
{
|
2013-04-07 22:40:13 +00:00
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}", url, NewsnabifyTitle(seriesTitle), seasonNumber));
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
|
|
|
|
|
{
|
2013-04-07 22:40:13 +00:00
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}+S{2:00}E{3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, episodeWildcard));
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
2013-05-02 01:59:09 +00:00
|
|
|
|
get
|
2013-04-07 07:30:37 +00:00
|
|
|
|
{
|
2013-05-02 01:59:09 +00:00
|
|
|
|
return InstanceDefinition.Name;
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string NewsnabifyTitle(string title)
|
|
|
|
|
{
|
|
|
|
|
return title.Replace("+", "%20");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|