Exemplo n.º 1
0
        public override List <AppIndexerMap> GetIndexerMappings()
        {
            var indexers = _sonarrV3Proxy.GetIndexers(Settings)
                           .Where(i => i.Implementation == "Newznab" || i.Implementation == "Torznab");

            var mappings = new List <AppIndexerMap>();

            foreach (var indexer in indexers)
            {
                if ((string)indexer.Fields.FirstOrDefault(x => x.Name == "apiKey")?.Value == _configFileProvider.ApiKey)
                {
                    var match = AppIndexerRegex.Match((string)indexer.Fields.FirstOrDefault(x => x.Name == "baseUrl").Value);

                    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 = indexerId
                        });
                    }
                }
            }

            return(mappings);
        }
Exemplo n.º 2
0
        public override List <AppIndexerMap> GetIndexerMappings()
        {
            var indexers = _lazyLibrarianV1Proxy.GetIndexers(Settings);

            var mappings = new List <AppIndexerMap>();

            foreach (var indexer in indexers)
            {
                if (indexer.Apikey == _configFileProvider.ApiKey)
                {
                    var match = AppIndexerRegex.Match(indexer.Host);

                    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 {
                            RemoteIndexerName = $"{indexer.Type},{indexer.Name}", IndexerId = indexerId
                        });
                    }
                }
            }

            return(mappings);
        }