Adds Newznab Album Search Support

Adds Newznab Album Search Support
pull/18/head
Qstick 8 years ago
parent f40918ddb8
commit f0b68afccd

@ -106,6 +106,9 @@ namespace NzbDrone.Core.Indexers.Newznab
return null;
}
if (capabilities.SupportedAudioSearchParameters != null &&
new[] { "artist", "album" }.All(v => capabilities.SupportedAudioSearchParameters.Contains(v)))
if (capabilities.SupportedTvSearchParameters != null &&
new[] { "q", "tvdbid", "rid" }.Any(v => capabilities.SupportedTvSearchParameters.Contains(v)) &&
new[] { "season", "ep" }.All(v => capabilities.SupportedTvSearchParameters.Contains(v)))

@ -8,6 +8,7 @@ namespace NzbDrone.Core.Indexers.Newznab
public int MaxPageSize { get; set; }
public string[] SupportedSearchParameters { get; set; }
public string[] SupportedTvSearchParameters { get; set; }
public string[] SupportedAudioSearchParameters { get; set; }
public bool SupportsAggregateIdSearch { get; set; }
public List<NewznabCategory> Categories { get; set; }
@ -17,6 +18,7 @@ namespace NzbDrone.Core.Indexers.Newznab
MaxPageSize = 100;
SupportedSearchParameters = new[] { "q" };
SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs.
SupportedAudioSearchParameters = new[] { "q", "artist", "album" };
SupportsAggregateIdSearch = false;
Categories = new List<NewznabCategory>();
}

@ -115,6 +115,18 @@ namespace NzbDrone.Core.Indexers.Newznab
capabilities.SupportedTvSearchParameters = xmlTvSearch.Attribute("supportedParams").Value.Split(',');
capabilities.SupportsAggregateIdSearch = true;
}
var xmlAudioSearch = xmlSearching.Element("audio-search");
if (xmlAudioSearch == null || xmlAudioSearch.Attribute("available").Value != "yes")
{
capabilities.SupportedAudioSearchParameters = null;
}
else if (xmlAudioSearch.Attribute("supportedParams") != null)
{
capabilities.SupportedAudioSearchParameters = xmlAudioSearch.Attribute("supportedParams").Value.Split(',');
//capabilities.SupportsAggregateIdSearch = true;
}
}
var xmlCategories = xmlRoot.Element("categories");

@ -45,6 +45,19 @@ namespace NzbDrone.Core.Indexers.Newznab
}
}
private bool SupportsAudioSearch
{
get
{
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
return capabilities.SupportedAudioSearchParameters != null &&
capabilities.SupportedAudioSearchParameters.Contains("q") &&
capabilities.SupportedAudioSearchParameters.Contains("artist") &&
capabilities.SupportedAudioSearchParameters.Contains("album");
}
}
private bool SupportsTvdbSearch
{
get
@ -182,7 +195,14 @@ namespace NzbDrone.Core.Indexers.Newznab
public IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria)
{
throw new System.NotImplementedException();
var pageableRequests = new IndexerPageableRequestChain();
AddAudioPageableRequests(pageableRequests, MaxPages, Settings.Categories, searchCriteria,
string.Format("&artist={0}&album={1}",
searchCriteria.Artist.Name,
searchCriteria.Album.Title));
return pageableRequests;
}
public IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria)
@ -250,6 +270,20 @@ namespace NzbDrone.Core.Indexers.Newznab
}
}
private void AddAudioPageableRequests(IndexerPageableRequestChain chain, int maxPages, IEnumerable<int> categories, SearchCriteriaBase searchCriteria, string parameters)
{
if (SupportsAudioSearch)
{
chain.AddTier();
chain.Add(GetPagedRequests(MaxPages, Settings.Categories, "music",
string.Format("&q={0}",
parameters)));
}
}
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, IEnumerable<int> categories, string searchType, string parameters)
{
if (categories.Empty())

Loading…
Cancel
Save