コード例 #1
0
            /// <summary>
            /// return true if success.
            /// </summary>
            /// <returns></returns>
            public async Task <bool> GenerateAsync(DataCenter dataCenter, ICoverParent source)
            {
                var video = (JryVideoInfo)source;

                if (video.DoubanId == null)
                {
                    return(false);
                }

                return(await Task.Run(async() =>
                {
                    var builder = CoverBuilder.CreateVideo(video);
                    var requests = (await DoubanHelper.TryGetMovieInfoAsync(video.DoubanId))?.GetMovieCoverRequest().ToArray();
                    if (requests == null)
                    {
                        return false;
                    }
                    if (requests.Length == 0)
                    {
                        return false;
                    }
                    builder.Requests.AddRange(requests);
                    return await this.manager.BuildCoverAsync(builder);
                }));
            }
コード例 #2
0
        public async Task LoadFromDoubanAsync()
        {
            var doubanId = this.DoubanId;

            if (string.IsNullOrWhiteSpace(doubanId))
            {
                return;
            }
            var info = await DoubanHelper.TryGetArtistInfoAsync(doubanId);

            if (info == null)
            {
                return;
            }
            var names = DoubanHelper.ParseName(info).ToArray();

            if (names.Length > 0)
            {
                for (var i = 0; i < names.Length; i++)
                {
                    var n = names[i];
                    names[i] = n
                               .Replace(", ", ",")
                               .Replace(" ,", ",")
                               .Replace(",", " , ")
                               .Replace("(蠻各)", "")
                               .Replace("(云兆)", "");
                }
                this.Names.AddRange(names);
            }
        }
コード例 #3
0
        public async Task LoadDoubanAsync()
        {
            if (string.IsNullOrWhiteSpace(this.DoubanId))
            {
                return;
            }

            var movie = await DoubanHelper.TryGetMovieInfoAsync(this.DoubanId);

            if (movie != null)
            {
                this.NamesViewModel.AddRange(DoubanMovieParser.Parse(movie).SeriesNames);
            }
        }
コード例 #4
0
        public async Task LoadDoubanAsync()
        {
            if (this.DoubanId.IsNullOrWhiteSpace())
            {
                return;
            }

            var info = await DoubanHelper.TryGetMovieInfoAsync(this.DoubanId);

            if (info != null)
            {
                this.LoadDouban(info);
            }
        }
コード例 #5
0
        public async Task LoadDoubanAsync()
        {
            if (String.IsNullOrWhiteSpace(this.DoubanId))
            {
                return;
            }

            var movie = await DoubanHelper.TryGetMovieInfoAsync(this.DoubanId);

            if (movie != null)
            {
                var doubanName = DoubanMovieParser.Parse(movie).SeriesNames.AsLines();

                this.Names = String.IsNullOrWhiteSpace(this.Names)
                    ? doubanName
                    : String.Join("\r\n", this.Names, doubanName);
            }
        }
コード例 #6
0
        private async void BeginLoadDoubanMeta(string doubanId)
        {
            var info = await DoubanHelper.TryGetMovieInfoAsync(doubanId);

            if (info != null)
            {
                var parser = DoubanMovieParser.Parse(info);
                this.NamesViewModel.AddRange(parser.EntityNames);

                var defaultValue = (Application.Current as App)?.UserConfig?.DefaultValue;
                if (defaultValue != null)
                {
                    if (parser.IsMovie)
                    {
                        if (!defaultValue.MovieType.IsNullOrWhiteSpace())
                        {
                            this.Type = defaultValue.MovieType;
                        }
                    }
                    else
                    {
                        if (!defaultValue.SeasonType.IsNullOrWhiteSpace())
                        {
                            this.Type = defaultValue.SeasonType;
                        }
                    }
                }

                if (this.Year.Value.IsNullOrWhiteSpace())
                {
                    this.Year.Value = info.Year;
                }

                if (this.Index.Value.IsNullOrWhiteSpace())
                {
                    this.Index.Value = info.CurrentSeason ?? parser.Index;
                }

                if (this.EpisodesCount.Value.IsNullOrWhiteSpace())
                {
                    this.EpisodesCount.Value = parser.EpisodesCount ?? string.Empty;
                }
            }
        }
コード例 #7
0
ファイル: ArtistViewModel.cs プロジェクト: ichobits/JRYVideo
            /// <summary>
            /// return true if success.
            /// </summary>
            /// <param name="dataCenter"></param>
            /// <param name="source"></param>
            /// <returns></returns>
            public async Task <bool> GenerateAsync(DataCenter dataCenter, ICoverParent source)
            {
                var item     = (Artist)source;
                var doubanId = item.DoubanId;

                if (string.IsNullOrWhiteSpace(doubanId))
                {
                    return(false);
                }
                var info = await DoubanHelper.TryGetArtistInfoAsync(doubanId);

                if (info == null)
                {
                    return(false);
                }
                var url          = info.GetLargeImageUrl();
                var coverBuilder = CoverBuilder.CreateArtist(item);

                coverBuilder.Uri.Add(url);
                return(await dataCenter.CoverManager.BuildCoverAsync(coverBuilder));
            }
コード例 #8
0
        public async Task <bool> LoadFromDoubanAsync()
        {
            if (string.IsNullOrWhiteSpace(this.DoubanId))
            {
                return(false);
            }

            var json = await DoubanHelper.TryGetMovieInfoAsync(this.DoubanId);

            if (json == null || json.Images == null || json.Images.Large == null)
            {
                return(false);
            }

            this.Uri = DoubanHelper.GetLargeImageUrl(json);

            var request = WebRequest.CreateHttp(this.Uri);

            this.BinaryData = (await request.GetResultAsBytesAsync()).Result;

            return(this.BinaryData != null);
        }
コード例 #9
0
        private async void BeginLoadDoubanHtml(string doubanId)
        {
            if (this.ImdbId.IsNullOrWhiteSpace() || this.StartLocalDate == null)
            {
                var html = await DoubanHelper.TryGetMovieHtmlAsync(doubanId);

                if (html == null)
                {
                    return;
                }

                if (this.ImdbId.IsNullOrWhiteSpace())
                {
                    this.ImdbId = DoubanHelper.TryParseImdbId(html) ?? string.Empty;
                }

                if (this.StartLocalDate == null)
                {
                    this.StartLocalDate = DoubanHelper.TryParseReleaseDate(html);
                }
            }
        }
コード例 #10
0
        public async Task <bool> LoadFromDoubanAsync()
        {
            if (string.IsNullOrWhiteSpace(this.DoubanId))
            {
                return(false);
            }
            var json = await DoubanHelper.TryGetMovieInfoAsync(this.DoubanId);

            if (json == null)
            {
                return(false);
            }
            var requests = json.GetMovieCoverRequest().ToArray();

            foreach (var request in requests)
            {
                if (await this.LoadFromRequestAsync(request))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #11
0
        private async Task <string> TryGetCoverUrlFromDoubanIdAsync(JryCoverType type, string doubanId)
        {
            DoubanEntity json = null;

            switch (type)
            {
            case JryCoverType.Video:
                json = await DoubanHelper.TryGetMovieInfoAsync(doubanId);

                break;

            case JryCoverType.Artist:
                json = await DoubanHelper.TryGetArtistInfoAsync(doubanId);

                break;

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }


            return(json != null?json.GetLargeImageUrl() : null);
        }
コード例 #12
0
ファイル: IsbnController.cs プロジェクト: wuzongwen/ISBN_JD
        public JsonResult GetIsbnimg(string Isbn)
        {
            string code = string.Empty;
            string msg  = string.Empty;
            string pic  = string.Empty;

            try
            {
                if (Isbn != null)
                {
                    if (HtmlHelper.RemoveNotNumber(Isbn).Length == 13)
                    {
                        //去除数字以外的其他字符
                        Isbn = HtmlHelper.RemoveNotNumber(Isbn);

                        //获取网页数据,页面编码格式(GB2312:Encoding.Default;UTF-8:Encoding.UTF8)
                        string HtmlData = HtmlHelper.DownloadHtml("https://search.jd.com/Search?keyword=" + Isbn, Encoding.UTF8);

                        //获取商品部分Html
                        string Html = HtmlHelper.GetValue(HtmlData, "<ul class=\"gl-warp clearfix\" data-tpl=\".*?\">", "</ul>");

                        //获取所有商品图片
                        var ImgList = HtmlHelper.GetHtmlImageUrlList(Html);

                        if (ImgList.Length > 0)
                        {
                            //匹配类似书籍的商品索引,如没有返回0
                            int BookIndex = HtmlHelper.GetBookIndex(HtmlData);
                            pic  = ImgList[BookIndex];
                            msg  = "获取成功";
                            code = "10001";
                        }
                        else
                        {
                            //到豆瓣检索书籍信息
                            BookInfo bookInfo;
                            DoubanHelper.getInfo(Isbn, out bookInfo);
                            if (bookInfo != null)
                            {
                                pic  = bookInfo.image;
                                msg  = "获取成功";
                                code = "10001";
                            }
                            else
                            {
                                msg  = "未查询到书籍信息";
                                code = "10002";
                            }
                        }
                    }
                    else
                    {
                        msg  = "未查询到书籍信息";
                        code = "10002";
                    }
                }
                else
                {
                    msg  = "ISBN错误";
                    code = "10003";
                }
            }
            catch (Exception)
            {
                msg  = "服务器错误";
                code = "10004";
            }
            return(Json(new { code, msg, pic }));
        }
コード例 #13
0
ファイル: IsbnController.cs プロジェクト: wuzongwen/ISBN_JD
        public void GetIsbnimg(string Isbn)
        {
            string code = string.Empty;
            string msg  = string.Empty;
            string pic  = string.Empty;

            try
            {
                if (Isbn != null)
                {
                    if (HtmlHelper.RemoveNotNumber(Isbn).Length == 13)
                    {
                        //去除数字以外的其他字符
                        Isbn = HtmlHelper.RemoveNotNumber(Isbn);

                        //获取网页数据,页面编码格式(GB2312:Encoding.Default;UTF-8:Encoding.UTF8)
                        string HtmlData = HtmlHelper.DownloadHtml("https://search.jd.com/Search?keyword=" + Isbn, Encoding.UTF8);

                        //获取商品部分Html
                        string Html = HtmlHelper.GetValue(HtmlData, "<ul class=\"gl-warp clearfix\" data-tpl=\".*?\">", "</ul>");

                        //获取所有商品图片
                        var ImgList = HtmlHelper.GetHtmlImageUrlList(Html);

                        if (ImgList.Length > 0)
                        {
                            //匹配类似书籍的商品索引,如没有返回0
                            int BookIndex = HtmlHelper.GetBookIndex(HtmlData);
                            pic  = ImgList[BookIndex];
                            msg  = "获取成功";
                            code = "10001";
                        }
                        else
                        {
                            //到豆瓣检索书籍信息
                            BookInfo bookInfo;
                            DoubanHelper.getInfo(Isbn, out bookInfo);
                            if (bookInfo != null)
                            {
                                pic  = bookInfo.image;
                                msg  = "获取成功";
                                code = "10001";
                            }
                            else
                            {
                                msg  = "未查询到书籍信息";
                                code = "10002";
                            }
                        }
                    }
                    else
                    {
                        msg  = "未查询到书籍信息";
                        code = "10002";
                    }
                }
                else
                {
                    msg  = "ISBN错误";
                    code = "10003";
                }
            }
            catch (Exception)
            {
                msg  = "服务器错误";
                code = "10004";
            }
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; //获取传统context
            HttpRequestBase request = context.Request;                                       //定义传统request对象

            HttpContext.Current.Response.Charset         = "GB2312";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(new { code, msg, pic }));
            HttpContext.Current.Response.End();
        }