Example #1
0
            /// <summary>
            /// return true if success.
            /// </summary>
            /// <returns></returns>
            public async Task <bool> GenerateAsync(DataCenter dataCenter, ICoverParent source)
            {
                var client = JryVideoCore.Current.GetTheTVDBClient();

                if (client == null)
                {
                    return(false);
                }

                var role = (VideoRole)source;

                var tvdb = this.TheTVDBItem;

                if (tvdb != null && !tvdb.TheTVDBId.IsNullOrWhiteSpace())
                {
                    if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.TheTVDB, tvdb.TheTVDBId), role))
                    {
                        return(true);
                    }
                }

                var imdb = this.ImdbItem.GetValidImdbId();

                if (imdb != null)
                {
                    if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.Imdb, imdb), role))
                    {
                        return(true);
                    }
                }

                return(false);
            }
Example #2
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);
                }));
            }
Example #3
0
 public CoverBuilder(ICoverParent coverParent)
 {
     this.Id = coverParent.CoverId;
     if (this.Id == null)
     {
         throw new ArgumentNullException();
     }
 }
Example #4
0
        private async void Manager_CoverParentRemoving(object sender, ICoverParent e)
        {
            var id = e.CoverId;

            if (id != null)
            {
                Debug.WriteLine($"remove cover [{id}] from {e.GetType().Name}[ {e.Id}] over {sender.GetType().Name}");
                await this.RemoveAsync(id);
            }
        }
Example #5
0
        private void ConnectToCover(string rootObjectId, ICoverParent obj)
        {
            var coverId = obj.CoverId;

            if (coverId == null)
            {
                return;
            }
            CoverRef cover;

            if (this.covers.TryGetValue(coverId, out cover))
            {
                cover.CoverParents.Add(new CoverParentRef(obj));
            }
        }
Example #6
0
            /// <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 client = JryVideoCore.Current.GetTheTVDBClient();

                if (client == null)
                {
                    return(false);
                }

                this.coverManager = dataCenter.CoverManager;
                return(await this.AutoGenerateCoverAsync(client, this.source.InfoView.Source) ||
                       await this.AutoGenerateCoverOverTheTVDBIdAsync(client,
                                                                      this.source.InfoView.SeriesView.Source.TheTVDBId,
                                                                      this.source.InfoView.Source.Index.ToString()) ||
                       await this.AutoGenerateCoverAsync(client, this.source.InfoView.SeriesView.Source));
            }
Example #7
0
            /// <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));
            }
Example #8
0
            /// <summary>
            /// return true if success.
            /// </summary>
            /// <returns></returns>
            public async Task<bool> GenerateAsync(DataCenter dataCenter, ICoverParent source)
            {
                var client = JryVideoCore.Current.GetTheTVDBClient();
                if (client == null) return false;

                var role = (VideoRole)source;

                var tvdb = this.TheTVDBItem;
                if (tvdb != null && !tvdb.TheTVDBId.IsNullOrWhiteSpace())
                {
                    if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.TheTVDB, tvdb.TheTVDBId), role))
                    {
                        return true;
                    }
                }

                var imdb = this.ImdbItem.GetValidImdbId();
                if (imdb != null)
                {
                    if (await this.TryAutoAddCoverAsync(dataCenter, client, new RemoteId(RemoteIdType.Imdb, imdb), role))
                    {
                        return true;
                    }
                }

                return false;
            }
            /// <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 client = JryVideoCore.Current.GetTheTVDBClient();
                if (client == null) return false;

                this.coverManager = dataCenter.CoverManager;
                return await this.AutoGenerateCoverAsync(client, this.source.InfoView.Source) ||
                       await this.AutoGenerateCoverOverTheTVDBIdAsync(client,
                           this.source.InfoView.SeriesView.Source.TheTVDBId,
                           this.source.InfoView.Source.Index.ToString()) ||
                       await this.AutoGenerateCoverAsync(client, this.source.InfoView.SeriesView.Source);
            }
Example #10
0
 public CoverParentRef(ICoverParent obj)
 {
     this.Id = obj.Id;
     this.Type = obj.GetType().Name;
 }
Example #11
0
 private void ConnectToCover(string rootObjectId, ICoverParent obj)
 {
     var coverId = obj.CoverId;
     if (coverId == null) return;
     CoverRef cover;
     if (this.covers.TryGetValue(coverId, out cover))
     {
         cover.CoverParents.Add(new CoverParentRef(obj));
     }
 }
Example #12
0
        public static async Task <CoverEditorViewModel> FromAsync(CoverManager manager, ICoverParent coverParent)
        {
            var viewModel = new CoverEditorViewModel
            {
                coverId = coverParent.CoverId
            };

            if (viewModel.coverId == null) // since cover id equal id, new object may contain null cover id.
            {
                throw new ArgumentNullException();
            }
            else
            {
                var cover = await manager.FindAsync(viewModel.coverId);

                if (cover == null)
                {
                    viewModel.CreateMode();
                }
                else
                {
                    viewModel.ModifyMode(cover);
                }
            }
            return(viewModel);
        }
Example #13
0
 public CoverBuilder(ICoverParent coverParent)
 {
     this.Id = coverParent.CoverId;
     if (this.Id == null) throw new ArgumentNullException();
 }
Example #14
0
 protected void OnCoverParentRemoving(ICoverParent parent, object sender = null)
 => this.CoverParentRemoving?.Invoke(sender ?? this, parent);
Example #15
0
 public CoverParentRef(ICoverParent obj)
 {
     this.Id   = obj.Id;
     this.Type = obj.GetType().Name;
 }