Exemplo n.º 1
0
        private async Task <List <NewzNabSearchResult> > Search(NewzNabQuery query)
        {
            var results  = new List <NewzNabSearchResult>();
            var queryUri = new UriBuilder(ApiUrl);
            var result   = new StringBuilder();

            result.Append($"t=search&apikey={ApiKey}&q={query.Query}&cat={string.Join(",", query.Categories)}");
            if (query.Offset != null)
            {
                result.Append("&offset=" + query.Offset);
            }
            if (query.Groups != null && query.Groups.Any())
            {
                result.Append("&group=");
                result.Append(string.Join(",", query.Groups));
            }
            queryUri.Query = result.ToString();
            var xmlResult = new XmlDocument();

            xmlResult.Load(queryUri.Uri.ToString());
            foreach (XmlNode item in xmlResult.SelectNodes("/rss/channel/item"))
            {
                results.Add(new NewzNabSearchResult(item));
            }
            return(results);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <SearchResult> > Search(string query)
        {
            if (Categories.Count == 0)
            {
                await Test();
            }
            var nnq = new NewzNabQuery(query, Categories);

            return(await Search(nnq));
        }
Exemplo n.º 3
0
        public static List <NewzNabSearchResult> SearchForIssue(Issue issue, Comic comic, string host, string apiKey, string name)
        {
            var query = new NewzNabQuery {
                RequestedFunction = Functions.Search
            };

            query.Groups.Add("alt.binaries.ebook");
            query.Groups.Add("alt.binaries.comics");
            query.Groups.Add("alt.binaries.comics.dcp");
            query.Groups.Add("alt.binaries.comics.repost");
            query.Groups.Add("alt.binaries.pictures.comics");
            query.Groups.Add("alt.binaries.pictures.comics.dcp");
            query.Groups.Add("alt.binaries.pictures.comics.repost");
            query.Groups.Add(" alt.binaries.pictures.comics.reposts");
            query.Groups.Add("alt.binaries.manga");
            query.Groups.Add("alt.binaries.mangas");
            query.Groups.Add("alt.binaries.pictures.comics.complete");
            query.Query = Regex.Replace(comic.ComicName, "[^a-zA-Z0-9_]+", " ");

            var rawData = GetSource(host, apiKey).Search(query);

            var parsedResults = new List <NewzNabSearchResult>();

            foreach (var result in rawData)
            {
                if (!result.Category.ToLower().Contains("comic") &&
                    !result.Category.ToLower().Contains("book"))
                {
                    continue;
                }
                if (!TitleParsingManager.TitleMatch(result.Title, issue, comic))
                {
                    continue;
                }

                result.Provider = name;
                parsedResults.Add(result);
            }

            return(parsedResults);
        }