private async Task CreateAdminServer(Server adminServer, User plexUser) { _logger.LogInformation("Found a PlexServer owned by the Admin account"); var plexServer = new PlexServerRow { Identifier = Guid.NewGuid(), AccessToken = adminServer.AccessToken, Name = adminServer.Name, MachineIdentifier = adminServer.MachineIdentifier, LocalIp = adminServer.LocalAddresses.Split(",").FirstOrDefault(), LocalPort = _plexSettings.DefaultLocalPort, ExternalIp = adminServer.Address, ExternalPort = Convert.ToInt32(adminServer.Port), Scheme = adminServer.Scheme, PlexLibraries = new List <PlexLibraryRow>() }; _logger.LogInformation("Getting available libraries on PlexServer"); var libraryContainer = await _plexApi.GetLibraries(plexUser.AuthToken, plexServer.GetPlexUri(_plexSettings.ConnectLocally)); var directories = libraryContainer?.MediaContainer.Directory; if (directories != null) { _logger.LogInformation( $"Identified '{directories.Count}' libraries on the PlexServer"); plexServer.PlexLibraries = directories.Select(x => new PlexLibraryRow { LibraryKey = x.Key, Title = x.Title, Type = x.Type }).ToList(); } else { _logger.LogInformation("No Plex Libraries were found for the server"); } await _plexService.AddServer(plexServer); }
private void GivenAServerIsCreated() { _plexService.AddServer(Arg.Do <PlexServerRow>(x => _createdServer = x)); }