Ejemplo n.º 1
0
        public FavoritesViewModel()
        {
            Instance      = this;
            FavoriteItems = new ReadOnlyObservableCollection <HentaiModel>(Favorites);
            foreach (var hentaiModel in Favorites)
            {
                if (hentaiModel.Site == "ExHentai.org")
                {
                    var client = new RestClient {
                        UserAgent =
                            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.70 Safari/537.36",
                        Encoding        = Encoding.UTF8,
                        Timeout         = 60000,
                        BaseUrl         = new Uri(hentaiModel.ThumbnailLink),
                        CookieContainer = ExHentai.GetCookies()
                    };
                    var imgbytes = client.Execute(new RestRequest());
                    try {
                        var img = ExHentai.BytesToBitmapImage(imgbytes.RawBytes);
                        hentaiModel.Img = img;
                    }
                    catch {
//ignore
                    }
                }
                else
                {
                    hentaiModel.Img = hentaiModel.ThumbnailLink;
                }
                hentaiModel.Seen = HistoryController.CheckHistory(hentaiModel.Link);
            }
        }
Ejemplo n.º 2
0
        private async Task LoadExHentaiPageAsync(int value)
        {
            SettingsController.Save();
            var pass    = SettingsController.Settings.ExHentai.IpbPassHash;
            var memid   = SettingsController.Settings.ExHentai.IpbMemberId;
            var igneous = SettingsController.Settings.ExHentai.Igneous;

            if (string.IsNullOrEmpty(memid) || string.IsNullOrEmpty(igneous) || string.IsNullOrEmpty(pass))
            {
                MessageBox.Show("Need Cookies for Exhentai", "Cookies missing", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (ExHentaiPageLoading)
            {
                return;
            }
            ExHentaiPageLoading = true;
            NextExHentaiPage    = NextExHentaiPage + value;
            ExHentaiLoadedPage  = ExHentaiLoadedPage + value;
            if (_exHentai.Count > 0)
            {
                _exHentai.Clear();
            }
            ExHentaiView.Instance.ScrollViewer.ScrollToTop();
            var searchQuery = string.Empty;

            if (!string.IsNullOrEmpty(SettingsController.Settings.ExHentai.SearchQuery))
            {
                searchQuery = SettingsController.Settings.ExHentai.SearchQuery.Replace(" ", "" + "+");
            }
            var i = await ExHentai.GetLatestAsync($"https://exhentai.org/?page={ExHentaiLoadedPage}" +
                                                  $"&f_doujinshi={SettingsController.Settings.ExHentai.Doujinshi}" +
                                                  $"&f_manga={SettingsController.Settings.ExHentai.Manga}" +
                                                  $"&f_artistcg={SettingsController.Settings.ExHentai.ArtistCg}" +
                                                  $"&f_gamecg={SettingsController.Settings.ExHentai.GameCg}" +
                                                  $"&f_western={SettingsController.Settings.ExHentai.Western}" +
                                                  $"&f_non-h={SettingsController.Settings.ExHentai.NonH}" +
                                                  $"&f_imageset={SettingsController.Settings.ExHentai.ImageSet}" +
                                                  $"&f_cosplay={SettingsController.Settings.ExHentai.Cosplay}" +
                                                  $"&f_asianporn={SettingsController.Settings.ExHentai.AsianPorn}" +
                                                  $"&f_misc={SettingsController.Settings.ExHentai.Misc}" +
                                                  $"&f_search={searchQuery}&f_apply=Apply+Filter" +
                                                  $"&advsearch=1&f_sname=on&f_stags=on&f_sr=on" +
                                                  $"&f_srdd={SettingsController.Settings.ExHentai.MinRating}");

            Console.WriteLine(SettingsController.Settings.ExHentai.MinRating);
            foreach (var hentaiModel in i)
            {
                if (FavoritesController.FavoriteMd5s.Contains(hentaiModel.Md5))
                {
                    hentaiModel.Favorite = true;
                }
                _exHentai.Add(hentaiModel);
                await Task.Delay(10);
            }
            ExHentaiPageLoading = false;
        }
        private async Task <List <object> > SelectSiteAsync(HentaiModel hentai)
        {
            switch (hentai.Site)
            {
            case "Hentai.cafe":
            {
                var(paths, count) = await HentaiCafe.CollectImagesTaskAsync(hentai, SetPages);

                Pages = $"{paths.Count} : {count}";
                return(paths);
            }

            case "nHentai.net":
            {
                var(paths, count) = await NHentai.CollectImagesTaskAsync(hentai, SetPages);

                Pages = $"{paths.Count} : {count}";
                return(paths);
            }

            case "ExHentai.org":
            {
                var(paths, count) = await ExHentai.CollectImagesTaskAsync(hentai, SetPages);

                Pages = $"{paths.Count} : {count}";
                return(paths);
            }

            case "Pururin.us":
            {
                var(paths, count) = await Pururin.CollectImagesTaskAsync(hentai, SetPages);

                Pages = $"{paths.Count} : {count}";
                return(paths);
            }

            case "Imgur.com":
            {
                var(paths, count) = await Sites.Imgur.CollectImagesTaskAsync(hentai, SetPages);

                Pages = $"{paths.Count} : {count}";
                return(paths);
            }

            default:
                return(null);
            }
        }