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;
        }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
        public async Task<string> TryGetTheTVDBSeriesIdByRemoteIdAsync(RemoteId id)
        {
            switch (id.Type)
            {
                case RemoteIdType.TheTVDB:
                    return id.Id;

                case RemoteIdType.Imdb:
                    return (await this.GetSeriesByImdbIdAsync(id.Id)).FirstOrDefault()?.SeriesId;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }