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-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-06-08 17:53:26 +00:00
|
|
|
|
public override IParseFeed Parser
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-08-06 05:06:58 +00:00
|
|
|
|
return new NewznabParser();
|
2013-06-08 17:53:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
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,
|
2013-08-06 05:06:58 +00:00
|
|
|
|
Settings = GetSettings("http://nzbs.org", new List<Int32> { 5000 })
|
2013-05-02 01:59:09 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.Add(new IndexerDefinition
|
|
|
|
|
{
|
|
|
|
|
Enable = false,
|
|
|
|
|
Name = "Nzb.su",
|
|
|
|
|
Implementation = GetType().Name,
|
2013-07-31 03:41:46 +00:00
|
|
|
|
Settings = GetSettings("https://nzb.su", new List<Int32>())
|
2013-05-02 01:59:09 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
list.Add(new IndexerDefinition
|
|
|
|
|
{
|
|
|
|
|
Enable = false,
|
|
|
|
|
Name = "Dognzb.cr",
|
|
|
|
|
Implementation = GetType().Name,
|
2013-07-31 03:41:46 +00:00
|
|
|
|
Settings = GetSettings("https://dognzb.cr", new List<Int32>())
|
2013-05-02 01:59:09 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-31 03:41:46 +00:00
|
|
|
|
private string GetSettings(string url, List<int> categories)
|
2013-05-02 01:59:09 +00:00
|
|
|
|
{
|
2013-07-31 03:41:46 +00:00
|
|
|
|
var settings = new NewznabSettings { Url = url };
|
|
|
|
|
|
|
|
|
|
if (categories.Any())
|
|
|
|
|
{
|
|
|
|
|
settings.Categories = categories;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return settings.ToJson();
|
2013-05-02 01:59:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-07 07:30:37 +00:00
|
|
|
|
public override IEnumerable<string> RecentFeed
|
|
|
|
|
{
|
2013-05-02 01:59:09 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
2013-07-31 03:41:46 +00:00
|
|
|
|
//Todo: We should be able to update settings on start
|
2013-08-03 21:39:07 +00:00
|
|
|
|
if (Name.Equals("nzbs.org", StringComparison.InvariantCultureIgnoreCase))
|
2013-07-31 03:41:46 +00:00
|
|
|
|
{
|
2013-08-06 05:06:58 +00:00
|
|
|
|
Settings.Categories = new List<int> { 5000 };
|
2013-07-31 03:41:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-19 05:53:26 +00:00
|
|
|
|
var url = String.Format("{0}/api?t=tvsearch&cat={1}&extended=1", Settings.Url.TrimEnd('/'), String.Join(",", Settings.Categories));
|
2013-05-02 01:59:09 +00:00
|
|
|
|
|
2013-06-03 23:07:36 +00:00
|
|
|
|
if (!String.IsNullOrWhiteSpace(Settings.ApiKey))
|
2013-05-02 01:59:09 +00:00
|
|
|
|
{
|
|
|
|
|
url += "&apikey=" + Settings.ApiKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield return url;
|
|
|
|
|
}
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-06 07:38:16 +00:00
|
|
|
|
public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber)
|
2013-04-07 07:30:37 +00:00
|
|
|
|
{
|
2013-08-07 03:10:28 +00:00
|
|
|
|
if (tvRageId > 0)
|
|
|
|
|
{
|
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&rid={1}&season={2}&ep={3}", url, tvRageId, seasonNumber, episodeNumber));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2013-08-06 07:38:16 +00:00
|
|
|
|
public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date)
|
2013-04-07 07:30:37 +00:00
|
|
|
|
{
|
2013-08-07 03:10:28 +00:00
|
|
|
|
if (tvRageId > 0)
|
|
|
|
|
{
|
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&rid={1}&season={2:yyyy}&ep={2:MM/dd}", url, tvRageId, date)).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2013-08-22 04:42:25 +00:00
|
|
|
|
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset)
|
2013-04-07 07:30:37 +00:00
|
|
|
|
{
|
2013-08-07 03:10:28 +00:00
|
|
|
|
if (tvRageId > 0)
|
|
|
|
|
{
|
2013-08-22 04:42:25 +00:00
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&rid={1}&season={2}&offset={3}", url, tvRageId, seasonNumber, offset));
|
2013-08-07 03:10:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-22 04:42:25 +00:00
|
|
|
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}&offset={3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, offset));
|
2013-04-07 07:30:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-22 04:42:25 +00:00
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|