Beispiel #1
0
        private void findCurseCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e != null && e.Error == null && !String.IsNullOrEmpty(e.Result))
            {
                using (StringReader sr = new StringReader(e.Result)) {
                    List <string> results = new List <string>();

                    while (true)
                    {
                        try {
                            string currentline = sr.ReadLine().Trim();
                            if (currentline.Contains("<a href=\"/mc-mods/"))
                            {
                                results.Add(currentline);
                            }
                        }
                        catch {
                            break;
                        }
                    }

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

                        if (MiscFunctions.CleanString(foundModname) == MiscFunctions.CleanString(modFileName))
                        {
                            startCharList = new char[] { '=', '"' };
                            endCharList   = new char[] { '"' };
                            string linkSection = MiscFunctions.ExtractSection(result, endCharList, startCharList);
                            website = ParseCurseUri("http://minecraft.curseforge.com" + linkSection);
                            break;
                        }
                    }
                }

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

                if (siteMode == "NONE")
                {
                    FindWebsiteUri();
                }
                else
                {
                    progress   = 0;
                    findMode   = 0;
                    findQueued = false;
                    findBusy   = false;
                    updateList = true;
                }
            }
            else
            {
                FindWebsiteUri();
            }
        }
Beispiel #2
0
        public void ForceSetSite(string modName, string uri)
        {
            string cleanName = MiscFunctions.CleanString(modName);

            if (userDatabase.ContainsKey(cleanName))
            {
                userDatabase[cleanName] = uri;
            }
            else
            {
                userDatabase.Add(cleanName, uri);
            }
        }
Beispiel #3
0
        public string GetSite(string modName)
        {
            string cleanName = MiscFunctions.CleanString(modName);

            if (userDatabase.ContainsKey(cleanName) && userDatabase[cleanName] != "NONE")
            {
                return(userDatabase[cleanName]);
            }
            else if (globalDatabase.ContainsKey(cleanName) && globalDatabase[cleanName] != "NONE")
            {
                return(globalDatabase[cleanName]);
            }
            else
            {
                return("NONE");
            }
        }
Beispiel #4
0
 private void googleButton_Click(object sender, EventArgs e)
 {
     Process.Start("https://www.google.com/?gws_rd=ssl#q=" + selectedMod.modFileName.Replace(" ", "") + "+minecraft");
     Process.Start("https://www.google.com/?gws_rd=ssl#q=" + MiscFunctions.CleanString(selectedMod.modFileName) + "+minecraft");
 }
Beispiel #5
0
        private void checkDownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e != null && e.Error == null && !String.IsNullOrEmpty(e.Result))
            {
                progress = 100;
                using (StringReader sr = new StringReader(e.Result)) {
                    string newVersion = "";
                    string newFile    = "";
                    releaseDate      = "N/A";
                    versionLatestRaw = "N/A";
                    versionLatest    = "N/A";
                    newFileName      = "";

                    if (siteMode == "curse")
                    {
                        while (true)
                        {
                            while (!newVersion.Contains("<h4 class=\"e-sidebar-subheader overflow-tip\">Minecraft"))
                            {
                                newVersion = sr.ReadLine();
                                if (newVersion == null)
                                {
                                    versionLatest = "MC version not found";
                                    progress      = 0;
                                    checkQueued   = false;
                                    checkBusy     = false;
                                    updateList    = true;
                                    return;
                                }
                                newVersion = newVersion.Trim();
                            }

                            char[] startCharList = new char[] { '>', 'm', 'i', 'n', 'e', 'c', 'r', 'a', 'f', 't' };
                            char[] endCharList   = new char[] { '<' };
                            string siteVersion   = MiscFunctions.ExtractSection(newVersion.ToLower(), endCharList, startCharList).Trim();

                            string thisVersion = "";
                            try {
                                char[] delim = new char[] { '.' };
                                thisVersion = mcVersion.Split(delim)[0] + "." + mcVersion.Split(delim)[1];
                            }
                            catch { }

                            if (siteVersion == thisVersion)
                            {
                                while (!newVersion.Contains("<a class=\"overflow-tip\" href=\"/projects/"))
                                {
                                    newVersion = sr.ReadLine().Trim();
                                }

                                startCharList = new char[] { '>' };
                                endCharList   = new char[] { '<' };
                                newFile       = MiscFunctions.ExtractSection(newVersion, endCharList, startCharList).Replace(" ", "").ToLower().Replace("&#x27;", "").Replace("+", "");

                                string[] modNames = new string[] { "reliquary", "carpentersblocks", "hardcoreenderexpansion" };
                                foreach (string mod in modNames)
                                {
                                    if (MiscFunctions.CleanString(website).Contains(mod) && !MiscFunctions.CleanString(newFile).Contains(mod))
                                    {
                                        newFile = mod + "-" + newFile;
                                    }
                                }

                                string dateLine = sr.ReadLine().Trim();
                                startCharList = new char[] { '"', '>' };
                                endCharList   = new char[] { '<' };
                                releaseDate   = MiscFunctions.ExtractSection(dateLine, endCharList, startCharList);
                                break;
                            }
                            else
                            {
                                newVersion = sr.ReadLine().Trim();
                            }
                        }
                    }

                    if (siteMode == "forum")
                    {
                        while (!newVersion.Contains("<title>"))
                        {
                            newVersion = sr.ReadLine().Trim();
                        }
                        newFile = "undefined-" + MiscFunctions.RemoveLetters(newVersion);
                    }

                    if (siteMode == "github")
                    {
                        while (!newVersion.Contains("<a href=\"" + website.Replace("https://github.com", "").Replace("/latest", "/download/")))
                        {
                            newVersion = sr.ReadLine().Trim();
                        }

                        char[] startCharList = new char[] { '/' };
                        char[] endCharList   = new char[] { '"' };
                        newFile = MiscFunctions.ExtractSection(newVersion, endCharList, startCharList).Replace(" ", "").ToLower();
                    }

                    if (!newFile.Contains(".zip") && !newFile.Contains(".jar"))
                    {
                        newFile += ".jar";
                    }
                    if (disabled && !newFile.Contains(".disabled"))
                    {
                        newFile += ".disabled";
                    }

                    versionLatestRaw = newVersion;
                    newFileName      = Path.GetFileName(newFile);
                    versionLatest    = MiscFunctions.RemoveLetters(newFileName);

                    if (versionLatestRaw != versionLocalRaw)
                    {
                        canUpdate = true;
                    }
                    else
                    {
                        canUpdate = false;
                    }
                }

                UpdateModValues();
                progress    = 0;
                checkQueued = false;
                checkBusy   = false;
                updateList  = true;
            }
            else
            {
                progress    = 0;
                checkQueued = false;
                checkBusy   = false;
            }
        }
Beispiel #6
0
        public void FindWebsiteUri()
        {
            findBusy = true;
            WebClient client1 = new WebClient();

            client1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(findCurseCompleted);
            WebClient client2 = new WebClient();

            client2.DownloadStringCompleted += new DownloadStringCompletedEventHandler(findLuckyCompleted);
            WebClient client3 = new WebClient();

            client3.DownloadStringCompleted += new DownloadStringCompletedEventHandler(findGoogleCompleted);
            WebClient client4 = new WebClient();

            client4.DownloadStringCompleted += new DownloadStringCompletedEventHandler(findYahooCompleted);
            progress = 0;
            findMode++;

            switch (findMode)
            {
            case 1:
                website = "NONE";     //debug
                client1.DownloadStringAsync(new Uri("http://minecraft.curseforge.com/search?search=" + MiscFunctions.CleanModName(modFileName)));
                break;

            case 2:
                website1 = website;
                website  = "NONE";    //debug
                client3.DownloadStringAsync(new Uri("http://www.google.com/search?sourceid=navclient&btnI=I&q=" + modFileName.Replace(" ", "") + "+minecraft"));
                break;

            case 3:
                website2 = website;
                website  = "NONE";    //debug
                client4.DownloadStringAsync(new Uri("https://search.yahoo.com/search?p=" + modFileName.Replace(" ", "") + "+minecraft"));
                break;

            case 4:
                website3 = website;
                website  = "NONE";    //debug
                client4.DownloadStringAsync(new Uri("https://search.yahoo.com/search?p=" + MiscFunctions.CleanString(modFileName) + "+minecraft"));
                break;

            default:
                website4 = website;
                website  = "NONE";    //debug
                if (website1 != "NONE")
                {
                    website = website1;
                }
                else if (website2 != "NONE")
                {
                    website = website2;
                }
                else if (website3 != "NONE")
                {
                    website = website3;
                }
                else if (website4 != "NONE")
                {
                    website = website4;
                }
                website1 = website1.Replace(forumIdentifier, "").Replace(curseIdentifier, "").Replace("http://", "").Replace("www.", "");
                website2 = website2.Replace(forumIdentifier, "").Replace(curseIdentifier, "").Replace("http://", "").Replace("www.", "");
                website3 = website3.Replace(forumIdentifier, "").Replace(curseIdentifier, "").Replace("http://", "").Replace("www.", "");
                website4 = website4.Replace(forumIdentifier, "").Replace(curseIdentifier, "").Replace("http://", "").Replace("www.", "");

                //client2.DownloadStringAsync(new Uri("http://www.google.com/search?&sourceid=navclient&btnI=I&q=" + MiscFunctions.CleanString(modFilename) + "+curseforge"));
                //client3.DownloadStringAsync(new Uri("http://www.google.com/search?sourceid=navclient&btnI=I&q=" + MiscFunctions.CleanString(modFilename) + "+minecraft"));
                progress   = 0;
                findMode   = 0;
                findQueued = false;
                findBusy   = false;
                updateList = true;     //debug
                break;
            }
        }