Exemple #1
0
        public object Get(GetMetadataEditorInfo request)
        {
            var item = _libraryManager.GetItemById(request.ItemId);

            var info = new MetadataEditorInfo
            {
                ParentalRatingOptions = _localizationManager.GetParentalRatings(),
                ExternalIdInfos       = _providerManager.GetExternalIdInfos(item).ToArray(),
                Countries             = _localizationManager.GetCountries(),
                Cultures = _localizationManager.GetCultures()
            };

            if (!item.IsVirtualItem && !(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName) &&
                item.SourceType == SourceType.Library)
            {
                var inheritedContentType  = _libraryManager.GetInheritedContentType(item);
                var configuredContentType = _libraryManager.GetConfiguredContentType(item);

                if (string.IsNullOrWhiteSpace(inheritedContentType) || !string.IsNullOrWhiteSpace(configuredContentType))
                {
                    info.ContentTypeOptions = GetContentTypeOptions(true).ToArray();
                    info.ContentType        = configuredContentType;

                    if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                    {
                        info.ContentTypeOptions = info.ContentTypeOptions
                                                  .Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                                                  .ToArray();
                    }
                }
            }

            return(ToOptimizedResult(info));
        }
        public ActionResult <MetadataEditorInfo> GetMetadataEditorInfo([FromRoute, Required] Guid itemId)
        {
            var item = _libraryManager.GetItemById(itemId);

            var info = new MetadataEditorInfo
            {
                ParentalRatingOptions = _localizationManager.GetParentalRatings().ToArray(),
                ExternalIdInfos       = _providerManager.GetExternalIdInfos(item).ToArray(),
                Countries             = _localizationManager.GetCountries().ToArray(),
                Cultures = _localizationManager.GetCultures().ToArray()
            };

            if (!item.IsVirtualItem &&
                item is not ICollectionFolder &&
                item is not UserView &&
                item is not AggregateFolder &&
                item is not LiveTvChannel &&
                item is not IItemByName &&
                item.SourceType == SourceType.Library)
            {
                var inheritedContentType  = _libraryManager.GetInheritedContentType(item);
                var configuredContentType = _libraryManager.GetConfiguredContentType(item);

                if (string.IsNullOrWhiteSpace(inheritedContentType) ||
                    !string.IsNullOrWhiteSpace(configuredContentType))
                {
                    info.ContentTypeOptions = GetContentTypeOptions(true).ToArray();
                    info.ContentType        = configuredContentType;

                    if (string.IsNullOrWhiteSpace(inheritedContentType) ||
                        string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                    {
                        info.ContentTypeOptions = info.ContentTypeOptions
                                                  .Where(i => string.IsNullOrWhiteSpace(i.Value) ||
                                                         string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                                                  .ToArray();
                    }
                }
            }

            return(info);
        }