2014-04-22 01:50:43 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2014-05-19 22:14:41 +03:00
|
|
|
using System.Text.RegularExpressions;
|
2014-07-04 11:09:48 +03:00
|
|
|
using FluentValidation.Results;
|
2014-04-22 01:50:43 +03:00
|
|
|
using NzbDrone.Core.ThingiProvider;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.Fanzub
|
|
|
|
{
|
|
|
|
public class Fanzub : IndexerBase<NullConfig>
|
|
|
|
{
|
2014-05-19 22:14:41 +03:00
|
|
|
private static readonly Regex RemoveCharactersRegex = new Regex(@"[!?`]", RegexOptions.Compiled);
|
|
|
|
|
2014-04-22 01:50:43 +03:00
|
|
|
public override DownloadProtocol Protocol
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return DownloadProtocol.Usenet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-18 05:25:00 +03:00
|
|
|
public override bool SupportsSearch
|
2014-04-22 01:50:43 +03:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override IParseFeed Parser
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return new FanzubParser();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override IEnumerable<string> RecentFeed
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2014-09-01 08:52:26 +03:00
|
|
|
yield return "http://fanzub.com/rss/?cat=anime&max=100";
|
2014-04-22 01:50:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:14:41 +03:00
|
|
|
public override IEnumerable<string> GetEpisodeSearchUrls(List<String> titles, int tvRageId, int seasonNumber, int episodeNumber)
|
2014-04-22 01:50:43 +03:00
|
|
|
{
|
|
|
|
return new List<string>();
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:14:41 +03:00
|
|
|
public override IEnumerable<string> GetSeasonSearchUrls(List<String> titles, int tvRageId, int seasonNumber, int offset)
|
2014-04-22 01:50:43 +03:00
|
|
|
{
|
|
|
|
return new List<string>();
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:14:41 +03:00
|
|
|
public override IEnumerable<string> GetDailyEpisodeSearchUrls(List<String> titles, int tvRageId, DateTime date)
|
2014-04-22 01:50:43 +03:00
|
|
|
{
|
|
|
|
return new List<string>();
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:14:41 +03:00
|
|
|
public override IEnumerable<string> GetAnimeEpisodeSearchUrls(List<String> titles, int tvRageId, int absoluteEpisodeNumber)
|
2014-04-22 01:50:43 +03:00
|
|
|
{
|
2014-05-19 22:14:41 +03:00
|
|
|
return RecentFeed.Select(url => String.Format("{0}&q={1}",
|
|
|
|
url,
|
|
|
|
String.Join("|", titles.SelectMany(title => GetTitleSearchStrings(title, absoluteEpisodeNumber)))));
|
2014-04-22 01:50:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public override IEnumerable<string> GetSearchUrls(string query, int offset)
|
|
|
|
{
|
|
|
|
return new List<string>();
|
|
|
|
}
|
2014-05-19 22:14:41 +03:00
|
|
|
|
2014-07-04 11:09:48 +03:00
|
|
|
public override ValidationResult Test()
|
|
|
|
{
|
|
|
|
return new ValidationResult();
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:14:41 +03:00
|
|
|
private IEnumerable<String> GetTitleSearchStrings(string title, int absoluteEpisodeNumber)
|
|
|
|
{
|
|
|
|
var formats = new[] { "{0}%20{1:00}", "{0}%20-%20{1:00}" };
|
|
|
|
|
|
|
|
return formats.Select(s => "\"" + String.Format(s, CleanTitle(title), absoluteEpisodeNumber) + "\"" );
|
|
|
|
}
|
|
|
|
|
|
|
|
private String CleanTitle(String title)
|
|
|
|
{
|
|
|
|
return RemoveCharactersRegex.Replace(title, "");
|
|
|
|
}
|
2014-04-22 01:50:43 +03:00
|
|
|
}
|
|
|
|
}
|