private IndexerBase <TestIndexerSettings> WithIndexer(bool paging, int resultCount) { var results = Builder <ReleaseInfo> .CreateListOfSize(resultCount) .Build(); var indexer = Mocker.GetMock <IndexerBase <TestIndexerSettings> >(); indexer.Setup(s => s.Parser.Process(It.IsAny <String>(), It.IsAny <String>())) .Returns(results); indexer.Setup(s => s.GetSeasonSearchUrls(It.IsAny <String>(), It.IsAny <Int32>(), It.IsAny <Int32>(), It.IsAny <Int32>())) .Returns(new List <string> { "http://www.nzbdrone.com" }); indexer.SetupGet(s => s.SupportsPaging).Returns(paging); var definition = new IndexerDefinition(); definition.Name = "Test"; indexer.SetupGet(s => s.Definition) .Returns(definition); return(indexer.Object); }
private void WithIndexer(bool paging, int resultCount) { var definition = new IndexerDefinition(); definition.Name = "Test"; Subject.Definition = definition; Subject._supportedPageSize = paging ? 100 : 0; var requestGenerator = Mocker.GetMock <IIndexerRequestGenerator>(); Subject._requestGenerator = requestGenerator.Object; var requests = Builder <IndexerRequest> .CreateListOfSize(paging? 100 : 1) .All() .WithConstructor(() => new IndexerRequest("http://my.feed.local/", HttpAccept.Rss)) .With(v => v.HttpRequest.Method = HttpMethod.GET) .Build(); requestGenerator.Setup(s => s.GetSearchRequests(It.IsAny <SeasonSearchCriteria>())) .Returns(new List <IEnumerable <IndexerRequest> > { requests }); var parser = Mocker.GetMock <IParseIndexerResponse>(); Subject._parser = parser.Object; var results = Builder <ReleaseInfo> .CreateListOfSize(resultCount) .Build(); parser.Setup(s => s.ParseResponse(It.IsAny <IndexerResponse>())) .Returns(results); }
public void Setup() { _movie = Builder <Movie> .CreateNew().With(s => s.Id = 1).Build(); _remoteMovie = new RemoteMovie { Movie = _movie, Release = new TorrentInfo { IndexerId = 1, Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp", Seeders = 0, //IndexerSettings = new TorrentRssIndexerSettings {MinimumSeeders = 5} } }; _indexerDefinition = new IndexerDefinition { Settings = new TorrentRssIndexerSettings { MinimumSeeders = 5 } }; Mocker.GetMock <IIndexerFactory>() .Setup(v => v.Get(1)) .Returns(_indexerDefinition); }
private SonarrIndexer BuildSonarrIndexer(IndexerDefinition indexer, DownloadProtocol protocol, int id = 0) { var cacheKey = $"{Settings.BaseUrl}"; var schemas = _schemaCache.Get(cacheKey, () => _sonarrV3Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); var newznab = schemas.Where(i => i.Implementation == "Newznab").First(); var torznab = schemas.Where(i => i.Implementation == "Torznab").First(); var schema = protocol == DownloadProtocol.Usenet ? newznab : torznab; var sonarrIndexer = new SonarrIndexer { Id = id, Name = $"{indexer.Name} (Prowlarr)", EnableRss = indexer.Enable && indexer.AppProfile.Value.EnableRss, EnableAutomaticSearch = indexer.Enable && indexer.AppProfile.Value.EnableAutomaticSearch, EnableInteractiveSearch = indexer.Enable && indexer.AppProfile.Value.EnableInteractiveSearch, Priority = indexer.Priority, Implementation = indexer.Protocol == DownloadProtocol.Usenet ? "Newznab" : "Torznab", ConfigContract = schema.ConfigContract, Fields = schema.Fields, }; sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "baseUrl").Value = $"{Settings.ProwlarrUrl.TrimEnd('/')}/{indexer.Id}/"; sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiPath").Value = "/api"; sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey; sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "categories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray())); sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "animeCategories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray())); return(sonarrIndexer); }
public void Setup() { _artist = Builder <Artist> .CreateNew().With(s => s.Id = 1).Build(); _remoteAlbum = new RemoteAlbum { Artist = _artist, Release = new TorrentInfo { IndexerId = 1, Title = "Artist - Album [FLAC-RlsGrp]", Seeders = 0 } }; _indexerDefinition = new IndexerDefinition { Settings = new TorrentRssIndexerSettings { MinimumSeeders = 5 } }; Mocker.GetMock <IIndexerFactory>() .Setup(v => v.Get(1)) .Returns(_indexerDefinition); }
public void Setup() { _author = Builder <Author> .CreateNew().With(s => s.Id = 1).Build(); _book1 = Builder <Book> .CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build(); _book2 = Builder <Book> .CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build(); _remoteBook = new RemoteBook { Author = _author, Books = new List <Book> { _book1 }, Release = new TorrentInfo { IndexerId = 1, Title = "Author - Book [FLAC-RlsGrp]", PublishDate = DateTime.Today } }; _indexerDefinition = new IndexerDefinition { Settings = new TorrentRssIndexerSettings { EarlyReleaseLimit = 5 } }; Mocker.GetMock <IIndexerFactory>() .Setup(v => v.Get(1)) .Returns(_indexerDefinition); }
public void Setup() { _author = Builder <Author> .CreateNew().With(s => s.Id = 1).Build(); _remoteBook = new RemoteBook { Author = _author, Release = new TorrentInfo { IndexerId = 1, Title = "Author - Book [FLAC-RlsGrp]", Seeders = 0 } }; _indexerDefinition = new IndexerDefinition { Settings = new TorrentRssIndexerSettings { MinimumSeeders = 5 } }; Mocker.GetMock <IIndexerFactory>() .Setup(v => v.Get(1)) .Returns(_indexerDefinition); }
public void Setup() { _fakeIndexerDefinition = new IndexerDefinition { Tags = new HashSet <int>() }; Mocker .GetMock <IIndexerFactory>() .Setup(m => m.Get(It.IsAny <int>())) .Throws(new ModelNotFoundException(typeof(IndexerDefinition), -1)); Mocker .GetMock <IIndexerFactory>() .Setup(m => m.Get(1)) .Returns(_fakeIndexerDefinition); _specification = Mocker.Resolve <IndexerTagSpecification>(); _fakeMovie = Builder <Movie> .CreateNew() .With(c => c.Monitored = true) .With(c => c.Tags = new HashSet <int>()) .Build(); _fakeRelease = new ReleaseInfo { IndexerId = 1 }; _parseResultMulti = new RemoteMovie { Movie = _fakeMovie, Release = _fakeRelease }; }
public override ValidationResult Test() { var failures = new List <ValidationFailure>(); var testIndexer = new IndexerDefinition { Id = 0, Name = "Test", Protocol = DownloadProtocol.Usenet, Capabilities = new IndexerCapabilities() }; foreach (var cat in NewznabStandardCategory.AllCats) { testIndexer.Capabilities.Categories.AddCategoryMapping(1, cat); } try { failures.AddIfNotNull(_sonarrV3Proxy.TestConnection(BuildSonarrIndexer(testIndexer, DownloadProtocol.Usenet), Settings)); } catch (WebException ex) { _logger.Error(ex, "Unable to send test message"); failures.AddIfNotNull(new ValidationFailure("BaseUrl", "Unable to complete application test, cannot connect to Sonarr")); } return(new ValidationResult(failures)); }
public void Setup() { _artist = Builder <Artist> .CreateNew().With(s => s.Id = 1).Build(); _album1 = Builder <Album> .CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build(); _album2 = Builder <Album> .CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build(); _remoteAlbum = new RemoteAlbum { Artist = _artist, Albums = new List <Album> { _album1 }, Release = new TorrentInfo { IndexerId = 1, Title = "Artist - Album [FLAC-RlsGrp]", PublishDate = DateTime.Today } }; _indexerDefinition = new IndexerDefinition { Settings = new TorrentRssIndexerSettings { EarlyReleaseLimit = 5 } }; Mocker.GetMock <IIndexerFactory>() .Setup(v => v.Get(1)) .Returns(_indexerDefinition); }
protected void Init(string DefinitionString) { var deserializer = new DeserializerBuilder() .WithNamingConvention(new CamelCaseNamingConvention()) .IgnoreUnmatchedProperties() .Build(); Definition = deserializer.Deserialize <IndexerDefinition>(DefinitionString); // Add default data if necessary if (Definition.Settings == null) { Definition.Settings = new List <settingsField>(); } if (Definition.Settings.Count == 0) { Definition.Settings.Add(new settingsField { Name = "username", Label = "Username", Type = "text" }); Definition.Settings.Add(new settingsField { Name = "password", Label = "Password", Type = "password" }); } // init missing mandatory attributes DisplayName = Definition.Name; DisplayDescription = Definition.Description; SiteLink = Definition.Links[0]; // TODO: implement alternative links if (!SiteLink.EndsWith("/")) { SiteLink += "/"; } TorznabCaps = TorznabUtil.CreateDefaultTorznabTVCaps(); // TODO implement caps // init config Data configData = new ConfigurationData(); foreach (var Setting in Definition.Settings) { configData.AddDynamic(Setting.Name, new StringItem { Name = Setting.Label }); } foreach (var Category in Definition.Caps.Categories) { var cat = TorznabCatType.GetCatByName(Category.Value); if (cat == null) { logger.Error(string.Format("CardigannIndexer ({0}): Can't find a category for {1}", ID, Category.Value)); continue; } AddCategoryMapping(Category.Key, TorznabCatType.GetCatByName(Category.Value)); } }
public override void AddIndexer(IndexerDefinition indexer) { if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any() || indexer.Capabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray()).Any()) { var sonarrIndexer = BuildSonarrIndexer(indexer, indexer.Protocol); var remoteIndexer = _sonarrV3Proxy.AddIndexer(sonarrIndexer, Settings); _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerId = remoteIndexer.Id }); } }
public override void AddIndexer(IndexerDefinition indexer) { if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { var lazyLibrarianIndexer = BuildLazyLibrarianIndexer(indexer, indexer.Protocol); var remoteIndexer = _lazyLibrarianV1Proxy.AddIndexer(lazyLibrarianIndexer, Settings); _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerName = $"{remoteIndexer.Type},{remoteIndexer.Name}" }); } }
public virtual void SaveSettings(IndexerDefinition definitions) { if (definitions.Id == 0) { Logger.Debug("Adding Indexer definitions for {0}", definitions.Name); _database.Insert(definitions); } else { Logger.Debug("Updating Indexer definitions for {0}", definitions.Name); _database.Update(definitions); } }
public override void UpdateIndexer(IndexerDefinition indexer) { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); var sonarrIndexer = BuildSonarrIndexer(indexer, indexer.Protocol, indexerMapping?.RemoteIndexerId ?? 0); var remoteIndexer = _sonarrV3Proxy.GetIndexer(indexerMapping.RemoteIndexerId, Settings); if (remoteIndexer != null) { _logger.Debug("Remote indexer found, syncing with current settings"); if (!sonarrIndexer.Equals(remoteIndexer)) { if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any() || indexer.Capabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray()).Any()) { // Update the indexer if it still has categories that match _sonarrV3Proxy.UpdateIndexer(sonarrIndexer, Settings); } else { // Else remove it, it no longer should be used _sonarrV3Proxy.RemoveIndexer(remoteIndexer.Id, Settings); _appIndexerMapService.Delete(indexerMapping.Id); } } } else { _appIndexerMapService.Delete(indexerMapping.Id); if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any() || indexer.Capabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray()).Any()) { _logger.Debug("Remote indexer not found, re-adding {0} to Sonarr", indexer.Name); sonarrIndexer.Id = 0; var newRemoteIndexer = _sonarrV3Proxy.AddIndexer(sonarrIndexer, 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 Sonarr due to indexer capabilities", indexer.Name); } } }
public void Setup() { _fakeIndexerDefinition = new IndexerDefinition { Tags = new HashSet <int>() }; Mocker .GetMock <IIndexerFactory>() .Setup(m => m.Get(It.IsAny <int>())) .Throws(new ModelNotFoundException(typeof(IndexerDefinition), -1)); Mocker .GetMock <IIndexerFactory>() .Setup(m => m.Get(1)) .Returns(_fakeIndexerDefinition); _specification = Mocker.Resolve <IndexerTagSpecification>(); _fakeSeries = Builder <Series> .CreateNew() .With(c => c.Monitored = true) .With(c => c.Tags = new HashSet <int>()) .Build(); _fakeRelease = new ReleaseInfo { IndexerId = 1 }; _firstEpisode = new Episode { Monitored = true }; _secondEpisode = new Episode { Monitored = true }; var doubleEpisodeList = new List <Episode> { _firstEpisode, _secondEpisode }; _parseResultMulti = new RemoteEpisode { Series = _fakeSeries, Episodes = doubleEpisodeList, Release = _fakeRelease }; }
private LazyLibrarianIndexer BuildLazyLibrarianIndexer(IndexerDefinition indexer, DownloadProtocol protocol, string originalName = null) { var schema = protocol == DownloadProtocol.Usenet ? LazyLibrarianProviderType.Newznab : LazyLibrarianProviderType.Torznab; var lazyLibrarianIndexer = new LazyLibrarianIndexer { Name = originalName ?? $"{indexer.Name} (Prowlarr)", Altername = $"{indexer.Name} (Prowlarr)", Host = $"{Settings.ProwlarrUrl.TrimEnd('/')}/{indexer.Id}/api", Apikey = _configFileProvider.ApiKey, Categories = string.Join(",", indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray())), Enabled = indexer.Enable, Type = schema, }; return(lazyLibrarianIndexer); }
private void GivenIndexer(string baseUrl, string apiPath) { var torznabSettings = new TorznabSettings { BaseUrl = baseUrl, ApiPath = apiPath }; _definition = new IndexerDefinition { Name = "Indexer", ConfigContract = "TorznabSettings", Settings = torznabSettings }; _indexers.Add(_definition); }
private ReleaseInfo ReleaseInfoWithLanguages(params Language[] languages) { _indexerDefinition = new IndexerDefinition { Settings = new RarbgSettings { MultiLanguages = languages.ToList().Select(l => (int)l) } }; Mocker.GetMock <IIndexerFactory>() .Setup(v => v.Get(1)) .Returns(_indexerDefinition); return(new ReleaseInfo { IndexerId = 1 }); }
public void SetUp() { _settings = new NewznabSettings() { BaseUrl = "http://indxer.local" }; _definition = new IndexerDefinition() { Id = 5, Name = "Newznab", Settings = new NewznabSettings() { BaseUrl = "http://indexer.local/" } }; _caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml"); }
public override void UpdateIndexer(IndexerDefinition indexer) { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); var indexerProps = indexerMapping.RemoteIndexerName.Split(","); var lazyLibrarianIndexer = BuildLazyLibrarianIndexer(indexer, indexer.Protocol, indexerProps[1]); //Use the old remote id to find the indexer on LazyLibrarian incase the update was from a name change in Prowlarr var remoteIndexer = _lazyLibrarianV1Proxy.GetIndexer(indexerProps[1], lazyLibrarianIndexer.Type, Settings); if (remoteIndexer != null) { _logger.Debug("Remote indexer found, syncing with current settings"); if (!lazyLibrarianIndexer.Equals(remoteIndexer)) { _lazyLibrarianV1Proxy.UpdateIndexer(lazyLibrarianIndexer, Settings); indexerMapping.RemoteIndexerName = $"{lazyLibrarianIndexer.Type},{lazyLibrarianIndexer.Altername}"; _appIndexerMapService.Update(indexerMapping); } } else { _appIndexerMapService.Delete(indexerMapping.Id); if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { _logger.Debug("Remote indexer not found, re-adding {0} to LazyLibrarian", indexer.Name); var newRemoteIndexer = _lazyLibrarianV1Proxy.AddIndexer(lazyLibrarianIndexer, Settings); _appIndexerMapService.Insert(new AppIndexerMap { AppId = Definition.Id, IndexerId = indexer.Id, RemoteIndexerName = $"{newRemoteIndexer.Type},{newRemoteIndexer.Name}" }); } else { _logger.Debug("Remote indexer not found for {0}, skipping re-add to LazyLibrarian due to indexer capabilities", indexer.Name); } } }
public override void UpdateIndexer(IndexerDefinition indexer) { _logger.Debug("Updating indexer {0} [{1}]", indexer.Name, indexer.Id); var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); var lidarrIndexer = BuildLidarrIndexer(indexer, indexer.Protocol, indexerMapping?.RemoteIndexerId ?? 0); var remoteIndexer = _lidarrV1Proxy.GetIndexer(indexerMapping.RemoteIndexerId, Settings); if (remoteIndexer != null) { _logger.Debug("Remote indexer found, syncing with current settings"); if (!lidarrIndexer.Equals(remoteIndexer)) { _lidarrV1Proxy.UpdateIndexer(lidarrIndexer, Settings); } } else { _appIndexerMapService.Delete(indexerMapping.Id); if (indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { _logger.Debug("Remote indexer not found, re-adding {0} to Lidarr", indexer.Name); lidarrIndexer.Id = 0; var newRemoteIndexer = _lidarrV1Proxy.AddIndexer(lidarrIndexer, 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 Lidarr due to indexer capabilities", indexer.Name); } } }
public virtual void InitializeIndexers(IList <IndexerBase> indexers) { Logger.Debug("Initializing indexers. Count {0}", indexers.Count); _indexers = indexers; var currentIndexers = All(); foreach (var feedProvider in indexers) { IndexerBase indexerLocal = feedProvider; if (!currentIndexers.Exists(c => c.IndexProviderType == indexerLocal.GetType().ToString())) { var settings = new IndexerDefinition { Enable = indexerLocal.EnabledByDefault, IndexProviderType = indexerLocal.GetType().ToString(), Name = indexerLocal.Name }; SaveSettings(settings); } } }
public abstract void AddIndexer(IndexerDefinition indexer);
public abstract void UpdateIndexer(IndexerDefinition indexer);
protected void Init(string DefinitionString) { this.DefinitionString = DefinitionString; var deserializer = new DeserializerBuilder() .WithNamingConvention(new CamelCaseNamingConvention()) .IgnoreUnmatchedProperties() .Build(); Definition = deserializer.Deserialize<IndexerDefinition>(DefinitionString); // Add default data if necessary if (Definition.Settings == null) Definition.Settings = new List<settingsField>(); if (Definition.Settings.Count == 0) { Definition.Settings.Add(new settingsField { Name = "username", Label = "Username", Type = "text" }); Definition.Settings.Add(new settingsField { Name = "password", Label = "Password", Type = "password" }); } if (Definition.Encoding == null) Definition.Encoding = "iso-8859-1"; if (Definition.Login != null && Definition.Login.Method == null) Definition.Login.Method = "form"; // init missing mandatory attributes DisplayName = Definition.Name; DisplayDescription = Definition.Description; SiteLink = Definition.Links[0]; // TODO: implement alternative links Encoding = Encoding.GetEncoding(Definition.Encoding); if (!SiteLink.EndsWith("/")) SiteLink += "/"; Language = Definition.Language; TorznabCaps = TorznabUtil.CreateDefaultTorznabTVCaps(); // TODO implement caps // init config Data configData = new ConfigurationData(); foreach (var Setting in Definition.Settings) { configData.AddDynamic(Setting.Name, new StringItem { Name = Setting.Label }); } foreach (var Category in Definition.Caps.Categories) { var cat = TorznabCatType.GetCatByName(Category.Value); if (cat == null) { logger.Error(string.Format("CardigannIndexer ({0}): Can't find a category for {1}", ID, Category.Value)); continue; } AddCategoryMapping(Category.Key, TorznabCatType.GetCatByName(Category.Value)); } }
public void Setup() { _indexer = Builder <IndexerDefinition> .CreateNew() .BuildNew(); }