Beispiel #1
0
        private async Task ProcessPeopleFromEmby(string id, IEnumerable <string> neededPeople, CancellationToken cancellationToken)
        {
            var query = new PersonsQuery
            {
                ParentId  = id,
                Recursive = true
            };

            var embyPeople = await _embyClient.GetPeopleAsync(query, cancellationToken);

            var existingPeople = _personRepository.GetIds();
            var newPeople      = embyPeople
                                 .Items
                                 .Where(x => neededPeople.Any(y => y == x.Id))
                                 .Where(x => existingPeople.All(y => y != x.Id))
                                 .ToList();

            if (newPeople.Any())
            {
                Log.Information($"Need to add {newPeople.Count} people first");
                var people = newPeople.Select(PersonHelper.ConvertToSmallPerson);
                _personRepository.AddRangeIfMissing(people);
            }
            else
            {
                Log.Information("No new people to add");
            }
        }