Ejemplo n.º 1
0
        private TSpec Get <TSpec>(NewznabRequest query, List <int> indexerIds, bool interactiveSearch)
            where TSpec : SearchCriteriaBase, new()
        {
            var spec = new TSpec()
            {
                InteractiveSearch = interactiveSearch
            };

            if (query.cat != null)
            {
                spec.Categories = query.cat.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => int.Parse(s)).ToArray();
            }
            else
            {
                spec.Categories = Array.Empty <int>();
            }

            spec.SearchTerm = query.q;
            spec.SearchType = query.t;
            spec.Limit      = query.limit;
            spec.Offset     = query.offset;
            spec.Source     = query.source;
            spec.Host       = query.host;

            spec.IndexerIds = indexerIds;

            return(spec);
        }
Ejemplo n.º 2
0
        private async Task <NewznabResults> BasicSearch(NewznabRequest request, List <int> indexerIds, bool interactiveSearch)
        {
            var searchSpec = Get <BasicSearchCriteria>(request, indexerIds, interactiveSearch);

            return(new NewznabResults {
                Releases = await Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec)
            });
        }
Ejemplo n.º 3
0
        private async Task <NewznabResults> BookSearch(NewznabRequest request, List <int> indexerIds, bool interactiveSearch)
        {
            var searchSpec = Get <BookSearchCriteria>(request, indexerIds, interactiveSearch);

            searchSpec.Author = request.author;
            searchSpec.Title  = request.title;

            return(new NewznabResults {
                Releases = await Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec)
            });
        }
Ejemplo n.º 4
0
        private async Task <NewznabResults> MusicSearch(NewznabRequest request, List <int> indexerIds, bool interactiveSearch)
        {
            var searchSpec = Get <MusicSearchCriteria>(request, indexerIds, interactiveSearch);

            searchSpec.Artist = request.artist;
            searchSpec.Album  = request.album;
            searchSpec.Label  = request.label;
            searchSpec.Genre  = request.genre;
            searchSpec.Year   = request.year;

            return(new NewznabResults {
                Releases = await Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec)
            });
        }
Ejemplo n.º 5
0
        private async Task <NewznabResults> MovieSearch(NewznabRequest request, List <int> indexerIds, bool interactiveSearch)
        {
            var searchSpec = Get <MovieSearchCriteria>(request, indexerIds, interactiveSearch);

            searchSpec.ImdbId  = request.imdbid;
            searchSpec.TmdbId  = request.tmdbid;
            searchSpec.TraktId = request.traktid;
            searchSpec.Year    = request.year;
            searchSpec.Genre   = request.genre;

            return(new NewznabResults {
                Releases = await Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec)
            });
        }
Ejemplo n.º 6
0
        private async Task <NewznabResults> TvSearch(NewznabRequest request, List <int> indexerIds, bool interactiveSearch)
        {
            var searchSpec = Get <TvSearchCriteria>(request, indexerIds, interactiveSearch);

            searchSpec.Season   = request.season;
            searchSpec.Episode  = request.ep;
            searchSpec.TvdbId   = request.tvdbid;
            searchSpec.ImdbId   = request.imdbid;
            searchSpec.TraktId  = request.traktid;
            searchSpec.TmdbId   = request.tmdbid;
            searchSpec.RId      = request.rid;
            searchSpec.TvMazeId = request.tvmazeid;

            return(new NewznabResults {
                Releases = await Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec)
            });
        }
Ejemplo n.º 7
0
        public Task <NewznabResults> Search(NewznabRequest request, List <int> indexerIds, bool interactiveSearch)
        {
            switch (request.t)
            {
            case "movie":
                return(MovieSearch(request, indexerIds, interactiveSearch));

            case "music":
                return(MusicSearch(request, indexerIds, interactiveSearch));

            case "tvsearch":
                return(TvSearch(request, indexerIds, interactiveSearch));

            case "book":
                return(BookSearch(request, indexerIds, interactiveSearch));

            default:
                return(BasicSearch(request, indexerIds, interactiveSearch));
            }
        }