示例#1
0
            private async Task <bool> TryAutoAddCoverAsync(DataCenter dataCenter, TheTVDBClient client, RemoteId removeId, VideoRole role)
            {
                var theTVDBId = await client.TryGetTheTVDBSeriesIdByRemoteIdAsync(removeId);

                if (theTVDBId == null)
                {
                    return(false);
                }
                var actor = await dataCenter.ArtistManager.FindAsync(role.ActorId);

                if (actor == null)
                {
                    return(false);
                }
                var actors = (await client.GetActorsBySeriesIdAsync(theTVDBId)).ToArray();

                actors = actors.Where(z => z.Id == actor.TheTVDBId).ToArray();
                if (actors.Length != 1)
                {
                    return(false);
                }
                if (!actors[0].HasBanner)
                {
                    return(false);
                }
                var url     = actors[0].BuildUrl(client);
                var builder = CoverBuilder.CreateRole(role);

                builder.Uri.Add(url);
                return(await dataCenter.CoverManager.BuildCoverAsync(builder));
            }
示例#2
0
        public async void BeginLoadFanartByImdbId(TheTVDBClient client, string index, params RemoteId[] ids)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            foreach (var id in ids)
            {
                if (await this.LoadFanartByImdbIdAsync(client, id, index))
                {
                    return;
                }
            }

            foreach (var id in ids)
            {
                if (await this.LoadFanartByImdbIdAsync(client, id))
                {
                    return;
                }
            }

            this.Load(Enumerable.Empty <string>());
        }
示例#3
0
        public async void BeginLoadPosterByImdbId(TheTVDBClient client, string imdbId)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (imdbId == null)
            {
                throw new ArgumentNullException(nameof(imdbId));
            }

            var videos = (await client.GetSeriesByImdbIdAsync(imdbId)).ToArray();

            if (videos.Length == 0)
            {
                this.Load(Enumerable.Empty <string>());
            }
            else
            {
                var urls = (await videos[0].GetBannersAsync(JryVideoCore.Current.GetTheTVDBClient()))
                           .Where(z => z.BannerType == BannerType.Poster)
                           .Select(z => z.BuildUrl(client))
                           .ToArray();
                this.Load(urls);
            }
        }
示例#4
0
            private async Task <bool> AutoGenerateCoverAsync(TheTVDBClient client, IImdbItem item)
            {
                var imdbId = item.GetValidImdbId();

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

                foreach (var series in await client.GetSeriesByImdbIdAsync(imdbId))
                {
                    if (await this.AutoGenerateCoverOverTheTVDBIdAsync(client, series.SeriesId,
                                                                       this.source.InfoView.Source.Index.ToString()))
                    {
                        return(true);
                    }
                }
                return(false);
            }
示例#5
0
        private async Task <bool> LoadFanartByImdbIdAsync(TheTVDBClient client, RemoteId id, string index = null)
        {
            var seriesId = await client.TryGetTheTVDBSeriesIdByRemoteIdAsync(id);

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

            var urls = (await client.GetBannersBySeriesIdAsync(seriesId)).Where(z => z.BannerType == BannerType.Fanart)
                       .Where(z => index == null || z.Season == index)
                       .Select(z => z.BuildUrl(client))
                       .ToArray();

            if (urls.Length > 0)
            {
                this.Load(urls);
                return(true);
            }
            return(false);
        }
示例#6
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);
                }));
            }