예제 #1
0
        public async Task <SearchComicResult> SearchAsync(string keywork, int skip, int take)
        {
            var targetUrl = string.Format(searchUrl, keywork);
            var req       = new RequestSettings
            {
                Address  = targetUrl,
                Host     = "www.dm5.com",
                Referrer = "http://www.dm5.com/"
            };
            var str = await networkAdapter.GetStringAsync(req);

            var html = new HtmlDocument();

            html.LoadHtml(str);
            var box = html.DocumentNode.SelectNodes("//div[@class='box-body']/ul/li/div[@class='mh-item']");
            var sns = new List <ComicSnapshot>();
            var res = new SearchComicResult
            {
                Total   = box.Count,
                Support = true
            };

            foreach (var item in box.Skip(skip).Take(take))
            {
                var converBox      = item.SelectSingleNode("p").Attributes["style"].Value;
                var converBoxLeft  = converBox.IndexOf('(');
                var converBoxRight = converBox.LastIndexOf(')');
                var conver         = converBox.Substring(converBoxLeft + 1, converBoxRight - converBoxLeft - 1);

                var detail   = item.SelectSingleNode("div[@class='mh-item-detali']");
                var titleBox = detail.SelectSingleNode("h2[@class='title']/a");
                var title    = titleBox.InnerText?.Trim();
                var url      = "http://www.dm5.com" + titleBox.Attributes["href"].Value;

                var tipDetail = item.SelectSingleNode("div[@class='mh-tip-wrap']/div[@class='mh-item-tip']/div[@class='mh-item-tip-detali']");
                var desc      = tipDetail.SelectSingleNode("div[@class='desc']");
                var auth      = tipDetail.SelectSingleNode("p[@class='author']/span/a").InnerText;
                var sn        = new ComicSnapshot
                {
                    Author    = auth,
                    Descript  = desc.InnerText,
                    ImageUri  = conver,
                    Name      = title,
                    TargetUrl = targetUrl,
                    Sources   = new ComicSource[]
                    {
                        new ComicSource
                        {
                            TargetUrl = url,
                            Name      = "Dm5"
                        },
                    },
                };
                sns.Add(sn);
            }
            res.Snapshots = sns.ToArray();
            return(res);
        }
예제 #2
0
        public async Task <SearchComicResult> SearchAsync(string keywork, int skip, int take)
        {
            var page = 1;

            if (take != 0)
            {
                page = Math.Max(1, skip / take);
            }
            var targetUrl = string.Format(url, keywork, page, take);
            var setting   = new RequestSettings
            {
                Address  = targetUrl,
                Referrer = "https://www.kuaikanmanhua.com/"
            };
            var datas = await networkAdapter.GetStringAsync(setting);

            using (var visit = JsonVisitor.FromString(datas))
            {
                var hit = visit["data"]["hit"].ToArray();
                var res = new SearchComicResult
                {
                    Total   = hit.Count(),
                    Support = true
                };
                var sns = new List <ComicSnapshot>();
                foreach (var item in hit)
                {
                    var conv  = item["vertical_image_url"].ToString();
                    var title = item["title"].ToString();
                    var id    = item["id"].ToString();
                    var desc  = item["description"].ToString();
                    var user  = item["user"]["nickname"].ToString();
                    var sn    = new ComicSnapshot
                    {
                        Author    = user,
                        Descript  = desc,
                        ImageUri  = conv,
                        Name      = title,
                        TargetUrl = targetUrl,
                        Sources   = new ComicSource[]
                        {
                            new ComicSource
                            {
                                TargetUrl = "https://www.kuaikanmanhua.com/web/topic/" + id,
                                Name      = "Kuaikan"
                            }
                        }
                    };
                    sns.Add(sn);
                }
                res.Snapshots = sns.ToArray();
                return(res);
            }
        }
예제 #3
0
 public ComicSourceInfo(ComicSnapshot snapshot,
                        ComicSource source,
                        IComicSourceCondition condition)
 {
     Snapshot     = snapshot;
     Source       = source;
     Condition    = condition;
     CanParse     = !(condition is null);
     WatchCommand = new RelayCommand(Watch);
     CopyCommand  = new RelayCommand(Copy);
     OpenCommand  = new AsyncRelayCommand(OpenAsync);
 }
예제 #4
0
 public StorableComicSourceInfo(ComicSnapshot snapshot,
                                ComicSource source,
                                IComicSourceCondition condition,
                                TStoreBox storeBox)
     : base(snapshot, source, condition)
 {
     StoreBox = storeBox;
     HasBox   = storeBox != null;
     CanStore = condition != null;
     ToggleSuperFavoriteCommand = new RelayCommand(ToggleSuperFavorite);
     AddCommand    = new AsyncRelayCommand(AddAsync);
     RemoveCommand = new RelayCommand(Remove);
     ToggleCommand = new AsyncRelayCommand(ToggleAsync);
     StoreService  = AppEngine.GetRequiredService <ComicStoreService <TStoreBox> >();
 }
예제 #5
0
 protected override ComicSnapshotInfo <WithImageStorableComicSourceInfo <ImageResource, ImageSource> > CreateSnapshotInfo(ComicSnapshot info)
 {
     return(new WithImageComicSnapshotInfo <ImageResource, ImageSource>(info, networkAdapter));
 }
예제 #6
0
 public WithImageComicSnapshotInfo(ComicSnapshot snapshot, INetworkAdapter networkAdapter)
     : base(snapshot)
 {
     InitLogoImage();
 }
예제 #7
0
 public MAUIComicViewModel(ComicSnapshot snapshot, ImageSource logoImage)
     : base(snapshot)
 {
     LogoImage            = logoImage;
     SaveLogoImageCommand = new RelayCommand(SaveLogoImage);
 }
예제 #8
0
 public MAUIComicViewModel(ComicSnapshot snapshot)
     : base(snapshot)
 {
     SaveLogoImageCommand = new RelayCommand(SaveLogoImage);
     InitLogoImage();
 }
예제 #9
0
        protected override WithImageStorableComicSourceInfo <TResource, TImage> CreateSourceInfo(ComicSnapshot snapshot, ComicSource source, ComicEngine engine)
        {
            var store = AppEngine.GetRequiredService <WithImageComicStoreService <TResource, TImage> >();
            var box   = store.GetStoreBox(source.TargetUrl);

            return(new WithImageStorableComicSourceInfo <TResource, TImage>(snapshot, source, engine.GetComicSourceProviderType(source.TargetUrl), box));
        }
예제 #10
0
 public WithImageStorableComicSourceInfo(ComicSnapshot snapshot, ComicSource source, IComicSourceCondition condition, WithImageComicStoreBox <TResource, TImage> storeBox) : base(snapshot, source, condition, storeBox)
 {
 }
예제 #11
0
        public async Task <SearchComicResult> SearchAsync(string keywork, int skip, int take)
        {
            var page = 1;

            if (skip != 0 && skip > take)
            {
                page = take / skip;
            }
            var    targetUrl = string.Format(SeachUrl, page, take, keywork);
            string str       = string.Empty;

            using (var rep = await networkAdapter.GetStreamAsync(new RequestSettings {
                Address = targetUrl
            }))
                using (var sr = new StreamReader(rep))
                {
                    str = sr.ReadToEnd();
                }
            var visitor = JsonVisitor.FromString(str);

            try
            {
                var total = int.Parse(visitor["Total"].ToString());
                var items = visitor["Items"].ToArray();
                var snaps = new List <ComicSnapshot>();
                foreach (var item in items)
                {
                    var comic = item["Comics"].ToArray();
                    if (!comic.Any())
                    {
                        continue;
                    }
                    var sn      = new ComicSnapshot();
                    var sources = new List <ComicSource>();
                    foreach (var c in comic)
                    {
                        var host   = c["Host"];
                        var part   = c["Url"];
                        var name   = c["Source"];
                        var source = new ComicSource
                        {
                            Name      = name.ToString(),
                            TargetUrl = host.ToString() + part.ToString()
                        };
                        sources.Add(source);
                    }
                    var first = comic.First();
                    sn.Name      = first["SomanId"].ToString();
                    sn.ImageUri  = first["PicUrl"].ToString();
                    sn.Author    = first["Author"].ToString();
                    sn.Descript  = first["Content"].ToString();
                    sn.TargetUrl = targetUrl;
                    sn.Sources   = sources.ToArray();
                    snaps.Add(sn);
                }
                return(new SearchComicResult
                {
                    Snapshots = snaps.ToArray(),
                    Support = true,
                    Total = total
                });
            }
            finally
            {
                visitor.Dispose();
            }
        }
예제 #12
0
 public ComicSnapshotInfo(ComicSnapshot snapshot) : base(snapshot)
 {
 }
예제 #13
0
        public async Task <ComicSnapshot[]> GetProposalAsync(int take)
        {
            var str = string.Empty;

            using (var stream = new StreamReader(await GetStreamAsync(Home)))
            {
                str = stream.ReadToEnd();
            }
            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(str);
            var sns = new List <ComicSnapshot>();

            void Fetch(int index)
            {
                if (sns.Count >= take)
                {
                    return;
                }
                var roots = htmlDoc.DocumentNode.SelectNodes($"//div[@id='index-update-{index}']/div/ul/li/div/div[@class='mh-tip-wrap']/div");

                foreach (var root in roots)
                {
                    if (sns.Count >= take)
                    {
                        return;
                    }
                    var a = root.SelectSingleNode("a");

                    var addr = a.Attributes["href"].Value;

                    var coverBlock = root.SelectSingleNode("a/p");
                    var cover      = coverBlock.Attributes["style"].Value;
                    var coverLeft  = cover.IndexOf('(');
                    var coverRight = cover.LastIndexOf(')');
                    var coverAddr  = cover.Substring(coverLeft + 1, coverRight - coverLeft - 1);

                    var titleBlock = root.SelectSingleNode("div[@class='mh-item-tip-detali']/h2/a");
                    var title      = titleBlock.Attributes["title"].Value;

                    var authBlock = root.SelectSingleNode("div[@class='mh-item-tip-detali']/p[@class='author']/span/a");
                    var auth      = authBlock.InnerText?.Trim();

                    var descBlock = root.SelectSingleNode("div[@class='mh-item-tip-detali']/div[@class='desc']");
                    var desc      = descBlock.InnerText.Trim();

                    var sn = new ComicSnapshot
                    {
                        Author    = auth,
                        Descript  = desc,
                        ImageUri  = coverAddr,
                        Name      = title,
                        TargetUrl = Home,
                        Sources   = new ComicSource[]
                        {
                            new ComicSource
                            {
                                TargetUrl = Home + addr,
                                Name      = EngineName
                            }
                        }
                    };
                    sns.Add(sn);
                }
            }

            for (int i = 1; i < 7; i++)
            {
                Fetch(i);
            }
            return(sns.ToArray());
        }
예제 #14
0
        public async Task <ComicSnapshot[]> GetProposalAsync(int take)
        {
            var str = string.Empty;

#if NETSTANDARD1_3
            using (var mem = new MemoryStream())
#else
            using (var mem = recyclableMemoryStreamManager.GetStream())
#endif
            {
                var buffer = Encoding.UTF8.GetBytes("{\"page_num\":4,\"seed\":\"0\"}");
                mem.Write(buffer, 0, buffer.Length);
                mem.Seek(0, SeekOrigin.Begin);
                var datas = await networkAdapter.GetStreamAsync(new RequestSettings
                {
                    Address  = url,
                    Referrer = "https://manga.bilibili.com/",
                    Method   = "POST",
                    Data     = mem,
                    Headers  = new Dictionary <string, string>(1)
                    {
                        ["Content-Type"] = "application/json"
                    }
                });

                using (var sr = new StreamReader(datas))
                {
                    str = sr.ReadToEnd();
                }
            }
            using (var doc = JsonVisitor.FromString(str))
            {
                var dataTk = doc["data"]["list"].ToArray().ToArray();
                var sns    = new List <ComicSnapshot>(dataTk.Length);
                for (int i = 0; i < dataTk.Length; i++)
                {
                    if (take < i)
                    {
                        break;
                    }
                    var tk     = dataTk[i];
                    var authTk = tk["authors"]?.ToArray();
                    var title  = tk["title"]?.ToString();
                    var id     = tk["comic_id"]?.ToString();
                    var conver = tk["vertical_cover"]?.ToString();
                    var auth   = string.Join("-", authTk.Select(x => x.ToString()));
                    var sn     = new ComicSnapshot
                    {
                        Author    = auth,
                        Name      = title,
                        ImageUri  = conver,
                        TargetUrl = url,
                        Sources   = new ComicSource[]
                        {
                            new ComicSource
                            {
                                Name      = EngineName,
                                TargetUrl = "https://manga.bilibili.com/detail/" + id
                            }
                        }
                    };
                    sns.Add(sn);
                }
                return(sns.ToArray());
            }
        }
예제 #15
0
 protected override ComicSourceInfo CreateSourceInfo(ComicSnapshot snapshot, ComicSource source, ComicEngine engine)
 {
     return(new ComicSourceInfo(snapshot, source, engine.GetComicSourceProviderType(source.TargetUrl)));
 }
예제 #16
0
        protected override ComicSnapshotInfo <WithImageStorableComicSourceInfo <Bitmap, Bitmap> > CreateSnapshotInfo(ComicSnapshot info)
        {
            var httpClient = AppEngine.GetRequiredService <INetworkAdapter>();

            return(new WithImageComicSnapshotInfo <Bitmap, Bitmap>(info, httpClient));
        }
예제 #17
0
 public WithImageStorableComicSnapshotInfo(ComicSnapshot snapshot) : base(snapshot)
 {
 }
예제 #18
0
        public async Task <SearchComicResult> SearchAsync(string keywork, int skip, int take)
        {
            var pageIndex = 1;

            if (take != 0)
            {
                pageIndex = Math.Max(1, skip / take);
            }
            var searchObj = new
            {
                key_word  = keywork,
                page_num  = pageIndex,
                page_size = take
            };
            var searchStr = JsonHelper.Serialize(searchObj);
            var res       = new SearchComicResult
            {
                Support = true
            };

            using (var mem = GetStream())
            {
                var buffer = Encoding.UTF8.GetBytes(searchStr);
                mem.Write(buffer, 0, buffer.Length);
                mem.Seek(0, SeekOrigin.Begin);
                var req = new RequestSettings
                {
                    Address  = searchUrl,
                    Method   = "POST",
                    Host     = UrlHelper.FastGetHost(searchUrl),
                    Referrer = "https://manga.bilibili.com/",
                    Data     = mem,
                    Headers  = headers
                };
                var str = await networkAdapter.GetStringAsync(req);

                using (var visitor = JsonVisitor.FromString(str))
                {
                    var list = visitor["data"]["list"].ToEnumerable();
                    res.Total = list.Count();
                    var sns = new List <ComicSnapshot>();
                    foreach (var item in list)
                    {
                        var conv  = item["vertical_cover"].ToString();
                        var title = item["org_title"].ToString();
                        var id    = item["id"].ToString();
                        var auth  = string.Join(",", item["author_name"].ToEnumerable());
                        var url   = "https://manga.bilibili.com/detail/mc" + id;
                        var sn    = new ComicSnapshot
                        {
                            Author    = auth,
                            ImageUri  = conv,
                            Name      = title,
                            TargetUrl = url,
                            Sources   = new ComicSource[]
                            {
                                new ComicSource
                                {
                                    TargetUrl = url,
                                    Name      = "Bilibili"
                                }
                            }
                        };
                        sns.Add(sn);
                    }
                    res.Snapshots = sns.ToArray();
                }
            }
            return(res);
        }
예제 #19
0
 public DesktopComicViewModel(ComicSnapshot snapshot, Bitmap logoImage)
     : base(snapshot)
 {
     LogoImage            = logoImage;
     SaveLogoImageCommand = new RelayCommand(SaveLogoImage);
 }