/// <summary>
        /// Получить список томов для манги
        /// </summary>
        /// <param name="manga"></param>
        public static void GetChaptersList(MangaInCatalog manga)
        {
            string result;

            webClient = new WebClient();
            chapters  = new List <string>();

            try
            {
                result = webClient.DownloadString(siteRoot + "/" + manga.MangaLink);
                //  Console.WriteLine(result);
                MatchCollection m = Regex.Matches(result, @"\/\w*\/vol\d*\/\d*");

                foreach (Match match in m)
                {
                    if (!chapters.Contains(match.Value))
                    {
                        chapters.Add(match.Value);
                    }
                }
                manga.Chapters = chapters;
                foreach (string ch in manga.Chapters)
                {
                    // Console.WriteLine(ch);
                }
            }
            catch
            {
                MessageBox.Show("Ошибочка GetChapterList");
            }
        }
Exemple #2
0
 public Form2(MangaInCatalog manga)
 {
     InitializeComponent();
     HtmlParsing.pictureBoxPages = pictureBox1;
     HtmlParsing.mangaPages      = new List <string>();
     Manga = manga;
 }
Exemple #3
0
 /// <summary>
 /// Показать загрузки
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ЗагруженнаяМангаToolStripMenuItem_Click(object sender, EventArgs e)
 {
     section = Section.Downloads;
     listViewCatalog.Items.Clear();
     string[] infoArr = new string[7];
     HtmlParsing.mangalist.Clear();
     if (File.Exists(Environment.CurrentDirectory + "/downloads.txt"))
     {
         StreamReader streamReader = new StreamReader(Environment.CurrentDirectory + "/downloads.txt");
         while (!streamReader.EndOfStream)
         {
             MangaInCatalog manga = new MangaInCatalog();
             manga.Chapters = new List <string>();
             var str = streamReader.ReadLine();
             infoArr               = str.Split('~');
             manga.MangaName       = infoArr[0];
             manga.MangaGenre      = infoArr[5];
             manga.MangaImage      = infoArr[3];
             manga.MangaLink       = infoArr[1];
             manga.CurrentChapter  = infoArr[2];
             manga.MangaLargeImage = infoArr[4];
             manga.MangaAbout      = infoArr[6];
             StreamReader stream = new StreamReader(Environment.CurrentDirectory + "/" + manga.MangaLink + "/info.txt");
             {
                 while (!stream.EndOfStream)
                 {
                     var line = stream.ReadLine();
                     manga.Chapters.Add(line);
                 }
             }
             var imagename = Environment.CurrentDirectory + "/" + manga.MangaGenre + "/" + manga.MangaLink + ".jpg";
             Directory.CreateDirectory(Environment.CurrentDirectory + "/" + manga.MangaGenre);
             if (!File.Exists(imagename))
             {
                 webClient.DownloadFile(manga.MangaImage, imagename);
             }
             var image = Image.FromFile(imagename);
             imageListCatalog.Images.Add(manga.MangaLink, image);
             var item = listViewCatalog.Items.Add(manga.MangaName);
             HtmlParsing.mangalist.Add(manga);
             item.ImageKey = manga.MangaLink;
             //  pictureBoxPage.Image = Image.FromFile(manga.MangaLargeImage);
         }
     }
     else
     {
         FileStream fs = File.Create(Environment.CurrentDirectory + "/downloads.txt");
         fs.Close();
     }
 }
Exemple #4
0
 private void BtnToRead_Click(object sender, EventArgs e)
 {
     if (listViewCatalog.SelectedItems.Count == 1)
     {
         MangaInCatalog manga = new MangaInCatalog();
         foreach (MangaInCatalog mangaIn in HtmlParsing.mangalist)
         {
             if (listViewCatalog.SelectedItems[0].Text == mangaIn.MangaName)
             {
                 manga = mangaIn;
                 break;
             }
         }
         Form2 form2 = new Form2(manga);//Передаем мангу на форму чтения
         form2.Show();
     }
 }
        /// <summary>
        /// Сохранить том в ккэш
        /// </summary>
        /// <param name="chapter"></param>
        public static void DownLoadManga(string chapter, MangaInCatalog manga)
        {
            webClient = new WebClient();
            int  i        = 0;
            bool yetExist = false;

            Directory.CreateDirectory(Environment.CurrentDirectory + "/" + chapter);
            webClient.DownloadFile(manga.MangaLargeImage, Environment.CurrentDirectory + "/" + chapter + "/" + "mangacover" + ".jpg");
            manga.MangaLargeImage = Environment.CurrentDirectory + "/" + chapter + "/" + "mangacover" + ".jpg"; ////Скачать обложку

            File.AppendAllText(Environment.CurrentDirectory + "/" + manga.MangaLink + "/info.txt",              //записать в папке с мангой скачанные главы
                               manga.CurrentChapter + Environment.NewLine);                                     //записывается каждый раз

            if (File.Exists(Environment.CurrentDirectory + "/downloads.txt"))
            {
                using (StreamReader fs = new StreamReader(Environment.CurrentDirectory + "/downloads.txt"))//если уже записана в загрузки то не записываем
                {
                    string[] splitName = new string[7];
                    while (!fs.EndOfStream)
                    {
                        var line = fs.ReadLine();
                        splitName = line.Split('~');
                        if (splitName[0] == manga.MangaName)
                        {
                            yetExist = true;
                        }
                    }
                }
            }
            if (!yetExist)
            {
                File.AppendAllText(Environment.CurrentDirectory + "/downloads.txt",                    //Записать информацию о манге название описание
                                   manga.MangaName + "~" + manga.MangaLink + "~" + manga.CurrentChapter + "~" + manga.MangaImage + "~" + manga.MangaLargeImage + "~"
                                   + manga.MangaGenre + "~" + manga.MangaAbout + Environment.NewLine); //записывается один раз
            }

            foreach (string page in mangaPages)                                                                                //Загрузка страниц
            {
                webClient.DownloadFile(page, Environment.CurrentDirectory + "/" + chapter + "/manga" + i.ToString() + ".jpg"); //Скачать страницы главы
                i++;
            }

            //File.AppendAllText(Environment.CurrentDirectory +"/"+manga.CurrentChapter+ "/chapters.txt",
            //    manga.MangaLink + "~" + manga.CurrentChapter+"~"+ + Environment.NewLine);
        }
Exemple #6
0
 /// <summary>
 /// Показать закладки
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ЗакладкиToolStripMenuItem_Click(object sender, EventArgs e)
 {
     section = Section.BookMarks;
     listViewCatalog.Items.Clear();
     string[] infoArr = new string[6];
     HtmlParsing.mangalist.Clear();
     if (File.Exists(Environment.CurrentDirectory + "/bookmarks.txt"))
     {
         using (StreamReader streamReader = new StreamReader(Environment.CurrentDirectory + "/bookmarks.txt"))
         {
             while (!streamReader.EndOfStream)
             {
                 MangaInCatalog manga = new MangaInCatalog();
                 var            str   = streamReader.ReadLine();
                 infoArr           = str.Split('~');
                 manga.MangaName   = infoArr[0];
                 manga.MangaGenre  = infoArr[3];
                 manga.MangaImage  = infoArr[5];
                 manga.MangaLink   = infoArr[4];
                 manga.CurrentPage = Convert.ToInt32(infoArr[2]);
                 var imagename = Environment.CurrentDirectory + "/" + manga.MangaGenre + "/" + manga.MangaLink + ".jpg";
                 Directory.CreateDirectory(Environment.CurrentDirectory + "/" + manga.MangaGenre);
                 if (!File.Exists(imagename))
                 {
                     webClient.DownloadFile(manga.MangaImage, imagename);
                 }
                 var image = Image.FromFile(imagename);
                 imageListCatalog.Images.Add(manga.MangaLink, image);
                 var item = listViewCatalog.Items.Add(manga.MangaName);
                 HtmlParsing.mangalist.Add(manga);
                 item.ImageKey = manga.MangaLink;
             }
         }
     }
     else
     {
         FileStream fs = File.Create(Environment.CurrentDirectory + "/bookmarks.txt");
         fs.Close();
     }
 }
        /// <summary>
        /// ССылки на страницы манги и главу
        /// </summary>
        /// <param name="manga"></param>
        /// <param name="chapter"></param>
        public static void ReadManga(MangaInCatalog manga, string chapter)
        {
            string result;

            webClient = new WebClient();
            result    = webClient.DownloadString(siteRoot + chapter);
            Console.WriteLine(result);
            mangaPages.Clear();
            MatchCollection m = Regex.Matches(result,
                                              @"https:\/\/\w{2,3}\.mangas\.rocks\/(?=\'\,\'https:\/\/h23)");//PARS JPEG PAGES OF MANGA
            // Console.WriteLine(m.Count);
            MatchCollection m2 = Regex.Matches(result, @"auto\/\d*\/\d*\/\d*\/[1\.\w?\-=&]*");

            if (m.Count == 0)
            {
                result = webClient.DownloadString(siteRoot + "/" + chapter + "?mtr=1");
                // Console.WriteLine(result);
                m = Regex.Matches(result,
                                  @"https:\/\/\w{2,3}\.mangas\.rocks\/(?=\'\,\'https:\/\/h23)");//PARS JPEG PAGES OF MANGA
                // Console.WriteLine(m.Count);
                m2 = Regex.Matches(result, @"auto\/\d*\/\d*\/\d*\/[1\.\w?\-=&]*");
            }
            var c = 0;

            Console.WriteLine(m.Count.ToString() + " " + m2.Count.ToString());
            foreach (Match match in m)
            {
                mangaPages.Add(match.Value + m2[c].Value);
                c++;
            }


            foreach (string s in mangaPages)
            {
                Console.WriteLine(s);
            }
        }
        /// <summary>
        /// Вывести в листвью картинки маленькие превьюшки и названия
        /// </summary>
        /// <param name="genrePath"></param>
        public static void GetCoverToList(string genrePath)
        {
            //  WebClient webClient;
            webClient          = new WebClient();
            webClient.Encoding = Encoding.UTF8;
            HtmlParsing.mangalist.Clear();
            MangaInCatalog manga = new MangaInCatalog();

            progressBar.Visible = true;
            progressBar.Value   = 0;
            listViewCatalog.Clear();

            try
            {
                var htmlstring = webClient.DownloadString(HtmlParsing.siteRoot + genrePath);
                //Console.WriteLine(htmlstring);
                MatchCollection m = Regex.Matches(htmlstring,
                                                  @"(?<=href=.)\/[\w_]+.\stitle=..+(?=.>.*<\/a>)");
                foreach (Match match in m)
                {
                    // Console.WriteLine(match.Value);
                }
                Console.WriteLine(m.Count.ToString());
                MatchCollection m2 = Regex.Matches(htmlstring,
                                                   @"(?!data-original=.)https:\/\/static\.readmanga\.me\/uploads\/pics\/\d{2,3}\/\d{2,3}\/\d{2,3}.*.jpg");//картинки
                int      ind      = 0;
                string[] nameLink = new string[2];

                foreach (Match match in m2) //заполнение
                {
                    var cutter = m[ind].Value.Replace("href=", "");
                    manga            = new MangaInCatalog();
                    manga.MangaImage = match.Value;
                    nameLink         = cutter.Split('=');
                    manga.MangaName  = nameLink[1].Remove(0, 1);
                    manga.MangaLink  = nameLink[0].Replace("\" title", "").Remove(0, 1);
                    manga.MangaGenre = genrePath;
                    HtmlParsing.mangalist.Add(manga);
                    ind++;
                }
            }
            catch (WebException)
            {
                MessageBox.Show("Автономная работа");
            }
            // Console.WriteLine(m2.Count.ToString());
            ///конец
            progressBar.Step = Convert.ToInt32(Math.Ceiling((double)100 / 1 + mangalist.Count));
            int index = 0;

            foreach (MangaInCatalog mng in HtmlParsing.mangalist)////Запоолнение листвью
            {
                progressBar.PerformStep();
                var imagename = Environment.CurrentDirectory + "/" + genrePath + "/" + mng.MangaLink + ".jpg";
                Directory.CreateDirectory(Environment.CurrentDirectory + "/" + genrePath);
                if (!File.Exists(imagename))
                {
                    webClient.DownloadFile(mng.MangaImage, imagename);
                }
                var image = Image.FromFile(imagename);
                imageListCatalog.Images.Add(mng.MangaLink, image);

                var item = listViewCatalog.Items.Add(mng.MangaName);
                item.ImageKey = mng.MangaLink;
                index++;
            }
            progressBar.Visible = false;
            progressBar.Value   = 0;
        }