コード例 #1
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();
            }
        }
コード例 #2
0
 public MainWindow()
 {
     Hitomi      = new Hitomi();
     DataContext = Hitomi;
     InitializeComponent();
     Loaded += MainWindow_Loaded;
 }
コード例 #3
0
ファイル: HitomiPanel.cs プロジェクト: 2dongsik2/HitomiViewer
        public override async void HitomiPanel_Loaded(object sender, RoutedEventArgs e)
        {
            this.nameLabel.Content = h.name + " (로딩중)";
            InternetP parser = new InternetP();

            parser.index = int.Parse(h.id);
            h            = await parser.HitomiData();

            //h = await parser.HitomiData2(h, int.Parse(h.id));
            if (Global.config.origin_thumb.Get <bool>() && h.files != null && h.files.Length >= 1 && h.files[0] != null)
            {
                this.pageLabel.Content = h.files.Length;
                this.nameLabel.Content = h.name + " (썸네일 로딩중)";
                ImageProcessor.ProcessAsync(h.files[0].url).then((byte[] image) =>
                {
                    h.thumbnail.preview_img = image;
                    base.h = this.h;
                    this.nameLabel.Content = h.name;
                }, null, sourceName: MethodBase.GetCurrentMethod().FullName());
            }
            else
            {
                var preview_image = await ImageProcessor.ProcessAsync(h.thumbnail.preview_url).@catch(null, MethodBase.GetCurrentMethod().FullName());

                h.thumbnail.preview_img = preview_image;
                base.h = this.h;
                this.nameLabel.Content = h.name;
            }
            BitmapImage image = h.thumbnail.preview_img.ToImage();

            thumbNail.Source       = image;
            thumbBrush.ImageSource = image;
            thumbNail.MouseEnter  += (object _, MouseEventArgs __) => thumbNail.ToolTip = GetToolTip(panel.Height);
            Init();
        }
コード例 #4
0
        private async void HitomiPanel_Loaded(object sender, RoutedEventArgs e)
        {
            if (!afterLoad)
            {
                return;
            }
            if (h.type == Hitomi.Type.Hiyobi)
            {
                this.nameLabel.Content = h.name + " (로딩중)";
                h.files = new string[0];
                InternetP parser = new InternetP(index: int.Parse(h.id));
                this.h.files           = (await parser.HiyobiFiles()).Select(x => x.url).ToArray();
                this.h.page            = h.files.Length;
                this.nameLabel.Content = h.name;
                Init();
            }
            if (h.type == Hitomi.Type.Hitomi)
            {
                this.nameLabel.Content = h.name + " (로딩중)";
                InternetP parser = new InternetP();
                parser.url = $"https://ltn.hitomi.la/galleries/{h.id}.js";
                JObject info = await parser.HitomiGalleryInfo();

                h.type  = Hitomi.Type.Hitomi;
                h.tags  = parser.HitomiTags(info);
                h.files = parser.HitomiFiles(info).ToArray();
                h.page  = h.files.Length;
                h.thumb = ImageProcessor.LoadWebImage("https:" + h.thumbpath);
                h.Json  = info;
                h       = await parser.HitomiGalleryData(h);

                this.nameLabel.Content = h.name;
                Init();
            }
        }
コード例 #5
0
ファイル: FileLoader.cs プロジェクト: 2dongsik2/HitomiViewer
        private void CheckType(JObject data, string path, int index, int length)
        {
            if (data["thumb"] != null)
            {
                DeprecatedFile(data, index, length);
                return;
            }
            int?type = (int?)(data["fileType"] ?? data["type"]);

            switch (type)
            {
            case (int)IHitomi.HFileType.Hitomi:
                Hitomi hitomi = data.ToObject <Hitomi>();
                hitomi.FileInfo.dir = path;
                hitomiupdate(hitomi, index, length);
                break;

            case (int)IHitomi.HFileType.Hiyobi:
                HiyobiGallery hiyobi = data.ToObject <HiyobiGallery>();
                hiyobi.FileInfo.dir = path;
                hiyobiupdate(hiyobi, index, length);
                break;

            default:
                PluginHandler.FireUnknownFileLoaded(type ?? 0, data);
                break;
            }
        }
コード例 #6
0
        private void Folder_Hiyobi_Search_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.MainPanel.Children.Clear();
            MainWindow.label.Visibility = Visibility.Visible;
            MainWindow.label.FontSize   = 100;
            InternetP parser = new InternetP();

            parser.keyword = h.name.Replace("|", "|").Split(' ').ToList();
            parser.index   = 1;
            parser.HiyobiSearch(data => new InternetP(data: data).ParseJObject(async jobject =>
            {
                MainWindow.label.Content = 0 + "/" + jobject["list"].ToList().Count;
                foreach (JToken tk in jobject["list"])
                {
                    MainWindow.label.Content = jobject["list"].ToList().IndexOf(tk) + "/" + jobject["list"].ToList().Count;
                    parser      = new InternetP();
                    parser.url  = $"https://cdn.hiyobi.me/data/json/{tk["id"]}_list.json";
                    JArray imgs = await parser.TryLoadJArray();
                    if (imgs == null)
                    {
                        continue;
                    }
                    Hitomi h = new Hitomi
                    {
                        id        = tk["id"].ToString(),
                        name      = tk["title"].ToString(),
                        dir       = $"https://hiyobi.me/reader/{tk["id"]}",
                        page      = imgs.Count,
                        thumbpath = $"https://cdn.hiyobi.me/tn/{tk["id"]}.jpg",
                        thumb     = await ImageProcessor.LoadWebImageAsync($"https://cdn.hiyobi.me/tn/{tk["id"]}.jpg"),
                        type      = Hitomi.Type.Hiyobi
                    };
                    Int64 size    = 0;
                    h.files       = imgs.ToList().Select(x => $"https://cdn.hiyobi.me/data/{tk["id"]}/{x["name"]}").ToArray();
                    h.FolderByte  = size;
                    h.SizePerPage = size / imgs.Count;
                    foreach (JToken tags in tk["tags"])
                    {
                        Tag tag = new Tag();
                        if (tags["value"].ToString().Contains(":"))
                        {
                            tag.types = (Tag.Types)Enum.Parse(typeof(Tag.Types), tags["value"].ToString().Split(':')[0]);
                            tag.name  = tags["display"].ToString();
                        }
                        else
                        {
                            tag.types = Structs.Tag.Types.tag;
                            tag.name  = tags["display"].ToString();
                        }
                        h.tags.Add(tag);
                    }
                    MainWindow.MainPanel.Children.Add(new HitomiPanel(h, MainWindow));
                    Console.WriteLine($"Completed: https://cdn.hiyobi.me/tn/{tk["id"]}.jpg");
                }
                MainWindow.label.Visibility = Visibility.Hidden;
            }));
        }
コード例 #7
0
 public HitomiReader(Hitomi hitomi)
 {
     this.Background = new SolidColorBrush(Global.background);
     this.hitomi     = hitomi;
     this.window     = Global.MainWindow;
     this.page       = 0;
     this.images     = new BitmapImage[hitomi.files.Length];
     InitializeComponent();
     Init();
 }
コード例 #8
0
        public async Task <Hitomi> HiyobiDataNumber(int?index = null)
        {
            url = $"https://api.hiyobi.me/gallery/{index ?? this.index}";
            JObject obj = await LoadJObject();

            Hitomi h = HiyobiParse(obj);

            h.type = Hitomi.Type.Hiyobi;
            return(h);
        }
コード例 #9
0
        /// <summary>
        /// Hiyobi 에서 불러올 수 있는지와 불러올 수 있다면 Hitomi 데이터까지 반환합니다.
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public async Task <Tuple <bool, Hitomi> > isHiyobiData(int?index = null)
        {
            try
            {
                Hitomi h = await HiyobiDataNumber(index);

                return(new Tuple <bool, Hitomi>(true, h));
            }
            catch { return(new Tuple <bool, Hitomi>(false, null)); }
        }
コード例 #10
0
ファイル: HitomiPanel.cs プロジェクト: 2dongsik2/HitomiViewer
 public HitomiPanel(Hitomi h, bool large = true, bool file = false, bool blur = false)
 {
     this.large = large;
     this.file  = file;
     this.blur  = blur;
     this.h     = h;
     base.h     = this.h;
     InitializeComponent();
     Init();
     InitEvent();
 }
コード例 #11
0
 public HitomiPanel(Hitomi h, MainWindow sender, bool large = false, bool afterLoad = false, bool blur = false)
 {
     this.large      = large;
     this.afterLoad  = afterLoad;
     this.blur       = blur;
     this.h          = h;
     this.thumb      = h.thumb;
     this.MainWindow = sender;
     InitializeComponent();
     Init();
     InitEvent();
 }
コード例 #12
0
ファイル: FileLoader.cs プロジェクト: 2dongsik2/HitomiViewer
        private void DeprecatedFile(JObject data, int index, int length)
        {
            int?type = (int?)(data["fileType"] ?? data["type"]);

            if (type == 1 || type == 2)
            {
                Hitomi h = new Hitomi();
                h.id   = data.Value <string>("id");
                h.name = data.Value <string>("name") + " (다시 다운로드가 필요함)";
                h.thumbnail.preview_url = data.Value <string>("thumbpath");
                h.files = new Hitomi.HFile[0];
                hitomiupdate(h, index, length);
            }
        }
コード例 #13
0
        public async Task <List <Hitomi> > HiyobiList()
        {
            List <Hitomi> output = new List <Hitomi>();

            url = $"https://api.hiyobi.me/list/{index}";
            JObject obj = await LoadJObject();

            foreach (JToken item in obj["list"])
            {
                Hitomi h = HiyobiParse(item);
                h.type = Hitomi.Type.Hiyobi;
                output.Add(h);
            }
            return(output);
        }
コード例 #14
0
ファイル: InternetP.cs プロジェクト: rednoam/HitomiViewer
        public async Task <Hitomi> HitomiData2()
        {
            url = $"https://ltn.hitomi.la/galleryblock/{index}.html";
            Hitomi h = await HitomiData();

            url = $"https://ltn.hitomi.la/galleries/{index}.js";
            JObject info = await HitomiGalleryInfo();

            h.type  = Hitomi.Type.Hitomi;
            h.tags  = HitomiTags(info);
            h.files = HitomiFiles(info).ToArray();
            h.page  = h.files.Length;
            h.thumb = ImageProcessor.LoadWebImage("https:" + h.thumbpath);
            h.Json  = info;
            return(await HitomiGalleryData(h));
        }
コード例 #15
0
ファイル: InternetP.cs プロジェクト: rednoam/HitomiViewer
        public async Task <Hitomi> HitomiData()
        {
            url = url ?? $"https://ltn.hitomi.la/galleryblock/{index}.html";
            string html = await Load(url);

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);
            Hitomi h = new Hitomi();

            h.dir = $"https://hitomi.la/reader/{index}.html";
            //h.dir = url;
            HtmlNode name = doc.DocumentNode.SelectSingleNode("//h1[@class=\"lillie\"]");

            h.name = name.InnerText;
            HtmlNode image = doc.DocumentNode.SelectSingleNode("//div[@class=\"dj-img1\"]/img");

            image       = image ?? doc.DocumentNode.SelectSingleNode("//div[@class=\"cg-img1\"]/img");
            h.thumbpath = image.GetAttributeValue("src", "");
            if (h.thumbpath == "")
            {
                h.thumbpath = image.GetDataAttribute("src").Value;
            }
            //HtmlNode artist = doc.DocumentNode.SelectSingleNode("//div[@class=\"artist-list\"]/ul");
            HtmlNodeCollection artists = doc.DocumentNode.SelectNodes("//div[@class=\"artist-list\"]/ul/li");

            if (artists != null)
            {
                h.authors = artists.Select(x => x.InnerText).ToArray();
                h.author  = string.Join(", ", h.authors);
            }
            else
            {
                h.authors = new string[0];
                h.author  = "";
            }
            HtmlNode table = doc.DocumentNode.SelectSingleNode("//table[@class=\"dj-desc\"]");

            for (var i = 0; i < table.ChildNodes.Count - 1; i += 2)
            {
                HtmlNode tr     = table.ChildNodes[i + 1];
                string   trname = tr.ChildNodes[0].InnerHtml;
                string   trtext = tr.ChildNodes[tr.ChildNodes.Count / 2].InnerHtml.Trim();
            }
            return(h);
        }
コード例 #16
0
        public Hitomi HiyobiParse(JToken item)
        {
            Hitomi h = new Hitomi();

            h.authors  = item["artists"].Select(x => x.StringValue("display")).ToArray();
            h.id       = item.StringValue("id");
            h.language = item.StringValue("language");
            h.tags     = item["tags"].Select(x => new Tag {
                name = x.StringValue("display"), types = Tag.ParseTypes(x.StringValue("value"))
            }).ToList();
            h.name       = item.StringValue("title");
            h.designType = DesignTypeFromString(item.StringValue("type"));
            h.thumbpath  = $"https://cdn.hiyobi.me/tn/{h.id}.jpg";
            h.thumb      = ImageProcessor.LoadWebImage(h.thumbpath);
            h.dir        = $"https://hiyobi.me/reader/{h.id}";
            h.page       = 0;
            h.AutoAuthor();
            return(h);
        }
コード例 #17
0
ファイル: InternetP.cs プロジェクト: rednoam/HitomiViewer
        public async Task <Hitomi> HitomiGalleryData(Hitomi org)
        {
            JObject jObject = await HitomiGalleryInfo();

            List <HitomiFile> files = new List <HitomiFile>();

            foreach (JToken tag1 in jObject["files"])
            {
                files.Add(new HitomiFile
                {
                    hash    = tag1["hash"].ToString(),
                    name    = tag1["name"].ToString(),
                    hasavif = Convert.ToBoolean(int.Parse(tag1["hasavif"].ToString())),
                    haswebp = Convert.ToBoolean(int.Parse(tag1["haswebp"].ToString()))
                });
            }
            org.language   = jObject.StringValue("language");
            org.id         = jObject.StringValue("id");
            org.designType = DesignTypeFromString(jObject.StringValue("type"));
            return(org);
        }
コード例 #18
0
 public static void Update(Hitomi h, int index, int max)
 {
     Global.MainWindow.label.Content = $"{index}/{max}";
     Global.MainWindow.MainPanel.Children.Add(new UserControls.Panels.HitomiPanel(h));
 }
コード例 #19
0
 public static Hitomi Copy(this Hitomi hitomi)
 {
     return(Hitomi.Copy(hitomi));
 }
コード例 #20
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);
        }
コード例 #21
0
ファイル: InternetP.cs プロジェクト: rednoam/HitomiViewer
        public async Task <List <Hitomi> > LoadCompre(List <string> items)
        {
            List <Hitomi> res = new List <Hitomi>();

            start(items.Count);
            foreach (string item in items)
            {
                if (item.isUrl())
                {
                    Uri uri = new Uri(item);
                    if (uri.Host == "hiyobi.me")
                    {
                        string id = Path.GetFileNameWithoutExtension(uri.AbsolutePath);
                        Hitomi h  = await new HiyobiLoader(text: id).Parser();
                        res.Add(h);
                        update(h, items.IndexOf(item), items.Count);
                    }
                    if (uri.Host == "hitomi.la")
                    {
                        string id = Path.GetFileNameWithoutExtension(uri.AbsolutePath);
                        this.url   = $"https://ltn.hitomi.la/galleryblock/{id}.html";
                        this.index = int.Parse(id);
                        Hitomi h = await HitomiData();

                        this.url = $"https://ltn.hitomi.la/galleries/{id}.js";
                        JObject info = await HitomiGalleryInfo();

                        h.type  = Hitomi.Type.Hitomi;
                        h.tags  = HitomiTags(info);
                        h.files = HitomiFiles(info).ToArray();
                        h.page  = h.files.Length;
                        h.thumb = await ImageProcessor.LoadWebImageAsync("https:" + h.thumbpath);

                        update(h, items.IndexOf(item), items.Count);
                    }
                }
                else
                {
                    var      allowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".lock" };
                    string[] innerFiles        = Directory.GetFiles(item).Where(file => allowedExtensions.Any(file.ToLower().EndsWith)).ToArray().ESort();
                    if (innerFiles.Length <= 0)
                    {
                        continue;
                    }
                    Hitomi h = new Hitomi
                    {
                        name        = item.Split(Path.DirectorySeparatorChar).Last(),
                        dir         = item,
                        page        = innerFiles.Length,
                        files       = innerFiles,
                        thumb       = await ImageProcessor.ProcessEncryptAsync(innerFiles.First()),
                        type        = Hitomi.Type.Folder,
                        FolderByte  = File2.GetFolderByte(item),
                        SizePerPage = File2.GetSizePerPage(item)
                    };
                    update(h, items.IndexOf(item), items.Count);
                }
            }
            end();
            return(res);
        }