mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-24 06:50:43 +00:00
Adds Newznab Album Search Support
Adds Newznab Album Search Support
This commit is contained in:
parent
f40918ddb8
commit
f0b68afccd
4 changed files with 52 additions and 1 deletions
|
@ -106,6 +106,9 @@ protected virtual ValidationFailure TestCapabilities()
|
|||
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 @@ public class NewznabCapabilities
|
|||
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 @@ public NewznabCapabilities()
|
|||
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 @@ private NewznabCapabilities ParseCapabilities(HttpResponse response)
|
|||
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 @@ private bool SupportsTvSearch
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearc
|
|||
|
||||
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 @@ private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, int maxP
|
|||
}
|
||||
}
|
||||
|
||||
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…
Reference in a new issue