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

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

            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);
                    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))
                                                  .ToList();
                    }
                }
            }

            return(ToOptimizedResult(info));
        }
Exemple #2
0
        protected override Series Resolve(ItemResolveArgs args)
        {
            if (args.IsDirectory)
            {
                if (args.HasParent <Series>() || args.HasParent <Season>())
                {
                    return(null);
                }

                var collectionType = args.GetCollectionType();
                if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                {
                    var configuredContentType = _libraryManager.GetConfiguredContentType(args.Path);
                    if (!string.Equals(configuredContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                    {
                        return(new Series
                        {
                            Path = args.Path,
                            Name = Path.GetFileName(args.Path)
                        });
                    }
                }
                else if (string.IsNullOrEmpty(collectionType))
                {
                    if (args.ContainsFileSystemEntryByName("tvshow.nfo"))
                    {
                        if (args.Parent != null && args.Parent.IsRoot)
                        {
                            // For now, return null, but if we want to allow this in the future then add some additional checks to guard against a misplaced tvshow.nfo
                            return(null);
                        }

                        return(new Series
                        {
                            Path = args.Path,
                            Name = Path.GetFileName(args.Path)
                        });
                    }

                    if (args.Parent != null && args.Parent.IsRoot)
                    {
                        return(null);
                    }

                    if (IsSeriesFolder(args.Path, args.FileSystemChildren, _logger, _libraryManager, false))
                    {
                        return(new Series
                        {
                            Path = args.Path,
                            Name = Path.GetFileName(args.Path)
                        });
                    }
                }
            }

            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Resolves the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns>Series.</returns>
        protected override Series Resolve(ItemResolveArgs args)
        {
            if (args.IsDirectory)
            {
                var collectionType = args.GetCollectionType();
                if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                {
                    if (args.HasParent <Series>())
                    {
                        return(null);
                    }

                    var configuredContentType = _libraryManager.GetConfiguredContentType(args.Path);
                    if (!string.Equals(configuredContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                    {
                        return(new Series
                        {
                            Path = args.Path,
                            Name = Path.GetFileName(args.Path)
                        });
                    }
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(collectionType))
                    {
                        if (args.HasParent <Series>())
                        {
                            return(null);
                        }

                        if (args.Parent.IsRoot)
                        {
                            return(null);
                        }
                        if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager, false))
                        {
                            return(new Series
                            {
                                Path = args.Path,
                                Name = Path.GetFileName(args.Path)
                            });
                        }
                    }
                }
            }

            return(null);
        }
        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);
        }