@ -74,7 +74,7 @@ namespace NzbDrone.Core.Applications.Whisparr
if ( match . Groups [ "indexer" ] . Success & & int . TryParse ( match . Groups [ "indexer" ] . Value , out var indexerId ) )
{
// Add parsed mapping if it's mapped to a Indexer in this Prowlarr instance
mappings . Add ( new AppIndexerMap { RemoteIndexerId = indexer . Id, IndexerId = indexer Id } ) ;
mappings . Add ( new AppIndexerMap { IndexerId = indexerId , RemoteIndexerId = indexer . Id } ) ;
}
}
}
@ -84,15 +84,19 @@ namespace NzbDrone.Core.Applications.Whisparr
public override void AddIndexer ( IndexerDefinition indexer )
{
if ( indexer . Capabilities . Categories . SupportedCategories ( Settings . SyncCategories . ToArray ( ) ) . An y( ) )
if ( indexer . Capabilities . Categories . SupportedCategories ( Settings . SyncCategories . ToArray ( ) ) . Empt y( ) )
{
var radarrIndexer = BuildWhisparrIndexer ( indexer , indexer . Protocol ) ;
_logger . Trace ( "Skipping add for indexer {0} [{1}] due to no app Sync Categories supported by the indexer" , indexer . Name , indexer . Id ) ;
var remoteIndexer = _whisparrV3Proxy . AddIndexer ( radarrIndexer , Settings ) ;
_appIndexerMapService . Insert ( new AppIndexerMap { AppId = Definition . Id , IndexerId = indexer . Id , RemoteIndexerId = remoteIndexer . Id } ) ;
return ;
}
_logger . Trace ( "Skipping add for indexer {0} [{1}] due to no app Sync Categories supported by the indexer" , indexer . Name , indexer . Id ) ;
_logger . Trace ( "Adding indexer {0} [{1}]" , indexer . Name , indexer . Id ) ;
var whisparrIndexer = BuildWhisparrIndexer ( indexer , indexer . Protocol ) ;
var remoteIndexer = _whisparrV3Proxy . AddIndexer ( whisparrIndexer , Settings ) ;
_appIndexerMapService . Insert ( new AppIndexerMap { AppId = Definition . Id , IndexerId = indexer . Id , RemoteIndexerId = remoteIndexer . Id } ) ;
}
public override void RemoveIndexer ( int indexerId )
@ -128,7 +132,11 @@ namespace NzbDrone.Core.Applications.Whisparr
{
if ( indexer . Capabilities . Categories . SupportedCategories ( Settings . SyncCategories . ToArray ( ) ) . Any ( ) )
{
whisparrIndexer . Fields . AddRange ( remoteIndexer . Fields . Where ( f = > ! whisparrIndexer . Fields . Any ( s = > s . Name = = f . Name ) ) ) ;
// Retain user fields not-affiliated with Prowlarr
whisparrIndexer . Fields . AddRange ( remoteIndexer . Fields . Where ( f = > whisparrIndexer . Fields . All ( s = > s . Name ! = f . Name ) ) ) ;
// Retain user tags not-affiliated with Prowlarr
whisparrIndexer . Tags . UnionWith ( remoteIndexer . Tags ) ;
// Update the indexer if it still has categories that match
_whisparrV3Proxy . UpdateIndexer ( whisparrIndexer , Settings ) ;
@ -147,14 +155,14 @@ namespace NzbDrone.Core.Applications.Whisparr
if ( indexer . Capabilities . Categories . SupportedCategories ( Settings . SyncCategories . ToArray ( ) ) . Any ( ) )
{
_logger . Debug ( "Remote indexer not found, re-adding {0} to Whisparr", indexer . Name ) ;
_logger . Debug ( "Remote indexer not found, re-adding {0} [{1}] to Whisparr", indexer . Name , indexer . Id ) ;
whisparrIndexer . Id = 0 ;
var newRemoteIndexer = _whisparrV3Proxy . AddIndexer ( whisparrIndexer , Settings ) ;
_appIndexerMapService . Insert ( new AppIndexerMap { AppId = Definition . Id , IndexerId = indexer . Id , RemoteIndexerId = newRemoteIndexer . Id } ) ;
}
else
{
_logger . Debug ( "Remote indexer not found for {0} , skipping re-add to Rad arr due to indexer capabilities", indexer . Name ) ;
_logger . Debug ( "Remote indexer not found for {0} [{1}], skipping re-add to Whisp arr due to indexer capabilities", indexer . Name , indexer . Id ) ;
}
}
}
@ -163,10 +171,10 @@ namespace NzbDrone.Core.Applications.Whisparr
{
var cacheKey = $"{Settings.BaseUrl}" ;
var schemas = _schemaCache . Get ( cacheKey , ( ) = > _whisparrV3Proxy . GetIndexerSchema ( Settings ) , TimeSpan . FromDays ( 7 ) ) ;
var syncFields = new string [ ] { "baseUrl" , "apiPath" , "apiKey" , "categories" , "minimumSeeders" , "seedCriteria.seedRatio" , "seedCriteria.seedTime" } ;
var syncFields = new [ ] { "baseUrl" , "apiPath" , "apiKey" , "categories" , "minimumSeeders" , "seedCriteria.seedRatio" , "seedCriteria.seedTime" } ;
var newznab = schemas . Where ( i = > i . Implementation = = "Newznab" ) . First ( ) ;
var torznab = schemas . Where ( i = > i . Implementation = = "Torznab" ) . First ( ) ;
var newznab = schemas . First ( i = > i . Implementation = = "Newznab" ) ;
var torznab = schemas . First ( i = > i . Implementation = = "Torznab" ) ;
var schema = protocol = = DownloadProtocol . Usenet ? newznab : torznab ;
@ -180,7 +188,8 @@ namespace NzbDrone.Core.Applications.Whisparr
Priority = indexer . Priority ,
Implementation = indexer . Protocol = = DownloadProtocol . Usenet ? "Newznab" : "Torznab" ,
ConfigContract = schema . ConfigContract ,
Fields = new List < WhisparrField > ( )
Fields = new List < WhisparrField > ( ) ,
Tags = new HashSet < int > ( )
} ;
whisparrIndexer . Fields . AddRange ( schema . Fields . Where ( x = > syncFields . Contains ( x . Name ) ) ) ;