/// <summary> /// 显示右键菜单并生成信息 /// </summary> public void LoadExtFunc(MoeItem moeItem) { var para = moeItem.Para; var site = para.Site; SpPanel.Children.Clear(); // load choose 首次登场图片 if (site.FuncSupportState.IsSupportSelectPixivRankNew && para.SubMenuIndex == 2) { var b = GetSpButton("全选首次登场图片"); b.Click += (o, args) => { foreach (ImageControl img in ImageItemsWrapPanel.Children) { img.ImageCheckBox.IsChecked = img.ImageItem.Tip == "首次登场"; } ContextMenuPopup.IsOpen = false; }; SpPanel.Children.Add(b); } // load search by author id if (site.FuncSupportState.IsSupportSearchByAuthorId) { var b = GetSpButton($"搜索该作者{moeItem.Uploader}的所有作品"); b.Click += (sender, args) => { SearchByAuthorIdAction?.Invoke(site, moeItem.UploaderId); ContextMenuPopup.IsOpen = false; }; SpPanel.Children.Add(b); } }
public async Task GetUgoiraDetailPageTask(MoeItem img) { if (img.Tip.IsEmpty()) { img.Tip = "动图"; } var net = Net.CloneWithOldCookie(); var api = $"{HomeUrl}/ajax/illust/{img.Id}/ugoira_meta"; var jsonRes = await net.Client.GetAsync(api); var jsonStr = await jsonRes.Content.ReadAsStringAsync(); dynamic json = JsonConvert.DeserializeObject(jsonStr); var img1 = json?.body; var refer = $"{HomeUrl}/artworks/{img.Id}"; if (img1 != null) { //img.Urls.Add(2, $"{img1.src}", refer, UgoiraAfterEffects); img.Urls.Add(3, $"{img1.src}", refer, UgoiraAfterEffects); img.Urls.Add(4, $"{img1.originalSrc}", refer, UgoiraAfterEffects); img.ExtraFile = new TextFileInfo { FileExt = "json", Content = jsonStr }; } }
public async Task GetDetailPageTask(MoeItem img, SearchPara para, CancellationToken token) { var net = Net.CloneWithCookie(); var json = await net.GetJsonAsync($"{HomeUrl}/ajax/illust/{img.Id}/pages", showSearchMessage : false, token : token); var img1 = json?.body?[0]; var refer = $"{HomeUrl}/artworks/{img.Id}"; if (img1 != null) { //img.Urls.Add(2, $"{img1.urls.small}", refer); img.Urls.Add(DownloadTypeEnum.Large, $"{img1.urls.regular}", refer); img.Urls.Add(DownloadTypeEnum.Origin, $"{img1.urls.original}", refer); } var list = (JArray)json?.body; if (list?.Count > 1) { foreach (var item in json.body) { var imgItem = new MoeItem(this, para); //imgItem.Urls.Add(2, $"{img1?.urls.small}", refer); imgItem.Urls.Add(DownloadTypeEnum.Large, $"{img1?.urls.regular}", refer); imgItem.Urls.Add(DownloadTypeEnum.Origin, $"{item?.urls?.original}", refer); img.ChildrenItems.Add(imgItem); } } }
public async Task GetDetailPageTask(MoeItem img, SearchPara para) { var net = Net.CloneWithOldCookie(); var json = await net.GetJsonAsync($"{HomeUrl}/ajax/illust/{img.Id}/pages"); var img1 = json?.body?[0]; var refer = $"{HomeUrl}/artworks/{img.Id}"; if (img1 != null) { //img.Urls.Add(2, $"{img1.urls.small}", refer); img.Urls.Add(3, $"{img1.urls.regular}", refer); img.Urls.Add(4, $"{img1.urls.original}", refer); } var list = (JArray)json?.body; if (list?.Count > 1) { foreach (var item in json.body) { var imgItem = new MoeItem(this, para); //imgItem.Urls.Add(2, $"{img1?.urls.small}", refer); imgItem.Urls.Add(3, $"{img1?.urls.regular}", refer); imgItem.Urls.Add(4, $"{item?.urls?.original}", refer); img.ChildrenItems.Add(imgItem); } } }
public async Task <MoeItems> GetRealPageImagesAsyncFromXml(SearchPara para, CancellationToken token) { var client = new NetOperator(Settings).Client; var query = GetPageQuery(para); var xmlRes = await client.GetAsync(query, token); var xmlStr = await xmlRes.Content.ReadAsStreamAsync(); var xml = XDocument.Load(xmlStr); var imageItems = new MoeItems(); if (xml.Root == null) { return(imageItems); } foreach (var post in xml.Root.Elements()) { token.ThrowIfCancellationRequested(); var img = new MoeItem(this, para); var tags = post.Attribute("tags")?.Value ?? ""; foreach (var tag in tags.Split(' ')) { if (!tag.IsEmpty()) { img.Tags.Add(tag.Trim()); } } img.Id = post.Attribute("id")?.Value.ToInt() ?? 0; img.Width = post.Attribute("width")?.Value.ToInt() ?? 0; img.Height = post.Attribute("height")?.Value.ToInt() ?? 0; img.Uploader = post.Attribute("author")?.Value; img.Source = post.Attribute("source")?.Value; img.IsExplicit = post.Attribute("rating")?.Value.ToLower() != "s"; img.DetailUrl = GetDetailPageUrl(img); img.Date = post.Attribute("created_at")?.Value.ToDateTime(); if (img.Date == null) { img.DateString = post.Attribute("created_at")?.Value; } img.Score = post.Attribute("score")?.Value.ToInt() ?? 0; img.Urls.Add(1, $"{UrlPre}{post.Attribute("preview_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(2, $"{UrlPre}{post.Attribute("sample_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(3, $"{UrlPre}{post.Attribute("jpeg_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(4, $"{UrlPre}{post.Attribute("file_url")?.Value}", img.DetailUrl); img.OriginString = $"{post}"; if (GetDetailTaskFunc != null) { img.GetDetailTaskFunc = async() => await GetDetailTaskFunc(img, para, token); } imageItems.Add(img); } var count = xml.Root.Attribute("count")?.Value.ToInt(); var offset = xml.Root.Attribute("offset")?.Value.ToInt(); Extend.ShowMessage($"共搜索到{count}张图片,当前第{offset+1}张,第{para.PageIndex}页,共{count / para.Count}页", null, Extend.MessagePos.InfoBar); return(imageItems); }
public override async Task <SearchedPage> GetRealPageAsync(SearchPara para, CancellationToken token) { if (!IsUserLogin) { Login(); } var net = Net.CloneWithCookie(); var cat = CustomConfig.Categories[para.Lv2MenuIndex]; var api = para.PageIndex <= 1 ? cat.FirstPageApi : cat.FollowUpPageApi; if (!para.Keyword.IsEmpty() && cat.OverrideSearchApi == null) { api = CustomConfig.SearchApi.Replace("{keyword}", para.Keyword.ToEncodedUrl()); } var rapi = api.Replace("{pagenum}", $"{para.PageIndex}").Replace("{pagenum-1}", $"{para.PageIndex - 1}"); var html = await net.GetHtmlAsync(rapi, token : token); if (html == null) { return(null); } var moes = new SearchedPage(); moes.OriginString = new StringBuilder(html.Text); var pa = cat.OverridePagePara ?? CustomConfig.PagePara; var list = (HtmlNodeCollection)html.DocumentNode.GetValue(pa.ImagesList); if (!(list?.Count > 0)) { return(moes); } foreach (var item in list) { var moe = new MoeItem(this, para); var url = item.GetValue(pa.ImageItemThumbnailUrlFromImagesList); if (url == null) { continue; } var refer = pa.ImageItemThumbnailUrlFromImagesList.Referer; moe.Urls.Add(DownloadTypeEnum.Thumbnail, url, refer); moe.Title = item.GetValue(pa.ImageItemTitleFromImagesList); var detail = item.GetValue(pa.ImageItemDetailUrlFromImagesList); moe.DetailUrl = detail; moe.GetDetailTaskFunc += t => GetDetail(moe.DetailUrl, moe, pa, true, t); if (pa.ImageItemDateTimeFromImagesList != null) { var date = item.GetValue(pa.ImageItemDateTimeFromImagesList); moe.DateString = $"{date}"; } moe.OriginString = item.InnerHtml; moes.Add(moe); } return(moes); }
private void MoeExplorerOnImageItemDownloadButtonClicked(MoeItem item, ImageSource imgSource) { MoeDownloaderControl.Downloader.AddDownload(item, imgSource); var lb = MoeDownloaderControl.DownloadItemsListBox; var ctrl = lb.Items[lb.Items.Count - 1]; lb.ScrollIntoView(ctrl); if (DownloaderMenuCheckBox.IsChecked != false) { return; } DownloaderMenuCheckBox.IsChecked = true; }
/// <summary> /// 显示右键菜单并生成信息 /// </summary> public void LoadExtFunc(MoeItem moeItem) { var para = moeItem.Para; var site = para.Site; SpPanel.Children.Clear(); var items = SelectedImageControls.Where(ctrl => ctrl.RefreshButton.Visibility == Visibility.Visible).ToList(); if (items.Any()) { var b = GetSpButton("刷新未加载的缩略图"); b.Click += (sender, args) => { ContextMenuPopup.IsOpen = false; foreach (var item in items) { _ = item.TryLoad(); } }; SpPanel.Children.Add(b); } // pixiv load choose 首次登场图片 if (site.ShortName == "pixiv" && para.Lv2MenuIndex == 2) { var b = GetSpButton("全选首次登场图片"); b.Click += delegate { ContextMenuPopup.IsOpen = false; foreach (MoeItemControl img in ImageItemsWrapPanel.Children) { img.ImageCheckBox.IsChecked = img.MoeItem.Tip == "首次登场"; } }; SpPanel.Children.Add(b); } // load search by author id if (site.ShortName == "pixiv") { var b = GetSpButton($"搜索该作者{moeItem.Uploader}的所有作品"); b.Click += delegate { SearchByAuthorIdAction?.Invoke(site, moeItem.UploaderId); ContextMenuPopup.IsOpen = false; }; SpPanel.Children.Add(b); } }
public async Task <MoeItems> GetRealPageImagesAsyncFromJson(SearchPara para, CancellationToken token) { var list = await new NetOperator(Settings).GetJsonAsync(GetPageQuery(para), token); return(await Task.Run(() => { token.ThrowIfCancellationRequested(); var imageItems = new MoeItems(); if (list == null) { return imageItems; } foreach (var item in list) { token.ThrowIfCancellationRequested(); var img = new MoeItem(this, para); img.Width = $"{item.image_width}".ToInt(); img.Height = $"{item.image_height}".ToInt(); img.Id = $"{item.id}".ToInt(); img.Score = $"{item.score}".ToInt(); img.Uploader = $"{item.uploader_name}"; foreach (var tag in $"{item.tag_string}".Split(' ').SkipWhile(string.IsNullOrWhiteSpace)) { img.Tags.Add(tag.Trim()); } img.IsExplicit = $"{item.rating}" == "e"; img.DetailUrl = GetDetailPageUrl(img); img.Date = $"{item.created_at}".ToDateTime(); if (img.Date == null) { img.DateString = $"{item.created_at}"; } img.Urls.Add(1, $"{item.preview_file_url}", GetThumbnailReferer(img)); img.Urls.Add(2, $"{item.large_file_url}", GetThumbnailReferer(img)); img.Urls.Add(4, $"{item.file_url}", img.DetailUrl); img.Copyright = $"{item.tag_string_copyright}"; img.Character = $"{item.tag_string_character}"; img.Artist = $"{item.tag_string_artist}"; img.OriginString = $"{item}"; if (GetDetailTaskFunc != null) { img.GetDetailTaskFunc = async() => await GetDetailTaskFunc(img, para, token); } imageItems.Add(img); } return imageItems; }, token)); }
public async Task GetDetailTask(MoeItem img, string id, CancellationToken token = new CancellationToken()) { var api = $"https://api.yuriimg.com/post/{id}"; var json = await Net.GetJsonAsync(api, token); if (json == null) { return; } img.Score = $"{json.praise}".ToInt(); img.Date = $"{json.format_date}".ToDateTime(); img.Urls.Add(4, $"https://i.yuriimg.com/{json.src}"); img.Artist = $"{json.artist?.name}"; img.Uploader = $"{json.user?.name}"; img.UploaderId = $"{json.user?.id}"; foreach (var tag in Extend.GetList(json.tags.general)) { var t = $"{tag.tags?.cn}"; if (!t.IsEmpty()) { img.Tags.Add(t); } } if ($"{json.page_count}".ToInt() > 1) { var q = $"{api}/multi"; var json2 = await Net.GetJsonAsync(q, token); var child1 = new MoeItem(this, img.Para); child1.Width = img.Width; child1.Height = img.Height; foreach (var urlInfo in img.Urls) { child1.Urls.Add(urlInfo); } img.ChildrenItems.Add(child1); foreach (var jitem in Extend.GetList(json2)) { var childImg = new MoeItem(this, img.Para); childImg.Width = $"{jitem.width}".ToInt(); childImg.Height = $"{jitem.height}".ToInt(); //childImg.Urls.Add(4, $"https://i.yuriimg.com/{post.src}/yuriimg.com%20{post.id}%20contain.jpg"); //childImg.Urls.Add(4,null,null,null, ResolveUrlFunc); img.ChildrenItems.Add(childImg); } } }
public override async Task <SearchedPage> GetRealPageAsync(SearchPara para, CancellationToken token) { //var homeUrl = para.IsShowExplicit ? HomeUrl : SafeHomeUrl; var homeUrl = HomeUrl; var pairs = new Pairs { { "page", $"{para.PageIndex}" }, { "limit", $"{para.CountLimit}" }, { "tags", para.Keyword.ToEncodedUrl() } }; var query = $"{homeUrl}/post.json{pairs.ToPairsString()}"; var net = new NetOperator(Settings, this); var json = await net.GetJsonAsync(query, token : token); var imageItems = new SearchedPage(); foreach (var item in Ex.GetList(json)) { var img = new MoeItem(this, para); img.Width = $"{item.width}".ToInt(); img.Height = $"{item.height}".ToInt(); img.Id = $"{item.id}".ToInt(); img.Score = $"{item.score}".ToInt(); img.Uploader = $"{item.author}"; img.UploaderId = $"{item.creator_id}"; foreach (var tag in $"{item.tags}".Split(' ').SkipWhile(string.IsNullOrWhiteSpace)) { img.Tags.Add(tag.Trim()); } img.IsExplicit = $"{item.rating}" == "e"; img.DetailUrl = $"{homeUrl}/post/show/{img.Id}"; img.Date = $"{item.created_at}".ToDateTime(); if (img.Date == null) { img.DateString = $"{item.created_at}"; } img.Urls.Add(DownloadTypeEnum.Thumbnail, $"{item.preview_url}"); img.Urls.Add(DownloadTypeEnum.Medium, $"{item.sample_url}"); img.Urls.Add(DownloadTypeEnum.Origin, $"{item.file_url}", img.DetailUrl, filesize: $"{item.file_size}".ToUlong()); img.Source = $"{item.source}"; img.OriginString = $"{item}"; imageItems.Add(img); } return(imageItems); }
public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token) { if (!_isIdolLogin) { await LoginAsync(token); } if (!_isIdolLogin) { return(new MoeItems()); } var query = $"{_idolQuery}page={para.PageIndex}&limit={para.Count}&tags={para.Keyword.ToEncodedUrl()}"; var list = await Net.GetJsonAsync(query, token); if (list == null) { return new MoeItems { Message = "获取Json失败" } } ; var imgs = new MoeItems(); const string https = "https:"; foreach (var item in list) { var img = new MoeItem(this, para); img.Width = $"{item.width}".ToInt(); img.Height = $"{item.height}".ToInt(); img.Id = $"{item.id}".ToInt(); img.Score = $"{item.fav_count}".ToInt(); img.Uploader = $"{item.uploader_name}"; img.DetailUrl = $"{HomeUrl}/post/show/{img.Id}"; img.Date = $"{item.created_at?.s}".ToDateTime(); foreach (var tag in Extend.GetList(item.tags)) { img.Tags.Add($"{tag.name}"); } img.IsExplicit = $"{item.rating}" == "e"; img.Net = Net.CloneWithOldCookie(); img.Urls.Add(1, $"{https}{item.preview_url}", img.DetailUrl); img.Urls.Add(2, $"{https}{item.sample_url}", img.DetailUrl); img.Urls.Add(4, $"{https}{item.file_url}", img.DetailUrl); img.OriginString = $"{item}"; imgs.Add(img); } return(imgs); }
public ImageControl(Settings settings, MoeItem item) { Settings = settings; ImageItem = item; DataContext = this; InitializeComponent(); MouseEnter += (sender, args) => VisualStateManager.GoToState(this, nameof(MouseOverState), true); MouseLeave += (sender, args) => VisualStateManager.GoToState(this, nameof(NormalState), true); ResolutionBorder.Visibility = item.Site.SupportState.IsSupportResolution ? Visibility.Visible : Visibility.Collapsed; DetailPageLinkButton.Click += (sender, args) => ImageItem.DetailUrl.GoUrl(); RefreshButton.Click += RefreshButtonOnClick; ImageCheckBox.Click += ImageCheckBoxOnClick; }
public async Task GetSearchByKeywordDetailTask(MoeItem img, SearchPara para, CancellationToken token) { var query = $"https://api.vc.bilibili.com/link_draw/v1/doc/detail?doc_id={img.Id}"; var json = await new NetOperator(Settings, this).GetJsonAsync(query, token: token); var item = json.data?.item; if (item == null) { return; } if ((item.pictures as JArray)?.Count > 1) { var i = 0; foreach (var pic in Ex.GetList(item.pictures)) { var child = new MoeItem(this, para); child.Urls.Add(1, $"{pic.img_src}@336w_336h_1e_1c.jpg"); child.Urls.Add(2, $"{pic.img_src}@1024w_768h.jpg"); child.Urls.Add(4, $"{pic.img_src}"); if (i == 0) { img.Width = $"{pic.img_width}".ToInt(); img.Height = $"{pic.img_height}".ToInt(); } img.ChildrenItems.Add(child); i++; } } else if ((item.pictures as JArray)?.Count == 1) { var pic = json.data?.item?.pictures[0]; img.Width = $"{pic?.img_width}".ToInt(); img.Height = $"{pic?.img_height}".ToInt(); img.Urls.Add(4, $"{pic?.img_src}"); } foreach (var tag in Ex.GetList(item.tags)) { img.Tags.Add($"{tag.name}"); } img.Date = $"{json.data?.item?.upload_time}".ToDateTime(); if (img.Date == null) { img.DateString = $"{item.upload_time}"; } }
public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token) { var imgs = new MoeItems(); const string api = "https://capi-v2.sankakucomplex.com"; const string beta = "https://beta.sankakucomplex.com"; Net = Net == null ? new NetDocker(Settings, api) : Net.CloneWithOldCookie(); Net.SetReferer(beta); var pairs = new Pairs { { "lang", "en" }, { "page", $"{para.PageIndex}" }, { "limit", $"{para.Count}" }, { "hide_posts_in_books", "in-larger-tags" }, { "default_threshold", "1" }, { "tags", para.Keyword.ToEncodedUrl() } }; var json = await Net.GetJsonAsync($"{api}/posts", token, pairs); foreach (var jitem in Extend.CheckListNull(json)) { var img = new MoeItem(this, para) { Net = Net.CloneWithOldCookie(), Id = $"{jitem.id}".ToInt(), Width = $"{jitem.width}".ToInt(), Height = $"{jitem.height}".ToInt(), Score = $"{jitem.total_score}".ToInt() }; img.Urls.Add(1, $"{jitem.preview_url}", beta); img.Urls.Add(2, $"{jitem.sample_url}", beta); img.Urls.Add(4, $"{jitem.file_url}", $"{beta}/post/show/{img.Id}"); img.IsExplicit = $"{jitem.rating}" != "s"; img.Date = $"{jitem.created_at?.s}".ToDateTime(); img.Uploader = $"{jitem.author?.name}"; img.DetailUrl = $"{beta}/post/show/{img.Id}"; foreach (var tag in Extend.CheckListNull(jitem.tags)) { img.Tags.Add($"{tag.name_en}"); } img.OriginString = $"{jitem}"; imgs.Add(img); } return(imgs); }
public static async Task GetDetailTask(MoeItem img, SearchPara para, CancellationToken token) { var url = img.DetailUrl; var net = new NetOperator(img.Site.Settings, img.Site); var html = await net.GetHtmlAsync(url, null, false, token); if (html == null) { return; } var nodes = html.DocumentNode; img.Artist = nodes.SelectSingleNode("*//li[@class='tag-type-artist']/a[2]")?.InnerText.Trim(); img.Character = nodes.SelectSingleNode("*//li[@class='tag-type-character']/a[2]")?.InnerText.Trim(); img.Copyright = nodes.SelectSingleNode("*//li[@class='tag-type-copyright']/a[2]")?.InnerText.Trim(); }
public async Task GetDetail(string url, MoeItem father, CustomPagePara pa, bool isFirst, CancellationToken token) { var items = await GetNewItems(url, father, pa, isFirst, token); foreach (var moeItem in items) { father.ChildrenItems.Add(moeItem); } if (isFirst) { var urlinfo = father.ChildrenItems[0]?.DownloadUrlInfo; if (father.ChildrenItems.Count > 0 && urlinfo != null) { father.Urls.Add(urlinfo); } } }
public async Task GetSearchByNewOrHotDetailTask(MoeItem img, CancellationToken token) { var query = $"https://api.vc.bilibili.com/link_draw/v1/doc/detail?doc_id={img.Id}"; var json = await new NetOperator(Settings, this).GetJsonAsync(query, showSearchMessage: false, token: token); var item = json.data?.item; if (item == null) { return; } foreach (var tag in Ex.GetList(item.tags)) { img.Tags.Add($"{tag.name}"); } img.Score = $"{item.vote_count}".ToInt(); }
public async Task GetSearchByNewOrHotDetailTask(MoeItem img, CancellationToken token, SearchPara para) { var query = $"https://api.vc.bilibili.com/link_draw/v1/doc/detail?doc_id={img.Id}"; var json = await new NetDocker(Settings).GetJsonAsync(query, token); var item = json.data?.item; if (item == null) { return; } foreach (var tag in Extend.CheckListNull(item.tags)) { img.Tags.Add($"{tag.name}"); } img.Score = $"{item.vote_count}".ToInt(); }
private void MoeExplorerOnMoeItemPreviewButtonClicked(MoeItem item, ImageSource imgSource) { if (PreviewWindowInstance == null) { PreviewWindowInstance = new PreviewWindow(); PreviewWindowInstance.Owner = this; PreviewWindowInstance.Closed += (sender, args) => PreviewWindowInstance = null; PreviewWindowInstance.Width = Width * 0.85d; PreviewWindowInstance.Height = Height * 0.85d; PreviewWindowInstance.Show(); } else { PreviewWindowInstance.Activate(); } PreviewWindowInstance.Init(item, imgSource); }
public static void Show(PreviewWindow thisWnd, Window wnd, MoeItem moeitem, ImageSource imgSource) { if (thisWnd == null) { thisWnd = new PreviewWindow(); thisWnd.Closed += delegate { thisWnd = null; }; thisWnd.Owner = wnd; thisWnd.Width = wnd.Width * 0.85d; thisWnd.Height = wnd.Height * 0.85d; thisWnd.Show(); } else { thisWnd.Activate(); } thisWnd.Init(moeitem, imgSource); }
public async Task GetDetailLv2(CustomPagePara pa, MoeItem currentItem, UrlInfo urlinfo, CancellationToken token) { var url = currentItem.DetailUrl; var net = Net.CloneWithCookie(); var html = await net.GetHtmlAsync(url, null, false, token); if (pa.DetailLv2ImageOriginUrl != null) { var originUrl = html.DocumentNode.GetValue(pa.DetailLv2ImageOriginUrl); urlinfo.Url = $"{originUrl}"; } if (pa.DetailLv2ImagePreviewUrl != null) { var prevUrl = html.DocumentNode.GetValue(pa.DetailLv2ImagePreviewUrl); currentItem.Urls.Add(DownloadTypeEnum.Medium, $"{prevUrl}"); } }
public async void Init(MoeItem moeitem, ImageSource imgSource) { CurrentMoeItem = moeitem; Settings = moeitem.Site.Settings; var info = CurrentMoeItem.Urls.GetPreview(); if (info == null) { return; } RootGrid.GoElementState(nameof(LoadingBarShowState)); ImageLoadProgressBar.Value = 0; await LoadImageAsync(); RootGrid.GoElementState(nameof(LoadingBarHideState)); InitImagePosition(); }
public void LoadImgInfo(MoeItem item) { ContextMenuImageInfoStackPanel.Children.Clear(); if (item.Id > 0) { GenImageInfoVisual("ID:", $"{item.Id}"); } if (!item.Uploader.IsEmpty()) { GenImageInfoVisual("Uploader:", item.Uploader); if (!item.UploaderId.IsEmpty()) { GenImageInfoVisual("UpID:", item.UploaderId); } } if (!item.Title.IsEmpty()) { GenImageInfoVisual("Title:", item.Title); } if (!item.DateString.IsEmpty()) { GenImageInfoVisual("Date:", item.DateString); } if (item.Tags.Count > 0) { GenImageInfoVisual("Tags:", item.Tags.ToArray()); } if (!item.Artist.IsEmpty()) { GenImageInfoVisual("Artist:", item.Artist); } if (!item.Character.IsEmpty()) { GenImageInfoVisual("Character:", item.Character); } if (!item.Copyright.IsEmpty()) { GenImageInfoVisual("Copyright:", item.Copyright); } if (!item.Source.IsEmpty()) { GenImageInfoVisual("Source:", item.Source); } }
public async Task SearchByKeyword(SearchPara para, MoeItems imgs, CancellationToken token) { const string api = "https://api.bilibili.com/x/web-interface/search/type"; var newOrHotOrder = para.Lv3MenuIndex == 0 ? "pubdate" : "stow"; var drawOrPhotoCatId = para.Lv2MenuIndex == 0 ? "1" : "2"; var pairs = new Pairs { { "search_type", "photo" }, { "page", $"{para.PageIndex}" }, { "order", newOrHotOrder }, { "keyword", para.Keyword.ToEncodedUrl() }, { "category_id", drawOrPhotoCatId } }; var net = new NetOperator(Settings, this); var json = await net.GetJsonAsync(api, pairs, token : token); if (json == null) { return; } foreach (var item in Ex.GetList(json.data?.result)) { var img = new MoeItem(this, para); img.Urls.Add(1, $"{item.cover}@336w_336h_1e_1c.jpg"); img.Urls.Add(2, $"{item.cover}@1024w_768h.jpg"); img.Urls.Add(4, $"{item.cover}"); img.Id = $"{item.id}".ToInt(); img.Score = $"{item.like}".ToInt(); img.Rank = $"{item.rank_offset}".ToInt(); img.Title = $"{item.title}"; img.Uploader = $"{item.uname}"; img.GetDetailTaskFunc = async cancellationToken => await GetSearchByKeywordDetailTask(img, para, cancellationToken); img.DetailUrl = $"https://h.bilibili.com/{img.Id}"; img.OriginString = $"{item}"; imgs.Add(img); } var c = $"{json.data?.numResults}".ToInt(); Ex.ShowMessage($"共搜索到{c}张,已加载至{para.PageIndex}页,共{c / para.CountLimit}页", null, Ex.MessagePos.InfoBar); }
public override async Task <MoeItems> GetRealPageImagesAsync(SearchPara para, CancellationToken token) { if (Net == null) { Net = new NetOperator(Settings, HomeUrl); } const string api = "https://api.yuriimg.com/posts"; var pairs = new Pairs { { "page", $"{para.PageIndex}" }, { "tags", para.Keyword.ToEncodedUrl() } }; var json = await Net.GetJsonAsync(api, token, pairs); if (json?.posts == null) { return(null); } var imgs = new MoeItems(); foreach (var post in json.posts) { var img = new MoeItem(this, para); img.IsExplicit = $"{post.rating}" == "e"; if (CurrentSiteSetting.LoginCookie.IsEmpty() && img.IsExplicit) { continue; } img.Id = $"{post.pid}".ToInt(); img.Sid = $"{post.id}"; img.Width = $"{post.width}".ToInt(); img.Height = $"{post.height}".ToInt(); img.Urls.Add(1, $"https://i.yuriimg.com/{post.src}/yuriimg.com%20{post.id}%20contain.jpg"); img.DetailUrl = $"{HomeUrl}/show/{post.id}"; img.GetDetailTaskFunc = async() => await GetDetailTask(img, $"{post.id}", token); img.OriginString = $"{post}"; imgs.Add(img); } return(imgs); }
public MoeItem GetChildrenItem(HtmlNode img, CustomPagePara pa, MoeItem father) { var newMoeitem = new MoeItem(this, father.Para); if (pa.DetailImageItemOriginUrlFromDetailImagesList != null) { var imgurl = img.GetValue(pa.DetailImageItemOriginUrlFromDetailImagesList); if (imgurl != null) { newMoeitem.Urls.Add(DownloadTypeEnum.Origin, imgurl, referer: pa.DetailImageItemOriginUrlFromDetailImagesList.Referer); } } if (pa.DetailImageItemThumbnailUrlFromDetailImagesList != null) { var imgurl = img.GetValue(pa.DetailImageItemThumbnailUrlFromDetailImagesList); if (imgurl != null) { newMoeitem.Urls.Add(DownloadTypeEnum.Thumbnail, imgurl, referer: pa.DetailImageItemThumbnailUrlFromDetailImagesList.Referer); } } if (pa.DetailImageItemDetailUrlFromDetailImagesList != null) { var imgurl = img.GetValue(pa.DetailImageItemDetailUrlFromDetailImagesList); if (imgurl != null) { newMoeitem.DetailUrl = $"{imgurl}"; var url = new UrlInfo(DownloadTypeEnum.Origin, "", resolveUrlFunc: (item, url, token) => GetDetailLv2(pa, item, url, token)); newMoeitem.Urls.Add(url); } } return(newMoeitem); }
public async Task GetDetailTask(MoeItem img) { var detialurl = img.DetailUrl; var net = Net.CloneWithOldCookie(); net.SetTimeOut(30); try { var subdoc = await net.GetHtmlAsync(detialurl); var docnodes = subdoc.DocumentNode; if (docnodes == null) { return; } var downnode = docnodes.SelectSingleNode("//*[@id='rating']/a[@class='download_icon']"); var fileurl = downnode?.GetAttributeValue("href", ""); if (!fileurl.IsEmpty()) { img.Urls.Add(4, $"{HomeUrl}{fileurl}", detialurl); } var tagnodes = docnodes.SelectNodes("*//div[@id='post_tags']//a"); if (tagnodes != null) { foreach (var tagnode in tagnodes) { if (!tagnode.InnerText.IsEmpty()) { img.Tags.Add(tagnode.InnerText); } } } } catch (Exception e) { Extend.Log(e, e.StackTrace); } }
public async Task GetDetailTask(MoeItem img, CancellationToken token) { var detialurl = img.DetailUrl; var net = GetCloneNet(timeout: 30); try { var subdoc = await net.GetHtmlAsync(detialurl, null, false, token); var docnodes = subdoc.DocumentNode; if (docnodes == null) { return; } var downnode = docnodes.SelectSingleNode("//*[@id='rating']/a[@class='download_icon']"); var fileurl = downnode?.GetAttributeValue("href", ""); if (!fileurl.IsEmpty()) { img.Urls.Add(DownloadTypeEnum.Origin, $"{HomeUrl}{fileurl}", detialurl); } var tagnodes = docnodes.SelectNodes("*//div[@id='post_tags']//a"); if (tagnodes != null) { foreach (var tagnode in tagnodes) { if (!tagnode.InnerText.IsEmpty()) { img.Tags.Add(tagnode.InnerText); } } } } catch (Exception e) { Ex.Log(e, e.StackTrace); } }
public override async Task <bool> StarAsync(MoeItem moe, CancellationToken token) { var net = CloneNet(); net.SetReferer(BetaApi); var res = await net.PostAsync($"https://capi-v2.sankakucomplex.com/posts/{moe.Id}/favorite?lang=en", token : token); var job = res as JObject; var b = job?["success"]?.Value <bool?>(); if (b == true) { moe.IsFav = true; var count = job["score"]?.Value <int>(); if (count != null) { moe.FavCount = count.Value; } return(true); } return(false); }