示例#1
0
        public async Task <IReadOnlyCollection <PlexTvShow> > GetTvShowsAsync(PlexServer server)
        {
            _logger.LogInformation($"Retrieving plex tv shows from server {server.Name}.");

            var libraries = await _plexClient.GetLibraries(server.AccessToken, server.Host);

            var tvDirectories = libraries.MediaContainer.Directory.Where(x => x.Type == "show").ToList();

            var tvShowMetadata = (await Task.WhenAll(tvDirectories.Select(d => _plexClient.GetLibrary(server.AccessToken, server.Host, d.Key)))).SelectMany(x => x.MediaContainer.Metadata).ToList();

            var tvShows = tvShowMetadata.Select(metadata => new PlexTvShow(metadata.Title, metadata.Year, metadata.RatingKey));

            return(tvShows.ToList());
        }
示例#2
0
        private Plex.Api.Models.PlexMediaContainer GetLibrary(string libraryName)
        {
            var plexServer         = GetPreferredServer();
            var fullURL            = plexServer.FullUri.ToString();
            var plexMediaContainer = plexApi.GetLibraries(plexServer.AccessToken, fullURL).Result;
            //If this errors for "forcibly closed by the remote host", go to your Plex settings, choose "Network" and set it to "Preferred".
            //If it is set to "required", it will error for not using https. But the HTTPS cert for the IP is not valid.

            var library = plexMediaContainer.MediaContainer.Directory.FirstOrDefault(c => c.Title == libraryName);

            if (library == null)
            {
                return(null);
            }

            return(plexApi.GetLibrary(plexServer.AccessToken, fullURL, library.Key).Result);
        }
示例#3
0
        public async Task <MediaContainer> GetLibrary(string authKey, string plexServerHost, string libraryKey)
        {
            var container = await _plexClient.GetLibrary(authKey, plexServerHost, libraryKey);

            return(container?.MediaContainer);
        }