Beispiel #1
0
        public static List<string> Search(string GameName, string Platform, int Retention, Logger LogInstance)
        {
            string ProviderClass = "Provider:NZBClub";
            //Create URI
            string XMLUri = "http://www.nzbclub.com/nzbfeed.aspx?q=" + GameName.Replace(" ", "%20") + "%20" + Platform.Replace(" ", "%20") + "&ig=2&st=5&sp=1&ns=1";
            System.IO.Stream XMLStream;
            WebResponse XMLResponse;

            //Load the feed-xml
            XmlDocument RSSXML;

            WebRequest XMLRequest = WebRequest.Create(XMLUri);
            try
            {
                LogInstance.WriteToFile(1, "Trying to get a response from " + XMLUri, ProviderClass);
                XMLResponse = XMLRequest.GetResponse();
                XMLStream = XMLResponse.GetResponseStream();
            }
            catch (Exception e)
            {
                LogInstance.WriteToFile(2, "Unable to connect to NZBClub.com. The error message returned was:\n" + e.Message, ProviderClass);
                return null;
            }

            RSSXML = new XmlDocument();
            RSSXML.Load(XMLStream);

            //Read the contents
            if (RSSXML.SelectNodes("rss/channel/item") == null)
                return null;

            List<string> Results = new List<string>();

            foreach (XmlNode Node in RSSXML.SelectNodes("rss/channel/item"))
            {
                if (NZBClub.ReturnRetention(Node.SelectSingleNode("pubDate").InnerText) <= Retention)
                {
                    string link = FreakOut.classes.Provider.NZBClub.ReturnURL(Node);
                    string title = Node.SelectSingleNode("title").InnerText;
                    Results.Add(title + ";" + link);
                }
            }

            if (Results.Count != 0)
                return Results;
            else
                return null;
        }
Beispiel #2
0
        public static List<string> Search(string GameName, string nzbshash, int nzbsid, int Retention, Logger LogInstance)
        {
            //Create URI
            string XMLUri = "http://nzbs.org/rss.php?type=5&i=" + nzbsid + "&h=" + nzbshash + "&q=" + GameName + "&dl=1&num=50&age=" + Retention;
            System.IO.Stream XMLStream;
            WebResponse XMLResponse;

            //Load the feed-xml
            XmlDocument RSSXML;

            WebRequest XMLRequest = WebRequest.Create(XMLUri);
            try
            {
                LogInstance.WriteToFile(1, "Trying to get a response from " + XMLUri, "Provider:NZBS.org");
                XMLResponse = XMLRequest.GetResponse();
                XMLStream = XMLResponse.GetResponseStream();
            }
            catch (Exception e)
            {
                LogInstance.WriteToFile(2, "Unable to connect to NZBS.org. The error message returned was:\n" + e.Message, "Provider:NZBS.org");
                return null;
            }

            RSSXML = new XmlDocument();
            RSSXML.Load(XMLStream);

            //Read the contents
            List<string> Results = new List<string>();

            if (RSSXML.SelectNodes("rss/channel/item") == null)
                return null;

            foreach (XmlNode Node in RSSXML.SelectNodes("rss/channel/item"))
            {
                Results.Add(Node.SelectSingleNode("title").InnerText + ";" + Node.SelectSingleNode("link").InnerText);
            }

            return Results;
        }
Beispiel #3
0
        public static List<string> Search(string GameName, string username, string apikey, int Retention, string Platform, Logger LogInstance)
        {
            string ProviderClass = "Provider:NZBMatrix";
            //Determine the correct category for the given Platform
            #region category
            int catid = 0;
            switch (Platform)
            {
                case "PC":
                    catid = 10;
                    break;

                case "Playstation 2":
                    catid = 11;
                    break;

                case "PSP":
                    catid = 12;
                    break;

                case "Xbox":
                    catid = 13;
                    break;

                case "Xbox 360":
                    catid = 14;
                    break;

                case "Wii":
                    catid = 44;
                    break;

                default:
                    catid = 0;
                    break;
            }
            #endregion
            //Create URI
            string XMLUri = "http://api.nzbmatrix.com/v1.1/search.php?search=" + GameName + "&num=50&username="******"&apikey=" + apikey + "&age=" + Retention;

            //Append catid if necessary
            if (catid != 0)
                XMLUri += "&catid=" + catid;

            System.IO.Stream XMLStream;
            WebResponse XMLResponse;

            //Load the feed-xml
            XmlDocument RSSXML;
            StreamReader ErrorParser;

            WebRequest XMLRequest = WebRequest.Create(XMLUri);
            try
            {
                LogInstance.WriteToFile(1, "Trying to get a response from " + XMLUri, ProviderClass);
                XMLResponse = XMLRequest.GetResponse();
                XMLStream = XMLResponse.GetResponseStream();
                ErrorParser = new StreamReader(XMLStream);
                string Messages = ErrorParser.ReadToEnd();
                string LogMessage = "Could not fetch the NZBMatrix-RSS due to the following error: \n";

                switch (Messages)
                {
                    case "error:invalid_login":
                        LogMessage += "error:invalid_login - There seems to be a problem with your username.";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    case "error:invalid_api":
                        LogMessage += "error:invalid_api - There seems to be a problem with your apikey.";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    case "error:invalid_nzbid":
                        LogMessage += "error:invalid_nzbid - Please post a bug report on github with this error message.";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    case "error:vip_only":
                        LogMessage += "error:vip_only - You do not have access to this feature (NZBMatrix VIP only).";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    case "error:disabled_account":
                        LogMessage += "error:disabled_account - Your account has been disabled by NZBMatrix.";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    case "error:no_nzb_found":
                        LogMessage += "error:no_nzb_found - Couldn't find a NZB-File. Problem probably on NZBMatrix' end.";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    case "error:no_search":
                        LogMessage += "error:no_search - Please post a bug report on github with this error message.";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    case "error:nothing_found":
                        LogMessage += "error:nothing_found - unable to get any results on your query.";
                        LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                        return null;

                    default:
                        if (Messages.Contains("error:please_wait"))
                        {
                            LogMessage += "error:please_wait - we have to wait for another request.";
                            LogInstance.WriteToFile(2, LogMessage, ProviderClass);
                            return null;
                        }
                        else
                            break;
                }
            }
            catch (Exception e)
            {
                LogInstance.WriteToFile(2, "Unable to connect to NZBMatrix. The error message returned was:\n" + e.Message, ProviderClass);
                return null;
            }

            RSSXML = new XmlDocument();
            RSSXML.Load(XMLStream);

            //Read the contents
            List<string> Results = new List<string>();

            if (RSSXML.SelectNodes("rss/channel/item") == null)
                return null;

            foreach (XmlNode Node in RSSXML.SelectNodes("rss/channel/item"))
            {
                Results.Add(Node.SelectSingleNode("title").InnerText + ";" + Node.SelectSingleNode("link").InnerText);
            }

            return Results;
        }