Ejemplo n.º 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);
                }));
            }
Ejemplo n.º 2
0
        public async Task LoadDoubanAsync()
        {
            if (this.DoubanId.IsNullOrWhiteSpace())
            {
                return;
            }

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

            if (info != null)
            {
                this.LoadDouban(info);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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;
                }
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }