Ejemplo n.º 1
0
 private Task <Stream> CreateRequest(string url)
 {
     return(networkAdapter.GetStreamAsync(new RequestSettings
     {
         Address = url,
         Referrer = "https://www.dmzj.com/"
     }));
 }
Ejemplo n.º 2
0
 private Task <Stream> XGetImageStreamAsync(string address)
 {
     return(networkAdapter.GetStreamAsync(new RequestSettings
     {
         Address = address,
         Headers = imgHeaders
     }));
 }
Ejemplo n.º 3
0
 public static async Task <string> GetStringAsync(this INetworkAdapter adapter, RequestSettings settings)
 {
     using (var stream = await adapter.GetStreamAsync(settings))
         using (var sr = new StreamReader(stream))
         {
             return(sr.ReadToEnd());
         }
 }
Ejemplo n.º 4
0
 protected virtual Task <Stream> GetStreamAsync(string address)
 {
     return(networkAdapter.GetStreamAsync(new RequestSettings
     {
         Address = address,
         Host = new Uri(address).Host,
         Referrer = "https://www.qimiaomh.com/",
     }));
 }
Ejemplo n.º 5
0
 public static async Task <T> GetObjectAsync <T>(this INetworkAdapter adapter, RequestSettings settings)
 {
     using (var stream = await adapter.GetStreamAsync(settings))
         using (var sr = new StreamReader(stream))
         {
             var str = sr.ReadToEnd();
             return(JsonHelper.Deserialize <T>(str));
         }
 }
Ejemplo n.º 6
0
 protected virtual Task <Stream> GetStreamAsync(string address)
 {
     return(networkAdapter.GetStreamAsync(new RequestSettings
     {
         Address = address,
         Host = new Uri(address).Host,
         Referrer = Home
     }));
 }
Ejemplo n.º 7
0
 protected virtual Task <Stream> GetStreamAsync(string address)
 {
     return(networkAdapter.GetStreamAsync(new RequestSettings
     {
         Address = address,
         Host = new Uri(address).Host,
         Referrer = "http://www.bikabika.com/",
         Headers = headers
     }));
 }
Ejemplo n.º 8
0
 protected virtual Task <Stream> GetStreamAsync(string address, string method, Stream stream = null)
 {
     return(networkAdapter.GetStreamAsync(new RequestSettings
     {
         Address = address,
         Host = new Uri(address).Host,
         Referrer = "https://manga.bilibili.com/",
         Headers = headers,
         Method = method,
         Data = stream
     }));
 }
Ejemplo n.º 9
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();
            }
        }
Ejemplo n.º 10
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());
            }
        }