Exemplo n.º 1
0
        private string BuildGenericQueryString(NewzNabQuery Query)
        {
            var result = new StringBuilder();

            result.Append("t=search");
            if (ApiKey != "")
            {
                result.Append("&apikey=" + ApiKey);
            }
            if (Query.Query != "")
            {
                result.Append("&q=" + Query.Query);
            }
            result.Append("&offset=" + Query.Offset.ToString());
            if (Query.Groups.Count > 0)
            {
                result.Append("&group=");
                result.Append(string.Join(",", Query.Groups));
            }

            if (Query.Categories.Count <= 0)
            {
                return(result.ToString());
            }
            result.Append("&cat=");
            result.Append(string.Join(",", Query.Categories));
            return(result.ToString());
        }
Exemplo n.º 2
0
        public bool GetCapabilities()
        {
            NewzNabQuery capsQuery = new NewzNabQuery();

            capsQuery.RequestedFunction = Functions.Caps;
            XmlDocument response = DoQuery(capsQuery);

            Capabilities = NewzNabCapabilities.ParseXmlResponse(response);
            return(true);
        }
Exemplo n.º 3
0
        public List <NewzNabSearchResult> Search(NewzNabQuery query)
        {
            var results = new List <NewzNabSearchResult>();
            var result  = DoQuery(query);
            var items   = result.SelectNodes("/rss/channel/item");

            if (items == null)
            {
                return(results);
            }
            foreach (XmlNode item in items)
            {
                results.Add(NewzNabQuery.ParseItemBlock(item));
            }

            return(results);
        }
Exemplo n.º 4
0
        private XmlDocument DoQuery(NewzNabQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            var queryUri = new UriBuilder(Apiurl);

            switch (query.RequestedFunction)
            {
            case Functions.Caps:
                queryUri.Query = "t=caps&o=xml";
                break;

            case Functions.Register:
                break;

            case Functions.Search:
                queryUri.Query = BuildGenericQueryString(query);
                break;

            case Functions.TvSearch:
                break;

            case Functions.MovieSearch:
                break;

            case Functions.MusicSearch:
                break;

            case Functions.BookSearch:
                break;

            case Functions.Details:
                break;

            case Functions.Getnfo:
                break;

            case Functions.Get:
                break;

            case Functions.CartAdd:
                break;

            case Functions.CartDel:
                break;

            case Functions.Comments:
                break;

            case Functions.CommentsAdd:
                break;

            case Functions.User:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            XmlDocument xmlResponse = new XmlDocument();

            xmlResponse.Load(queryUri.Uri.ToString());
            return(xmlResponse);
        }