Ejemplo n.º 1
0
            public async Task <bool?> StartSelect(Window window)
            {
                var parameters = new List <RemoteId>();

                var imdbId = this.videoViewer.InfoView.Source.GetValidImdbId();

                if (imdbId != null)
                {
                    parameters.Add(new RemoteId(RemoteIdType.Imdb, imdbId));
                }

                var theTVDBId = this.videoViewer.InfoView.SeriesView.Source.TheTVDBId;

                if (!theTVDBId.IsNullOrWhiteSpace())
                {
                    parameters.Add(new RemoteId(RemoteIdType.TheTVDB, theTVDBId));
                }

                imdbId = this.videoViewer.InfoView.SeriesView.Source.GetValidImdbId();
                if (imdbId != null)
                {
                    parameters.Add(new RemoteId(RemoteIdType.Imdb, imdbId));
                }

                var url = WebImageSelectorWindow.StartSelectFanartByImdbId(window,
                                                                           this.videoViewer.InfoView.Source.Index.ToString(), parameters.ToArray());

                if (string.IsNullOrWhiteSpace(url))
                {
                    return(null);
                }
                var builder = CoverBuilder.CreateBackground(this.videoViewer.InfoView.Source);

                builder.Uri.Add(url);
                await this.GetManagers().CoverManager.BuildCoverAsync(builder);

                this.RefreshProperties();
                return(false);
            }
Ejemplo n.º 2
0
            private async Task <bool> AutoGenerateCoverOverTheTVDBIdAsync(TheTVDBClient client, string theTVDBId, string index)
            {
                if (theTVDBId.IsNullOrWhiteSpace())
                {
                    return(false);
                }

                return(await Task.Run(async() =>
                {
                    var array = (await client.GetBannersBySeriesIdAsync(theTVDBId)).ToArray();
                    var urls = array.Where(z => z.Season == index).RandomSort()
                               .Concat(array.Where(z => z.Season != index).RandomSort())
                               .Where(banner => banner.BannerType == BannerType.Fanart)
                               .Select(z => z.BuildUrl(client))
                               .ToArray();
                    if (urls.Length == 0)
                    {
                        return false;
                    }
                    var builder = CoverBuilder.CreateBackground(this.source.InfoView.Source);
                    builder.Uri.AddRange(urls);
                    return await this.coverManager.BuildCoverAsync(builder);
                }));
            }