protected BaseCachingWebIndexer(string name, string link, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, client, logger, configData, p, caps, downloadBase) { }
// standard constructor used by most indexers public BaseIndexer(string name, string link, string description, IIndexerManagerService manager, IWebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : this(manager, client, logger, p) { if (!link.EndsWith("/")) { throw new Exception("Site link must end with a slash."); } DisplayName = name; DisplayDescription = description; SiteLink = link; this.downloadUrlBase = downloadBase; this.configData = configData; if (caps == null) { caps = TorznabUtil.CreateDefaultTorznabTVCaps(); } TorznabCaps = caps; }
public void TestParseCardigannSearchModes() { var torznabCaps = new TorznabCapabilities(); torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "search", new List <string> { "q" } }, { "tv-search", new List <string> { "q" } }, { "movie-search", new List <string> { "q" } }, { "music-search", new List <string> { "q" } }, { "book-search", new List <string> { "q" } } }); Assert.True(torznabCaps.SearchAvailable); Assert.True(torznabCaps.TvSearchAvailable); Assert.True(torznabCaps.MovieSearchAvailable); Assert.True(torznabCaps.MusicSearchAvailable); Assert.True(torznabCaps.BookSearchAvailable); torznabCaps = new TorznabCapabilities(); try { torznabCaps.ParseCardigannSearchModes(null); // null search modes Assert.Fail(); } catch (Exception) { // ignored } torznabCaps = new TorznabCapabilities(); try { torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> >()); // empty search modes Assert.Fail(); } catch (Exception) { // ignored } torznabCaps = new TorznabCapabilities(); try { torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "bad", new List <string> { "q" } } // bad search mode }); Assert.Fail(); } catch (Exception) { // ignored } torznabCaps = new TorznabCapabilities(); try { torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "search", new List <string> { "bad" } } // search mode with bad parameters }); Assert.Fail(); } catch (Exception) { // ignored } }
protected BaseWebIndexer(string name, string link, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, logger, configData, p) { this.webclient = client; this.downloadUrlBase = downloadBase; if (caps == null) { caps = TorznabUtil.CreateDefaultTorznabTVCaps(); } TorznabCaps = caps; }
public void TestTorznabCaps() { // test header var torznabCaps = new TorznabCapabilities(); var xDocument = torznabCaps.GetXDocument(); Assert.AreEqual("caps", xDocument.Root?.Name.LocalName); Assert.AreEqual("Jackett", xDocument.Root?.Element("server")?.Attribute("title")?.Value); Assert.True(xDocument.Root?.Element("searching")?.HasElements); Assert.False(xDocument.Root?.Element("categories")?.HasElements); // test all features disabled torznabCaps = new TorznabCapabilities { SearchAvailable = false }; xDocument = torznabCaps.GetXDocument(); var xDoumentSearching = xDocument.Root?.Element("searching"); Assert.AreEqual("no", xDoumentSearching?.Element("search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("tv-search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("tv-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("movie-search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("movie-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("music-search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("music-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("audio-search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("audio-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("book-search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("book-search")?.Attribute("supportedParams")?.Value); // test all features enabled torznabCaps = new TorznabCapabilities { SearchAvailable = true, TvSearchParams = new List <TvSearchParam> { TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId, TvSearchParam.TvdbId, TvSearchParam.RId }, MovieSearchParams = new List <MovieSearchParam> { MovieSearchParam.Q, MovieSearchParam.ImdbId, MovieSearchParam.TmdbId }, MusicSearchParams = new List <MusicSearchParam> { MusicSearchParam.Q, MusicSearchParam.Album, MusicSearchParam.Artist, MusicSearchParam.Label, MusicSearchParam.Year }, BookSearchParams = new List <BookSearchParam> { BookSearchParam.Q, BookSearchParam.Title, BookSearchParam.Author }, }; xDocument = torznabCaps.GetXDocument(); xDoumentSearching = xDocument.Root?.Element("searching"); Assert.AreEqual("yes", xDoumentSearching?.Element("search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("tv-search")?.Attribute("available")?.Value); Assert.AreEqual("q,season,ep,tvdbid,rid", xDoumentSearching?.Element("tv-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("movie-search")?.Attribute("available")?.Value); Assert.AreEqual("q,imdbid,tmdbid", xDoumentSearching?.Element("movie-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("music-search")?.Attribute("available")?.Value); Assert.AreEqual("q,album,artist,label,year", xDoumentSearching?.Element("music-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("audio-search")?.Attribute("available")?.Value); Assert.AreEqual("q,album,artist,label,year", xDoumentSearching?.Element("audio-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("book-search")?.Attribute("available")?.Value); Assert.AreEqual("q,title,author", xDoumentSearching?.Element("book-search")?.Attribute("supportedParams")?.Value); // test categories torznabCaps = new TorznabCapabilities { Categories = { TorznabCatType.MoviesSD } // child category }; xDocument = torznabCaps.GetXDocument(); var xDoumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList(); Assert.AreEqual(1, xDoumentCategories?.Count); Assert.AreEqual(TorznabCatType.MoviesSD.ID.ToString(), xDoumentCategories?.First().Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDoumentCategories?.First().Attribute("name")?.Value); // TODO: child category is duplicated. should we add just parent and child without other subcats? torznabCaps = new TorznabCapabilities { Categories = { TorznabCatType.Movies, TorznabCatType.MoviesSD } // parent and child category }; xDocument = torznabCaps.GetXDocument(); xDoumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList(); Assert.AreEqual(2, xDoumentCategories?.Count); Assert.AreEqual(TorznabCatType.Movies.ID.ToString(), xDoumentCategories?.First().Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.Movies.Name, xDoumentCategories?.First().Attribute("name")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.ID.ToString(), xDoumentCategories?[1].Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDoumentCategories?[1].Attribute("name")?.Value); var xDoumentSubCategories = xDoumentCategories?.First()?.Elements("subcat").ToList(); Assert.AreEqual(9, xDoumentSubCategories?.Count); Assert.AreEqual(TorznabCatType.MoviesForeign.ID.ToString(), xDoumentSubCategories?.First().Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesForeign.Name, xDoumentSubCategories?.First().Attribute("name")?.Value); // TODO: review Torznab spec about custom cats => https://github.com/Sonarr/Sonarr/wiki/Implementing-a-Torznab-indexer#caps-endpoint torznabCaps = new TorznabCapabilities { Categories = { new TorznabCategory(100001, "CustomCat"), TorznabCatType.MoviesSD } // custom category }; xDocument = torznabCaps.GetXDocument(); xDoumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList(); Assert.AreEqual(2, xDoumentCategories?.Count); Assert.AreEqual("100001", xDoumentCategories?[0].Attribute("id")?.Value); // custom cats are first in the list Assert.AreEqual("CustomCat", xDoumentCategories?[0].Attribute("name")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.ID.ToString(), xDoumentCategories?[1].Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDoumentCategories?[1].Attribute("name")?.Value); }
public void TestParseBookSearchParams() { var torznabCaps = new TorznabCapabilities(); torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "search", new List <string> { "q" } }, { "book-search", null } }); Assert.IsEmpty(torznabCaps.MovieSearchParams); torznabCaps = new TorznabCapabilities(); torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "search", new List <string> { "q" } }, { "book-search", new List <string>() } }); Assert.IsEmpty(torznabCaps.MovieSearchParams); torznabCaps = new TorznabCapabilities(); torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "search", new List <string> { "q" } }, { "book-search", new List <string> { "q", "title" } } }); Assert.AreEqual(new List <BookSearchParam> { BookSearchParam.Q, BookSearchParam.Title }, torznabCaps.BookSearchParams); torznabCaps = new TorznabCapabilities(); try { torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "search", new List <string> { "q" } }, { "book-search", new List <string> { "q", "q" } } // duplicate param }); Assert.Fail(); } catch (Exception) { // ignored } torznabCaps = new TorznabCapabilities(); try { torznabCaps.ParseCardigannSearchModes(new Dictionary <string, List <string> > { { "search", new List <string> { "q" } }, { "book-search", new List <string> { "bad" } } // unsupported param }); Assert.Fail(); } catch (Exception) { // ignored } }
protected BaseNewznabIndexer(string link, string id, string name, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(id: id, name: name, description: description, link: link, caps: caps, configService: configService, client: client, logger: logger, p: p, configData: configData, downloadBase: downloadBase) { }
protected AvistazTracker(string name, string link, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, IProtectionService p, TorznabCapabilities caps) : base(name, description: description, link: link, caps: caps, configService: configService, client: client, logger: logger, p: p, configData: new ConfigurationDataBasicLogin()) { Encoding = Encoding.UTF8; Language = "en-us"; AddCategoryMapping(1, TorznabCatType.Movies); AddCategoryMapping(1, TorznabCatType.MoviesUHD); AddCategoryMapping(1, TorznabCatType.MoviesHD); AddCategoryMapping(1, TorznabCatType.MoviesSD); AddCategoryMapping(2, TorznabCatType.TV); AddCategoryMapping(2, TorznabCatType.TVUHD); AddCategoryMapping(2, TorznabCatType.TVHD); AddCategoryMapping(2, TorznabCatType.TVSD); AddCategoryMapping(3, TorznabCatType.Audio); }
public void TestTorznabCaps() { // test header var torznabCaps = new TorznabCapabilities(); var xDocument = torznabCaps.GetXDocument(); Assert.AreEqual("caps", xDocument.Root?.Name.LocalName); Assert.AreEqual("Jackett", xDocument.Root?.Element("server")?.Attribute("title")?.Value); Assert.True(xDocument.Root?.Element("searching")?.HasElements); Assert.False(xDocument.Root?.Element("categories")?.HasElements); // TODO: remove params when it's disabled. Review Torznab specs // test all features disabled torznabCaps = new TorznabCapabilities { SearchAvailable = false, TVSearchAvailable = false }; xDocument = torznabCaps.GetXDocument(); var xDoumentSearching = xDocument.Root?.Element("searching"); Assert.AreEqual("no", xDoumentSearching?.Element("search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("tv-search")?.Attribute("available")?.Value); Assert.AreEqual("q,season,ep", xDoumentSearching?.Element("tv-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("movie-search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("movie-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("music-search")?.Attribute("available")?.Value); Assert.AreEqual("", xDoumentSearching?.Element("music-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("audio-search")?.Attribute("available")?.Value); Assert.AreEqual("", xDoumentSearching?.Element("audio-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("no", xDoumentSearching?.Element("book-search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("book-search")?.Attribute("supportedParams")?.Value); // TODO: validate invalid music params // TODO: book parameters should be configurable? // test all features enabled torznabCaps = new TorznabCapabilities { SearchAvailable = true, TVSearchAvailable = true, MovieSearchAvailable = true, BookSearchAvailable = true, SupportsImdbMovieSearch = true, SupportsImdbTVSearch = true, SupportsTvdbSearch = true, SupportsTmdbMovieSearch = true, SupportsTVRageSearch = true, SupportedMusicSearchParamsList = new List <string> { "q", "album", "artist", "label", "year" } }; xDocument = torznabCaps.GetXDocument(); xDoumentSearching = xDocument.Root?.Element("searching"); Assert.AreEqual("yes", xDoumentSearching?.Element("search")?.Attribute("available")?.Value); Assert.AreEqual("q", xDoumentSearching?.Element("search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("tv-search")?.Attribute("available")?.Value); Assert.AreEqual("q,season,ep,rid,tvdbid,imdbid", xDoumentSearching?.Element("tv-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("movie-search")?.Attribute("available")?.Value); Assert.AreEqual("q,imdbid,tmdbid", xDoumentSearching?.Element("movie-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("music-search")?.Attribute("available")?.Value); Assert.AreEqual("q,album,artist,label,year", xDoumentSearching?.Element("music-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("audio-search")?.Attribute("available")?.Value); Assert.AreEqual("q,album,artist,label,year", xDoumentSearching?.Element("audio-search")?.Attribute("supportedParams")?.Value); Assert.AreEqual("yes", xDoumentSearching?.Element("book-search")?.Attribute("available")?.Value); Assert.AreEqual("q,author,title", xDoumentSearching?.Element("book-search")?.Attribute("supportedParams")?.Value); // test categories torznabCaps = new TorznabCapabilities(new [] { TorznabCatType.MoviesSD }); // child category xDocument = torznabCaps.GetXDocument(); var xDoumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList(); Assert.AreEqual(1, xDoumentCategories?.Count); Assert.AreEqual(TorznabCatType.MoviesSD.ID.ToString(), xDoumentCategories?.First().Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDoumentCategories?.First().Attribute("name")?.Value); // TODO: child category is duplicated. should we add just parent and child without other subcats? torznabCaps = new TorznabCapabilities(new [] { TorznabCatType.Movies, TorznabCatType.MoviesSD }); // parent and child category xDocument = torznabCaps.GetXDocument(); xDoumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList(); Assert.AreEqual(2, xDoumentCategories?.Count); Assert.AreEqual(TorznabCatType.Movies.ID.ToString(), xDoumentCategories?.First().Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.Movies.Name, xDoumentCategories?.First().Attribute("name")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.ID.ToString(), xDoumentCategories?[1].Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDoumentCategories?[1].Attribute("name")?.Value); var xDoumentSubCategories = xDoumentCategories?.First()?.Elements("subcat").ToList(); Assert.AreEqual(9, xDoumentSubCategories?.Count); Assert.AreEqual(TorznabCatType.MoviesForeign.ID.ToString(), xDoumentSubCategories?.First().Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesForeign.Name, xDoumentSubCategories?.First().Attribute("name")?.Value); // TODO: review Torznab spec about custom cats => https://github.com/Sonarr/Sonarr/wiki/Implementing-a-Torznab-indexer#caps-endpoint // TODO: orderby is not working torznabCaps = new TorznabCapabilities(new [] { new TorznabCategory(100001, "CustomCat"), TorznabCatType.MoviesSD }); // custom category xDocument = torznabCaps.GetXDocument(); xDoumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList(); Assert.AreEqual(2, xDoumentCategories?.Count); Assert.AreEqual("100001", xDoumentCategories?[0].Attribute("id")?.Value); // custom cats are first in the list Assert.AreEqual("CustomCat", xDoumentCategories?[0].Attribute("name")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.ID.ToString(), xDoumentCategories?[1].Attribute("id")?.Value); Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDoumentCategories?[1].Attribute("name")?.Value); }