Example #1
0
 public TmdbPersonProvider(IFileSystem fileSystem, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogger logger)
 {
     _fileSystem           = fileSystem;
     _configurationManager = configurationManager;
     _jsonSerializer       = jsonSerializer;
     _httpClient           = httpClient;
     _logger = logger;
     Current = this;
 }
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var person = (Person)item;
            var id     = person.GetProviderId(MetadataProviders.Tmdb);

            if (!string.IsNullOrEmpty(id))
            {
                await TmdbPersonProvider.Current.EnsurePersonInfo(id, cancellationToken).ConfigureAwait(false);

                var dataFilePath = TmdbPersonProvider.GetPersonDataFilePath(_config.ApplicationPaths, id);

                var result = _jsonSerializer.DeserializeFromFile <PersonResult>(dataFilePath);

                var images = result.Images ?? new PersonImages();

                var tmdbSettings = await TmdbMovieProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);

                var tmdbImageUrl = tmdbSettings.images.GetImageUrl("original");

                return(GetImages(images, item.GetPreferredMetadataLanguage(), tmdbImageUrl));
            }

            return(new List <RemoteImageInfo>());
        }