Exemplo n.º 1
0
 private void Hitomi_Download_Click(object sender, RoutedEventArgs e)
 {
     Task.Factory.StartNew(() =>
     {
         string filename = File2.GetDownloadTitle(File2.SaftyFileName(h.name));
         if (!Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}"))
         {
             Directory.CreateDirectory($"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}");
         }
         Directory.CreateDirectory($"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}/{filename}");
         h.dir = $"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}/{filename}";
         h.Save($"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}/{filename}/info.json");
         for (int i = 0; i < h.files.Length; i++)
         {
             string file  = h.files[i];
             WebClient wc = new WebClient();
             wc.Headers.Add("referer", "https://hitomi.la/");
             if (!File.Exists($"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}/{filename}/{i}.jpg"))
             {
                 h.encrypted = Global.AutoFileEn;
                 if (Global.AutoFileEn)
                 {
                     FileEncrypt.DownloadAsync(new Uri(file), $"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}/{filename}/{i}.jpg.lock");
                 }
                 else
                 {
                     wc.DownloadFileAsync(new Uri(file), $"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}/{filename}/{i}.jpg");
                 }
             }
         }
         Process.Start($"{AppDomain.CurrentDomain.BaseDirectory}/{Global.DownloadFolder}/{filename}");
     });
 }
Exemplo n.º 2
0
        private async void DownloadImage_Click(object sender, RoutedEventArgs e)
        {
            bool hiyobi = ftype == Hitomi.Type.Hiyobi;

            if (ftype == Hitomi.Type.Folder)
            {
                bool result = await new InternetP(index: int.Parse(h.id)).isHiyobi();
                hiyobi = result;
            }
            Hitomi h2 = null;

            if (hiyobi)
            {
                h2 = await new HiyobiLoader(text: h.id).Parser();
            }
            if (!hiyobi)
            {
                h2 = await new InternetP(index: int.Parse(h.id)).HitomiData2();
            }
            if (h2 == null)
            {
                return;
            }
            string folder = h.type == Hitomi.Type.Folder ? h.dir : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Global.DownloadFolder, File2.GetDownloadTitle(File2.SaftyFileName(h2.name)));

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            h = h2;
            File.WriteAllText(Path.Combine(folder, "info.json"), JObject.FromObject(h2).ToString());
            foreach (string file in Directory.GetFiles(folder))
            {
                if (file.EndsWith(".lock") || file.EndsWith(".jpg"))
                {
                    File.Delete(file);
                }
            }
            for (int i = 0; i < h2.files.Length; i++)
            {
                string    file = h2.files[i];
                WebClient wc   = new WebClient();
                if (!hiyobi)
                {
                    wc.Headers.Add("referer", "https://hitomi.la/");
                }
                h.encrypted = Global.AutoFileEn;
                if (Global.AutoFileEn)
                {
                    FileEncrypt.DownloadAsync(new Uri(file), $"{folder}/{i}.jpg.lock");
                }
                else
                {
                    wc.DownloadFileAsync(new Uri(file), $"{folder}/{i}.jpg");
                }
                if (i == 0)
                {
                    wc.DownloadFileCompleted += ImageDownloadCompleted;
                }
            }
            Process.Start(folder);
        }
Exemplo n.º 3
0
        private async void DownloadData_Click(object sender, RoutedEventArgs e)
        {
            bool hiyobi = ftype == Hitomi.Type.Hiyobi;

            if (ftype == Hitomi.Type.Folder)
            {
                bool result = await new InternetP(index: int.Parse(h.id)).isHiyobi();
                hiyobi = result;
            }
            if (hiyobi)
            {
                Hitomi h2 = await new HiyobiLoader(text: h.id).Parser();
                if (h2.name == "정보없음" && h2.id == "0")
                {
                    MessageBox.Show("데이터를 받아오는데 실패했습니다.");
                    return;
                }
                string folder = h.dir;
                if (h.type != Hitomi.Type.Folder)
                {
                    folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Global.DownloadFolder, File2.GetDownloadTitle(File2.SaftyFileName(h2.name)));
                }
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                File.WriteAllText(Path.Combine(folder, "info.json"), JObject.FromObject(h2).ToString());
                MessageBox.Show("데이터를 성공적으로 받았습니다.");
                authorsPanel.Children.Clear();
                authorsPanel.Children.Add(new Label {
                    Content = "작가 :"
                });
                tagPanel.Children.Clear();
                Init();
            }
            if (!hiyobi)
            {
                InternetP parser = new InternetP();
                parser.index = int.Parse(h.id);
                Hitomi h2 = await parser.HitomiData2();

                string folder = h.dir;
                if (h.type != Hitomi.Type.Folder)
                {
                    folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Global.DownloadFolder, File2.GetDownloadTitle(File2.SaftyFileName(h2.name)));
                }
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                File.WriteAllText(Path.Combine(folder, "info.json"), JObject.FromObject(h2).ToString());
                MessageBox.Show("데이터를 성공적으로 받았습니다.");
                authorsPanel.Children.Clear();
                authorsPanel.Children.Add(new Label {
                    Content = "작가 :"
                });
                tagPanel.Children.Clear();
                Init();
            }
        }