private async Task UpdatePlexData() { if (AuthToken == null) { AuthToken = (await _plexApi.SignIn()).user.authentication_token; } Libraries = (await _plexApi.GetLibrarySections(AuthToken)).MediaContainer.Directory; LibraryMetadata = new Dictionary <string, Metadata[]>(); for (int i = 0; i < Libraries.Count; i++) { LibraryMetadata.Add(Libraries[i].key, (await _plexApi.GetLibrary(AuthToken, Libraries[i].key)).MediaContainer.Metadata); } }
private async Task Cache(PlexServers settings) { if (!Validate(settings)) { _log.LogWarning("Validation failed"); return; } // Get the librarys and then get the tv section var sections = await _api.GetLibrarySections(settings.PlexAuthToken, settings.FullUri); // Filter the libSections var tvSections = sections.MediaContainer.Directory.Where(x => x.type.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase)); foreach (var section in tvSections) { if (settings.PlexSelectedLibraries.Any()) { // Are any enabled? if (settings.PlexSelectedLibraries.Any(x => x.Enabled)) { // Make sure we have enabled this var keys = settings.PlexSelectedLibraries.Where(x => x.Enabled).Select(x => x.Key.ToString()) .ToList(); if (!keys.Contains(section.key)) { // We are not monitoring this lib continue; } } } // Get the episodes await GetEpisodes(settings, section); } }