Example #1
0
        private void findLuckyCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e != null && e.Error == null && !String.IsNullOrEmpty(e.Result))
            {
                using (StringReader sr = new StringReader(e.Result)) {
                    try {
                        string currentline = "";
                        while (!currentline.Contains("<a href=\"/mc-mods/"))
                        {
                            currentline = sr.ReadLine().Trim();
                        }

                        char[] startCharList = new char[] { '=', '"' };
                        char[] endCharList   = new char[] { '"' };
                        string linkSection   = MiscFunctions.ExtractSection(currentline, endCharList, startCharList);

                        startCharList = new char[] { '"', '>' };
                        endCharList   = new char[] { '<' };
                        string foundModname = MiscFunctions.ExtractSection(currentline, endCharList, startCharList);

                        if (!MiscFunctions.PartialMatch(modFileName, foundModname))
                        {
                            website = "No Patial Match: "; //debug
                        }
                        website += ParseCurseUri("http://minecraft.curseforge.com" + linkSection);
                    }
                    catch {
                        website = "NONE";
                    }
                }

                UpdateModValues();
                FindWebsiteUri(); //debug
                return;           //debug

                if (siteMode == "NONE")
                {
                    FindWebsiteUri();
                }
                else
                {
                    progress   = 0;
                    findMode   = 0;
                    findQueued = false;
                    findBusy   = false;
                    updateList = true;
                }
            }
            else
            {
                FindWebsiteUri();
            }
        }
Example #2
0
        private string GetWebsiteFromResults(string webpage, string delim, char[] startChars, char[] endChars)
        {
            List <string> results = new List <string>();

            using (StringReader sr = new StringReader(webpage)) {
                string currentLine = "";
                while (true)
                {
                    currentLine = sr.ReadLine();

                    if (currentLine != null)
                    {
                        if (currentLine.Contains(delim))
                        {
                            string[] delims = new string[] { delim };
                            results.AddRange(currentLine.Split(delims, StringSplitOptions.RemoveEmptyEntries));
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                string curseLink = "NONE";
                string forumLink = "NONE";

                for (int i = 1; i < results.Count; i++)
                {
                    results[i] = MiscFunctions.ExtractSection(results[i], endChars, startChars).Replace("%2f", "/").Replace("%3a", ":");

                    char[] startCharList = new char[] { 'm', 'o', 'd', 's', '/' };
                    char[] endCharList   = new char[] { };
                    string foundModname  = MiscFunctions.ExtractSection(results[i], endCharList, startCharList);

                    if (curseLink == "NONE" && results[i].Contains(curseIdentifier) && MiscFunctions.PartialMatch(modFileName, foundModname))
                    {
                        curseLink = ParseCurseUri(results[i]);
                    }
                    if (forumLink == "NONE" && results[i].Contains(forumIdentifier) && MiscFunctions.PartialMatch(modFileName, foundModname))
                    {
                        forumLink = ParseForumUri(results[i]);
                    }
                }

                if (curseLink != "NONE")
                {
                    return(curseLink);
                }
                else
                {
                    return(forumLink);
                }
            }
        }