Exemplo n.º 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");
            }
        }
Exemplo n.º 2
0
        public async Task <QueryResult <BaseItemDto> > GetPeopleAsync(PersonsQuery query, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = GetItemByNameListUrl("Persons", query);

            if (query.PersonTypes != null && query.PersonTypes.Length > 0)
            {
                url += "&PersonTypes=" + string.Join(",", query.PersonTypes);
            }

            using (var stream = await GetSerializedStreamAsync(url, cancellationToken))
            {
                return(DeserializeFromStream <QueryResult <BaseItemDto> >(stream));
            }
        }
Exemplo n.º 3
0
        private Task <ItemsResult> GetAllActors(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var fields = FolderPage.QueryFields.ToList();

            fields.Remove(ItemFields.Overview);
            fields.Remove(ItemFields.DisplayPreferencesId);
            fields.Remove(ItemFields.DateCreated);

            var query = new PersonsQuery
            {
                Fields = fields.ToArray(),

                IncludeItemTypes = new[] { "Series", "Episode" },

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                Recursive = true,

                UserId = _sessionManager.CurrentUser.Id,

                PersonTypes = new[] { PersonType.Actor, PersonType.GuestStar }
            };

            var indexOption = viewModel.CurrentIndexOption;

            if (indexOption != null)
            {
                if (string.Equals(indexOption.Name, "#", StringComparison.OrdinalIgnoreCase))
                {
                    query.NameLessThan = "A";
                }
                else
                {
                    query.NameStartsWithOrGreater = indexOption.Name;
                    query.NameLessThan            = indexOption.Name + "zz";
                }
            }

            return(ApiClient.GetPeopleAsync(query));
        }
        private Task <ItemsResult> GetFavoritePeople(ItemListViewModel viewModel, DisplayPreferences displayPreferences)
        {
            var query = new PersonsQuery
            {
                Fields = FolderPage.QueryFields,

                UserId = _sessionManager.CurrentUser.Id,

                SortBy = !String.IsNullOrEmpty(displayPreferences.SortBy)
                             ? new[] { displayPreferences.SortBy }
                             : new[] { ItemSortBy.SortName },

                SortOrder = displayPreferences.SortOrder,

                Recursive = true,

                Filters = new[] { ItemFilter.IsFavorite }
            };

            return(ApiClient.GetPeopleAsync(query));
        }
Exemplo n.º 5
0
 public async Task <IEnumerable <PersonDto> > Persons([FromQuery] PersonsQuery personsQuery)
 {
     return(await _mediator.Send(personsQuery));
 }
        public IEnumerable <BaseItem> RetrievePersons(PersonsQuery query)
        {
            var dtos = Kernel.ApiClient.GetPersons(query);

            return(dtos == null ? new BaseItem[] {} : dtos.Items.Select(dto => GetItem(dto, dto.Type)).Where(item => item != null));
        }
Exemplo n.º 7
0
        public Task <IEnumerable <PersonDto> > Handle(PersonsQuery request, CancellationToken cancellationToken)
        {
            var persons = _personDomain.GetAll();

            return(Task.FromResult(persons.MapTo <IEnumerable <PersonDto> >()));
        }
Exemplo n.º 8
0
        public virtual IEnumerable <BaseItem> IndexBy(string property)
        {
            if (string.IsNullOrEmpty(property))
            {
                throw new ArgumentException("Index type should not be none!");
            }

            if (property == LocalizedStrings.Instance.GetString("GenreDispPref"))
            {
                var query = new ItemQuery
                {
                    UserId    = Kernel.CurrentUser.ApiId,
                    ParentId  = ApiId,
                    Recursive = true,
                    Fields    = new[] { ItemFields.SortName },
                    SortBy    = new[] { "SortName" }
                };

                var ret = CollectionType == "Music" || ContainsMusic?
                          Kernel.Instance.MB3ApiRepository.RetrieveMusicGenres(query).Select(g => new ApiGenreFolder(g, ApiId, new[] { "MusicAlbum" }, null, this)).Cast <BaseItem>().ToList() :
                              Kernel.Instance.MB3ApiRepository.RetrieveGenres(query).Select(g => new ApiGenreFolder(g, ApiId, null, null, this)).Cast <BaseItem>().ToList();

                ApiRecursiveItemCount = ret.Count;
                Logger.ReportVerbose("=========== Indexing with new technique...");
                return(ret);
            }
            else if (property == LocalizedStrings.Instance.GetString("ActorDispPref"))
            {
                var personTypes = new[] { PersonType.Actor, PersonType.GuestStar };
                var ret         = LocalizedStrings.Instance.GetString("StartingLetters").Select(c => new PersonLetterFolder(c.ToString(), false, ApiId, personTypes, null, null, this)).Cast <BaseItem>().ToList();
                ret.Add(new PersonLetterFolder("#", true, ApiId, personTypes, null, null, this));
                ApiRecursiveItemCount = ret.Count;
                return(ret);
            }
            else if (property == LocalizedStrings.Instance.GetString("DirectorDispPref"))
            {
                var personTypes = new[] { PersonType.Director };
                var query       = new PersonsQuery
                {
                    UserId      = Kernel.CurrentUser.ApiId,
                    ParentId    = ApiId,
                    Recursive   = true,
                    Fields      = new[] { ItemFields.SortName },
                    SortBy      = new[] { "SortName" },
                    PersonTypes = personTypes
                };
                var ret = Kernel.Instance.MB3ApiRepository.RetrievePersons(query).Select(p => new ApiPersonFolder(p, ApiId, personTypes, null, null, this)).Cast <BaseItem>().ToList();
                ApiRecursiveItemCount = ret.Count;
                return(ret);
            }
            else if (property == LocalizedStrings.Instance.GetString("YearDispPref"))
            {
                var query = new ItemsByNameQuery
                {
                    UserId    = Kernel.CurrentUser.ApiId,
                    ParentId  = ApiId,
                    Recursive = true,
                    Fields    = new[] { ItemFields.SortName },
                    SortBy    = new[] { "SortName" },
                };
                var ret = Kernel.Instance.MB3ApiRepository.RetrieveIbnItems("Years", query).Select(p => new ApiYearFolder(p, ApiId, null, new[] { "Audio" }, this)).Cast <BaseItem>().ToList();
                ApiRecursiveItemCount = ret.Count;
                return(ret);
            }
            else if (property == LocalizedStrings.Instance.GetString("StudioDispPref"))
            {
                var query = new ItemsByNameQuery
                {
                    UserId    = Kernel.CurrentUser.ApiId,
                    ParentId  = ApiId,
                    Recursive = true,
                    Fields    = new[] { ItemFields.SortName },
                    SortBy    = new[] { "SortName" },
                };
                var ret = Kernel.Instance.MB3ApiRepository.RetrieveIbnItems("Studios", query).Select(p => new ApiStudioFolder(p, ApiId, null, new[] { "Audio" }, this)).Cast <BaseItem>().ToList();
                ApiRecursiveItemCount = ret.Count;
                return(ret);
            }

            return(Kernel.Instance.MB3ApiRepository.RetrieveChildren(this.ApiId));
        }