Exemplo n.º 1
0
            /// <summary>
            /// Download JPG Images From Parsed HTML Links
            /// </summary>
            /// <param name="html">HTML Containing URL Links to JPG Images</param>
            /// <param name="SaveRoot">Dir To Save Images To</param>
            /// <param name="BaseName">Base Save Name for New Images</param>
            /// <returns></returns>
            public int DownloadImages(string html, string SaveRoot = "\\Images", string BaseName = "Image")
            {
                if (SaveRoot == "\\Images")
                {
                    SaveRoot = ahk.AppDir() + "\\Images";
                }

                List <string> images   = rg.JpgImageLinks(html); // list of jpg images found on page
                string        savename = "";

                int downloaded = 0;

                if (images != null && images.Count > 0)
                {
                    ahk.FileCreateDir(SaveRoot);

                    int i = 0;
                    foreach (string image in images)
                    {
                        savename = SaveRoot + "\\" + BaseName + ".jpg";

                        if (i > 0)
                        {
                            savename = SaveRoot + "\\" + BaseName + "_" + i.AddLeadingZeros(3) + ".jpg";
                        }
                        i++;

                        if (!File.Exists(savename))
                        {
                            web.DownloadFile(image, savename, true); downloaded++;
                        }
                    }
                }

                //ahk.MsgBox("Downloaded " + downloaded.ToString() + " + Images");
                return(downloaded);
            }
Exemplo n.º 2
0
            //_Parse.XML xml = new _Parse.XML();
            //_AHK ahk = new _AHK();
            //_Database.SQL sql = new _Database.SQL();
            //_Lists lst = new _Lists();
            //_Parse prs = new _Parse();
            ////_Images img = new _Images();
            //_TelerikLib.RadProgress pro = new _TelerikLib.RadProgress();
            //_TelerikLib tel = new _TelerikLib();
            ////_Apps.Chrome cr = new _Apps.Chrome();
            //sharpAHK_Dev._Threads thr = new sharpAHK_Dev._Threads();
            //_TelerikLib.RadTree tree = new _TelerikLib.RadTree();
            //IAFD iafd = new IAFD();
            //_Web.ADBSites.PBBForum pbb = new _Web.ADBSites.PBBForum();
            //_Web.ADBSites.PRNWForum prnw = new _Web.ADBSites.PRNWForum();

            #endregion


            public void Download_Site(int startPage = 1, int LastPage = 230, bool SkipExisting = true, RadProgressBar Bar = null, RadProgressBar Bar2 = null, bool NewThread = true)
            {
                _AHK   ahk = new _AHK();
                _Lists lst = new _Lists();

                _Sites.RapidGator       rg  = new _Sites.RapidGator();
                _TelerikLib.RadProgress pro = new _TelerikLib.RadProgress();

                if (NewThread)
                {
                    Thread newThread = new Thread(() => Download_Site(startPage, LastPage, SkipExisting, Bar, Bar2, false)); // Function To Execute
                    newThread.IsBackground = true;
                    newThread.Start();
                }
                else
                {
                    int pageNum = startPage;
                    do
                    {
                        int           postNum = 0;
                        string        html    = ahk.Download_HTML("http://pornchil.com/page/" + pageNum + "/");
                        List <string> lines   = lst.Text_To_List(html, true, true, false);

                        if (Bar != null)
                        {
                            pro.SetupProgressBar(Bar, 10);
                        }                                                    // # of posts/page

                        foreach (string line in lines)
                        {
                            if (line.Contains("<h1 class=\"entry-title\"><a href="))
                            {
                                PrnChill chill = new PrnChill();
                                //ahk.MsgBox(line);

                                string Line = line.Replace("<h1 class=\"entry-title\"><a href=\"", "");
                                chill.PostURL  = ahk.StringSplit(Line, "\"", 0);
                                chill.PostName = ahk.StringSplit(Line, ">", 1);
                                chill.PostName = ahk.StringSplit(chill.PostName, "<", 0);

                                if (SkipExisting)
                                {
                                    if (AlreadyParsed(chill.PostURL))
                                    {
                                        continue;
                                    }                                                // check to see if this post already has an entry, if so skip
                                }


                                if (Bar != null)
                                {
                                    postNum++; pro.UpdateProgress(Bar, postNum + "/10");
                                }                                                                          // # of posts remaining

                                string        postHTML = ahk.Download_HTML(chill.PostURL);
                                List <string> links    = rg.Regex_RGLinks(postHTML);

                                if (links.Count > 0)
                                {
                                    if (Bar != null)
                                    {
                                        pro.ProgressText(Bar, postNum + "/10 | Verifying Links");
                                    }                                                                                           // # of posts remaining

                                    List <_Sites.RapidGator.RGInfo> checkedLinks = rg.RapidGator_BatchCheck(links, true, Bar2); // batch check list of rg links

                                    string rglinks = ""; int goodLinkCount = 0;
                                    foreach (_Sites.RapidGator.RGInfo link in checkedLinks)
                                    {
                                        if (rglinks == "")
                                        {
                                            rglinks = link.FileURL + "|" + link.FileSize; goodLinkCount++;
                                        }
                                        else
                                        {
                                            rglinks = rglinks + "\n" + link.FileURL + "|" + link.FileSize; goodLinkCount++;
                                        }
                                    }

                                    chill.Links     = rglinks; // online rg links with  filepath|filesize return
                                    chill.LinkCount = goodLinkCount;

                                    chill.LinkCheckDate = DateTime.Now.ToString();
                                }

                                chill.InCollection = "false";

                                List <string> images = rg.JpgImageLinks(postHTML);

                                if (Bar != null)
                                {
                                    pro.ProgressText(Bar, postNum + "/10 | Downloading Images (" + images.Count + ")");
                                }                                                                                                         // # of posts remaining

                                if (images.Count > 0)
                                {
                                    // create save dir
                                    string saveDir = ahk.AppDir() + "\\PrnChillPosts";
                                    ahk.FileCreateDir(saveDir);
                                    saveDir = saveDir + "\\" + chill.PostName;
                                    ahk.FileCreateDir(saveDir);

                                    chill.ImageDir = saveDir;

                                    int imgNum = 1;
                                    foreach (string image in images)
                                    {
                                        ahk.Download_File(image, saveDir + "\\" + imgNum + ".jpg", true); imgNum++;
                                    }
                                }

                                PrnChill_UpdateInsert(chill);
                            }
                        }

                        pageNum++;
                    } while (pageNum <= LastPage);
                }
            }