diff --git a/e621 ReBot v3/Modules/CefSharp/Module_CefSharp.cs b/e621 ReBot v3/Modules/CefSharp/Module_CefSharp.cs index f1f7866..27c47f9 100644 --- a/e621 ReBot v3/Modules/CefSharp/Module_CefSharp.cs +++ b/e621 ReBot v3/Modules/CefSharp/Module_CefSharp.cs @@ -8,7 +8,6 @@ using e621_ReBot_v3.CustomControls; using e621_ReBot_v3.Modules.Downloader; using e621_ReBot_v3.Modules.Grabber; -using HtmlAgilityPack; namespace e621_ReBot_v3.Modules { diff --git a/e621 ReBot v3/Modules/Downloader/Module_DLe621.cs b/e621 ReBot v3/Modules/Downloader/Module_DLe621.cs index 924c7f9..7fd45d5 100644 --- a/e621 ReBot v3/Modules/Downloader/Module_DLe621.cs +++ b/e621 ReBot v3/Modules/Downloader/Module_DLe621.cs @@ -55,28 +55,23 @@ internal static void GrabMediaLinks(string WebAddress) SpecialSaveFolder = Module_Downloader.SelectFolderPopup(SpecialSaveFolder); if (WebAddress.Contains("/posts?tags=")) { - if (string.IsNullOrEmpty(AppSettings.APIKey) || HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@class='paginator']/menu").ChildNodes.Count <= 3) + //If there is API key or page navigation has more than 3 buttons (<, 1, >) then grab all + if (!string.IsNullOrEmpty(AppSettings.APIKey) || HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@class='paginator']/menu").ChildNodes.Count > 3) { - goto GrabPageOnly_Tags; - } - - MessageBoxResult MessageBoxResultTemp = Window_Main._RefHolder.Dispatcher.Invoke(() => { return MessageBox.Show(Window_Main._RefHolder, "Do you want to download all images with current tags?\nPress no if you want current page only.", "Download", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); }); - if (MessageBoxResultTemp == MessageBoxResult.Yes) - { - string TagQuery = WebAddress; - TagQuery = TagQuery.Substring(TagQuery.IndexOf("tags=") + 5); + MessageBoxResult MessageBoxResultTemp = Window_Main._RefHolder.Dispatcher.Invoke(() => { return MessageBox.Show(Window_Main._RefHolder, "Do you want to download all images with current tags?\nPress no if you want current page only.", "Download", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); }); + if (MessageBoxResultTemp == MessageBoxResult.Yes) + { + string TagQuery = WebAddress; + TagQuery = TagQuery.Substring(TagQuery.IndexOf("tags=") + 5); - Grab_MediaWithTags(TagQuery, SpecialSaveFolder); - return; - } - else - { - goto GrabPageOnly_Tags; + Grab_MediaWithTags(TagQuery, SpecialSaveFolder); + return; + } } } - GrabPageOnly_Tags: - HtmlNodeCollection NodeSelector = HtmlDocumentTemp.DocumentNode.SelectNodes(".//div[@id='posts-container']/article"); + //If no API key or page navigation has 3 buttons (<, 1, >) then just grab this (single) page + HtmlNodeCollection NodeSelector = HtmlDocumentTemp.DocumentNode.SelectNodes(".//div[@id='posts']/section[@class='posts-container']/article"); if (NodeSelector != null) { foreach (HtmlNode Post in NodeSelector) @@ -107,22 +102,22 @@ internal static void GrabMediaLinks(string WebAddress) case "pools": { HtmlNode BottomMenuHolder = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@class='paginator']/menu"); - if (string.IsNullOrEmpty(AppSettings.APIKey) || BottomMenuHolder.ChildNodes.Count <= 3) - { - goto GrabPageOnly_Pools; - } - MessageBoxResult MessageBoxResultTemp = Window_Main._RefHolder.Dispatcher.Invoke(() => { return MessageBox.Show(Window_Main._RefHolder, "Do you want to download the whole pool?\nPress no if you want current page only.", "Download", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); }); - if (MessageBoxResultTemp == MessageBoxResult.OK) + //If there is API key or page navigation has more than 3 buttons (<, 1, >) then grab all + if (!string.IsNullOrEmpty(AppSettings.APIKey) || BottomMenuHolder.ChildNodes.Count > 3) { - string PoolID = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//li[@id='subnav-show']/a").Attributes["href"].Value; - PoolID = PoolID.Substring(PoolID.LastIndexOf('/') + 1); + MessageBoxResult MessageBoxResultTemp = Window_Main._RefHolder.Dispatcher.Invoke(() => { return MessageBox.Show(Window_Main._RefHolder, "Do you want to download the whole pool?\nPress no if you want current page only.", "Download", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); }); + if (MessageBoxResultTemp == MessageBoxResult.OK) + { + string PoolID = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//li[@id='subnav-show']/a").Attributes["href"].Value; + PoolID = PoolID.Substring(PoolID.LastIndexOf('/') + 1); - Grab_Pool(PoolID); - return; + Grab_Pool(PoolID); + return; + } } - GrabPageOnly_Pools: + //If no API key or page navigation has 3 buttons (<, 1, >) then just grab this (single) page HtmlNodeCollection NodeSelector = HtmlDocumentTemp.DocumentNode.SelectNodes(".//div[@id='a-show']//article"); if (NodeSelector != null) { @@ -173,7 +168,7 @@ internal static void GrabMediaLinks(string WebAddress) case "popular": { - HtmlNodeCollection NodeSelector = HtmlDocumentTemp.DocumentNode.SelectNodes(".//div[@id='posts-container']/article"); + HtmlNodeCollection NodeSelector = HtmlDocumentTemp.DocumentNode.SelectNodes(".//div[@id='posts']/section[@class='posts-container']/article"); if (NodeSelector != null) { SpecialSaveFolder = Module_Downloader.SelectFolderPopup(SpecialSaveFolder); @@ -204,37 +199,37 @@ internal static void GrabMediaLinks(string WebAddress) case "favorites": { SpecialSaveFolder = Module_Downloader.SelectFolderPopup(SpecialSaveFolder); - if (string.IsNullOrEmpty(AppSettings.APIKey) || HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@class='paginator']/menu").ChildNodes.Count <= 3) - { - goto GrabPageOnly_Favorites; - } - MessageBoxResult MessageBoxResultTemp = Window_Main._RefHolder.Dispatcher.Invoke(() => { return MessageBox.Show(Window_Main._RefHolder, "Do you want to download all favorites?\nPress no if you want current page only.", "Download", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); }); - if (MessageBoxResultTemp == MessageBoxResult.Yes) + //If there is API key or page navigation has more than 3 buttons (<, 1, >) then grab all + if (!string.IsNullOrEmpty(AppSettings.APIKey) || HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@class='paginator']/menu").ChildNodes.Count > 3) { - string TagQuery = WebAddress; - if (TagQuery.Contains("user_id")) - { - TagQuery = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//input[@id='tags']").Attributes["value"].Value; - } - else + MessageBoxResult MessageBoxResultTemp = Window_Main._RefHolder.Dispatcher.Invoke(() => { return MessageBox.Show(Window_Main._RefHolder, "Do you want to download all favorites?\nPress no if you want current page only.", "Download", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); }); + if (MessageBoxResultTemp == MessageBoxResult.Yes) { - if (TagQuery.Contains('?')) + string TagQuery = WebAddress; + if (TagQuery.Contains("user_id")) { - TagQuery = TagQuery.Substring(TagQuery.IndexOf("?") + 1); + TagQuery = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//input[@id='tags']").Attributes["value"].Value; } else { - TagQuery = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//input[@id='tags']").Attributes["value"].Value; + if (TagQuery.Contains('?')) + { + TagQuery = TagQuery.Substring(TagQuery.IndexOf("?") + 1); + } + else + { + TagQuery = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//input[@id='tags']").Attributes["value"].Value; + } } - } - Grab_MediaWithTags(TagQuery, SpecialSaveFolder); - return; + Grab_MediaWithTags(TagQuery, SpecialSaveFolder); + return; + } } - GrabPageOnly_Favorites: - HtmlNodeCollection NodeSelector = HtmlDocumentTemp.DocumentNode.SelectNodes(".//div[@id='posts-container']/article"); + //If no API key or page navigation has 3 buttons (<, 1, >) then just grab this (single) page + HtmlNodeCollection NodeSelector = HtmlDocumentTemp.DocumentNode.SelectNodes(".//div[@id='posts']/section[@class='posts-container']/article"); if (NodeSelector != null) { foreach (HtmlNode Post in NodeSelector) diff --git a/e621 ReBot v3/Windows/Window_Main.xaml b/e621 ReBot v3/Windows/Window_Main.xaml index 33d0393..2259d94 100644 --- a/e621 ReBot v3/Windows/Window_Main.xaml +++ b/e621 ReBot v3/Windows/Window_Main.xaml @@ -133,7 +133,7 @@ - + diff --git a/e621 ReBot v3/Windows/Window_PoolWatcher.xaml.cs b/e621 ReBot v3/Windows/Window_PoolWatcher.xaml.cs index 5d5930a..dc4546c 100644 --- a/e621 ReBot v3/Windows/Window_PoolWatcher.xaml.cs +++ b/e621 ReBot v3/Windows/Window_PoolWatcher.xaml.cs @@ -100,7 +100,7 @@ internal static void PoolWatcher_AddPool2Watch() } } - string ThumbnailURL = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@id='posts-container']/article[@id]").Attributes["data-md5"].Value; + string ThumbnailURL = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@id='posts']/section[@class='posts-container']/article[@id]").Attributes["data-md5"].Value; ThumbnailURL = $"https://static1.e621.net/data/preview/{ThumbnailURL.Substring(0, 2)}/{ThumbnailURL.Substring(2, 2)}/{ThumbnailURL}.jpg"; string PoolName = HtmlDocumentTemp.DocumentNode.SelectSingleNode(".//div[@id='c-pools']/div[@id='a-show']/h2/a").InnerText.Trim(); diff --git a/e621 ReBot v3/e621 ReBot v3.csproj b/e621 ReBot v3/e621 ReBot v3.csproj index 6c3405b..a327636 100644 --- a/e621 ReBot v3/e621 ReBot v3.csproj +++ b/e621 ReBot v3/e621 ReBot v3.csproj @@ -11,7 +11,7 @@ Resources\ReBot_Icon.ico x64 False - 3.0.0.43 + 3.0.0.44 e621_ReBot_v3.App False https://github.com/e621-ReBot/e621-ReBot-v3 @@ -177,18 +177,10 @@ - - - - - - - - \ No newline at end of file