Removed single search method in indexer base.

pull/4/head
kay.one 13 years ago
parent a9c88bb6ab
commit 30497357b4

@ -8,7 +8,6 @@ using System.ServiceModel.Syndication;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Indexer;
@ -76,14 +75,29 @@ namespace NzbDrone.Core.Test.ProviderTests
get { return new[] { "www.google.com" }; }
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
protected override NetworkCredential Credentials
{
get { return null; }
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
throw new NotImplementedException();
}
protected override NetworkCredential Credentials
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
get { return null; }
throw new NotImplementedException();
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
throw new NotImplementedException();
}
public override string Name
@ -115,7 +129,22 @@ namespace NzbDrone.Core.Test.ProviderTests
get { return new[] { "http://rss.nzbmatrix.com/rss.php?cat=TV" }; }
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
throw new NotImplementedException();
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
throw new NotImplementedException();
}
@ -143,7 +172,22 @@ namespace NzbDrone.Core.Test.ProviderTests
get { return new[] { "http://www.google.com" }; }
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
throw new NotImplementedException();
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
throw new NotImplementedException();
}

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace NzbDrone.Core.Model.Search
{
public class SearchModel
{
public string SeriesTitle { get; set; }
public int EpisodeNumber { get; set; }
public int SeasonNumber { get; set; }
public int EpisodePrefix { get; set; }
public DateTime AirDate { get; set; }
public SearchType SearchType { get; set; }
}
}

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace NzbDrone.Core.Model.Search
{
public enum SearchType
{
EpisodeSearch = 0,
DailySearch = 1,
PartialSeasonSearch = 2,
SeasonSearch = 3
}
}

@ -230,8 +230,6 @@
<Compile Include="Model\Quality.cs" />
<Compile Include="Model\SabnzbdCategoryModel.cs" />
<Compile Include="Model\SabnzbdInfoModel.cs" />
<Compile Include="Model\Search\SearchModel.cs" />
<Compile Include="Model\Search\SearchType.cs" />
<Compile Include="Model\Twitter\TwitterAuthorizationModel.cs" />
<Compile Include="Model\UpdatePackage.cs" />
<Compile Include="Model\Xbmc\ActionType.cs" />

@ -161,6 +161,7 @@ namespace NzbDrone.Core.Providers
}
//Add to Result and Return (There will only be one episode to return)
//TODO: This should not add if episode is still null (When doesn't exist and autoadd is false.)
result.Add(episodeInfo);
return result;
}

@ -4,11 +4,9 @@ using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using System.Web;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Indexer
@ -55,12 +53,10 @@ namespace NzbDrone.Core.Providers.Indexer
}
/// <summary>
/// Gets the rss url for specific episode search
/// </summary>
/// <param name="searchModel">SearchModel containing episode information</param>
/// <returns></returns>
protected abstract IList<String> GetSearchUrls(SearchModel searchModel);
protected abstract IList<String> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);
protected abstract IList<String> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date);
protected abstract IList<String> GetSeasonSearchUrls(string seriesTitle, int seasonNumber);
protected abstract IList<String> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard);
/// <summary>
/// This method can be overwritten to provide indexer specific info parsing
@ -104,14 +100,7 @@ namespace NzbDrone.Core.Providers.Indexer
var result = new List<EpisodeParseResult>();
var searchModel = new SearchModel
{
SeriesTitle = GetQueryTitle(seriesTitle),
SeasonNumber = seasonNumber,
SearchType = SearchType.SeasonSearch
};
var searchUrls = GetSearchUrls(searchModel);
var searchUrls = GetSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber);
foreach (var url in searchUrls)
{
@ -130,15 +119,7 @@ namespace NzbDrone.Core.Providers.Indexer
var result = new List<EpisodeParseResult>();
var searchModel = new SearchModel
{
SeriesTitle = GetQueryTitle(seriesTitle),
SeasonNumber = seasonNumber,
EpisodePrefix = episodePrefix,
SearchType = SearchType.PartialSeasonSearch
};
var searchUrls = GetSearchUrls(searchModel);
var searchUrls = GetPartialSeasonSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodePrefix);
foreach (var url in searchUrls)
{
@ -157,15 +138,7 @@ namespace NzbDrone.Core.Providers.Indexer
var result = new List<EpisodeParseResult>();
var searchModel = new SearchModel
{
SeriesTitle = GetQueryTitle(seriesTitle),
SeasonNumber = seasonNumber,
EpisodeNumber = episodeNumber,
SearchType = SearchType.EpisodeSearch
};
var searchUrls = GetSearchUrls(searchModel);
var searchUrls = GetEpisodeSearchUrls(GetQueryTitle(seriesTitle), seasonNumber, episodeNumber);
foreach (var url in searchUrls)
{
@ -185,14 +158,7 @@ namespace NzbDrone.Core.Providers.Indexer
var result = new List<EpisodeParseResult>();
var searchModel = new SearchModel
{
SeriesTitle = GetQueryTitle(seriesTitle),
AirDate = airDate,
SearchType = SearchType.DailySearch
};
var searchUrls = GetSearchUrls(searchModel);
var searchUrls = GetDailyEpisodeSearchUrls(GetQueryTitle(seriesTitle), airDate);
foreach (var url in searchUrls)
{

@ -5,7 +5,6 @@ using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Indexer
@ -18,7 +17,7 @@ namespace NzbDrone.Core.Providers.Indexer
{
}
private const string UrlParams = "feed=rss&hauth=1&ps_rb_language=4096";
private const string URL_PARAMS = "feed=rss&hauth=1&ps_rb_language=4096";
protected override string[] Urls
{
@ -26,7 +25,7 @@ namespace NzbDrone.Core.Providers.Indexer
{
return new[]
{
"http://www.newzbin.com/browse/category/p/tv?" + UrlParams
"http://www.newzbin.com/browse/category/p/tv?" + URL_PARAMS
};
}
}
@ -39,51 +38,46 @@ namespace NzbDrone.Core.Providers.Indexer
get { return new NetworkCredential(_configProvider.NewzbinUsername, _configProvider.NewzbinPassword); }
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
{
if (searchModel.SearchType == SearchType.EpisodeSearch)
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
return new List<string>
{
String.Format(
@"http://www.newzbin.com/search/query/?q={0}+{1}x{2:00}&fpn=p&searchaction=Go&category=8&{3}",
searchModel.SeriesTitle, searchModel.SeasonNumber,
searchModel.EpisodeNumber, UrlParams)
seriesTitle, seasonNumber,episodeNumber, URL_PARAMS)
};
}
if (searchModel.SearchType == SearchType.SeasonSearch)
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
return new List<string>
{
String.Format(
@"http://www.newzbin.com/search/query/?q={0}+Season+{1}&fpn=p&searchaction=Go&category=8&{2}",
searchModel.SeriesTitle, searchModel.SeasonNumber, UrlParams)
seriesTitle, seasonNumber, URL_PARAMS)
};
}
if (searchModel.SearchType == SearchType.PartialSeasonSearch)
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
return new List<string>
{
String.Format(
@"http://www.newzbin.com/search/query/?q={0}+{1}x{2}&fpn=p&searchaction=Go&category=8&{3}",
searchModel.SeriesTitle, searchModel.SeasonNumber, searchModel.EpisodePrefix, UrlParams)
@"http://www.newzbin.com/search/query/?q={0}+{1:yyyy-MM-dd}&fpn=p&searchaction=Go&category=8&{2}",
seriesTitle, date, URL_PARAMS)
};
}
if (searchModel.SearchType == SearchType.DailySearch)
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
return new List<string>
{
String.Format(
@"http://www.newzbin.com/search/query/?q={0}+{1:yyyy-MM-dd}&fpn=p&searchaction=Go&category=8&{2}",
searchModel.SeriesTitle, searchModel.AirDate, UrlParams)
@"http://www.newzbin.com/search/query/?q={0}+{1}x{2}&fpn=p&searchaction=Go&category=8&{3}",
seriesTitle, seasonNumber, episodeWildcard, URL_PARAMS)
};
}
return new List<string>();
}
public override string Name
{

@ -4,7 +4,6 @@ using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Indexer
@ -25,44 +24,51 @@ namespace NzbDrone.Core.Providers.Indexer
get { return GetUrls(); }
}
public override string Name
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
get { return "Newznab"; }
}
var searchUrls = new List<string>();
protected override string NzbDownloadUrl(SyndicationItem item)
foreach (var url in Urls)
{
return item.Id;
searchUrls.Add(String.Format("{0}&limit=100&q={1}&season{2}&ep{3}", url, seriesTitle, seasonNumber, episodeNumber));
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
return searchUrls;
}
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
var searchUrls = new List<String>();
var searchUrls = new List<string>();
foreach (var url in Urls)
{
if (searchModel.SearchType == SearchType.EpisodeSearch)
{
searchUrls.Add(String.Format("{0}&limit=100&q={1}&season{2}&ep{3}", url,
searchModel.SeriesTitle, searchModel.SeasonNumber, searchModel.EpisodeNumber));
searchUrls.Add(String.Format("{0}&limit=100&q={1}+{2:yyyy MM dd}", url, seriesTitle, date));
}
return searchUrls;
}
if (searchModel.SearchType == SearchType.SeasonSearch)
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
searchUrls.Add(String.Format("{0}&limit=100&q={1}&season={2}", url, searchModel.SeriesTitle, searchModel.SeasonNumber));
//searchUrls.Add(String.Format("{0}&limit=100&q={1}+Season", url, searchModel.SeriesTitle));
return new List<string>();
}
if (searchModel.SearchType == SearchType.DailySearch)
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
searchUrls.Add(String.Format("{0}&limit=100&q={1}+{2:yyyy MM dd}", url, searchModel.SeriesTitle,
searchModel.AirDate));
return new List<string>();
}
public override string Name
{
get { return "Newznab"; }
}
return searchUrls;
protected override string NzbDownloadUrl(SyndicationItem item)
{
return item.Id;
}
protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult)
{
if (currentResult != null)

@ -4,7 +4,6 @@ using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Indexer
@ -12,7 +11,8 @@ namespace NzbDrone.Core.Providers.Indexer
public class NzbMatrix : IndexerBase
{
[Inject]
public NzbMatrix(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
public NzbMatrix(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
{
}
@ -30,51 +30,66 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
public override string Name
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
get { return "NzbMatrix"; }
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&term={1}+s{2:00}e{3:00}", url, seriesTitle, seasonNumber, episodeNumber));
}
return searchUrls;
}
protected override string NzbDownloadUrl(SyndicationItem item)
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
return item.Links[0].Uri.ToString();
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&term={1}+{2:yyyy MM dd}", url, seriesTitle, date));
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
return searchUrls;
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
var searchUrls = new List<String>();
foreach (var url in Urls)
{
if (searchModel.SearchType == SearchType.EpisodeSearch)
{
searchUrls.Add(String.Format("{0}&term={1}+s{2:00}e{3:00}", url, searchModel.SeriesTitle,
searchModel.SeasonNumber, searchModel.EpisodeNumber));
searchUrls.Add(String.Format("{0}&term={1}+Season", url, seriesTitle));
searchUrls.Add(String.Format("{0}&term={1}+S{2:00}", url, seriesTitle, seasonNumber));
}
if (searchModel.SearchType == SearchType.PartialSeasonSearch)
{
searchUrls.Add(String.Format("{0}&term={1}+S{2:00}E{3}",
url, searchModel.SeriesTitle, searchModel.SeasonNumber, searchModel.EpisodePrefix));
return searchUrls;
}
if (searchModel.SearchType == SearchType.SeasonSearch)
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
searchUrls.Add(String.Format("{0}&term={1}+Season", url, searchModel.SeriesTitle));
searchUrls.Add(String.Format("{0}&term={1}+S{2:00}", url, searchModel.SeriesTitle, searchModel.SeasonNumber));
}
var searchUrls = new List<String>();
if (searchModel.SearchType == SearchType.DailySearch)
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&term={1}+{2:yyyy MM dd}", url, searchModel.SeriesTitle,
searchModel.AirDate));
}
searchUrls.Add(String.Format("{0}&term={1}+S{2:00}E{3}", url, seriesTitle, seasonNumber, episodeWildcard));
}
return searchUrls;
}
public override string Name
{
get { return "NzbMatrix"; }
}
protected override string NzbDownloadUrl(SyndicationItem item)
{
return item.Links[0].Uri.ToString();
}
protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult)
{
if (currentResult != null)

@ -4,7 +4,6 @@ using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Indexer
@ -23,54 +22,71 @@ namespace NzbDrone.Core.Providers.Indexer
{
return new[]
{
string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}&num=50&dl=1", _configProvider.NzbsOrgUId, _configProvider.NzbsOrgHash)
string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}&num=50&dl=1",
_configProvider.NzbsOrgUId, _configProvider.NzbsOrgHash)
};
}
}
public override string Name
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
get { return "Nzbs.org"; }
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&action=search&q={1}+s{2:00}e{3:00}", url, seriesTitle, seasonNumber, episodeNumber));
}
return searchUrls;
}
protected override string NzbDownloadUrl(SyndicationItem item)
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
return item.Id;
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&action=search&q={1}+{2:yyyy.MM.dd}", url, seriesTitle, date));
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
return searchUrls;
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
var searchUrls = new List<String>();
foreach (var url in Urls)
{
if (searchModel.SearchType == SearchType.EpisodeSearch)
{
searchUrls.Add(String.Format("{0}&action=search&q={1}+s{2:00}e{3:00}", url,
searchModel.SeriesTitle, searchModel.SeasonNumber, searchModel.EpisodeNumber));
searchUrls.Add(String.Format("{0}&action=search&q={1}+Season", url, seriesTitle));
searchUrls.Add(String.Format("{0}&action=search&q={1}+S{2:00}", url, seriesTitle, seasonNumber));
}
if (searchModel.SearchType == SearchType.PartialSeasonSearch)
return searchUrls;
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&action=search&q={1}+S{2:00}E{3}",
url, searchModel.SeriesTitle, searchModel.SeasonNumber, searchModel.EpisodePrefix));
url, seriesTitle, seasonNumber, episodeWildcard));
}
if (searchModel.SearchType == SearchType.SeasonSearch)
{
searchUrls.Add(String.Format("{0}&action=search&q={1}+Season", url, searchModel.SeriesTitle));
searchUrls.Add(String.Format("{0}&action=search&q={1}+S{2:00}", url, searchModel.SeriesTitle, searchModel.SeasonNumber));
return searchUrls;
}
if (searchModel.SearchType == SearchType.DailySearch)
public override string Name
{
searchUrls.Add(String.Format("{0}&action=search&q={1}+{2:yyyy.MM.dd}", url, searchModel.SeriesTitle,
searchModel.AirDate));
}
get { return "Nzbs.org"; }
}
return searchUrls;
protected override string NzbDownloadUrl(SyndicationItem item)
{
return item.Id;
}
protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult)

@ -1,9 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Indexer
@ -39,7 +39,23 @@ namespace NzbDrone.Core.Providers.Indexer
return item.Links[0].Uri.ToString();
}
protected override IList<string> GetSearchUrls(SearchModel searchModel)
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
return new List<string>();
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
return new List<string>();
}
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
return new List<string>();
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
return new List<string>();
}

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers.Jobs

@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Model.Search;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers.Jobs
{

@ -48,7 +48,7 @@
.searchImage:hover, .renameImage:hover, .ignoreEpisode:hover, .ignoreEpisodesMaster:hover
{
background-color: #065EFE;
}
#banner-container

Loading…
Cancel
Save