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}"); }); }
public override void DownloadImage_Click(object sender, RoutedEventArgs e) { base.DownloadImage_Click(sender, e); string filename = CF.File.GetDownloadTitle(CF.File.SaftyFileName(h.name)); for (int i = 0; i < h.files.Length; i++) { Hitomi.HFile file = h.files[i]; WebClient wc = new WebClient(); wc.Headers.Add("referer", "https://hitomi.la/"); string folder = Global.config.download_folder.Get <string>(); if (!File.Exists($"{AppDomain.CurrentDomain.BaseDirectory}/{folder}/{filename}/{i}.jpg")) { bool fileen = Global.config.download_file_encrypt.Get <bool>(); h.FileInfo.encrypted = fileen; string path = $"{AppDomain.CurrentDomain.BaseDirectory}/{folder}/{filename}/{file.name}.{InternetP.GetDirFromHFileS(file)}.lock"; if (fileen) { FileEncrypt.DownloadAsync(wc, new Uri(file.url), path + ".lock"); } else { wc.DownloadFileAsync(new Uri(file.url), path); } } } }
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); }