< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Studio
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Studio.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 32
Coverable lines: 32
Total lines: 124
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/Studio.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Text.Json.Serialization;
 8using Jellyfin.Extensions;
 9using Microsoft.Extensions.Logging;
 10
 11namespace MediaBrowser.Controller.Entities
 12{
 13    /// <summary>
 14    /// Class Studio.
 15    /// </summary>
 16    public class Studio : BaseItem, IItemByName
 17    {
 18        /// <summary>
 19        /// Gets the folder containing the item.
 20        /// If the item is a folder, it returns the folder itself.
 21        /// </summary>
 22        /// <value>The containing folder path.</value>
 23        [JsonIgnore]
 024        public override string ContainingFolderPath => Path;
 25
 26        [JsonIgnore]
 027        public override bool IsDisplayedAsFolder => true;
 28
 29        [JsonIgnore]
 030        public override bool SupportsAncestors => false;
 31
 32        [JsonIgnore]
 033        public override bool SupportsPeople => false;
 34
 35        public override List<string> GetUserDataKeys()
 36        {
 037            var list = base.GetUserDataKeys();
 38
 039            list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
 040            return list;
 41        }
 42
 43        public override string CreatePresentationUniqueKey()
 44        {
 045            return GetUserDataKeys()[0];
 46        }
 47
 48        public override double GetDefaultPrimaryImageAspectRatio()
 49        {
 050            double value = 16;
 051            value /= 9;
 52
 053            return value;
 54        }
 55
 56        public override bool CanDelete()
 57        {
 058            return false;
 59        }
 60
 61        public override bool IsSaveLocalMetadataEnabled()
 62        {
 063            return true;
 64        }
 65
 66        public IList<BaseItem> GetTaggedItems(InternalItemsQuery query)
 67        {
 068            query.StudioIds = new[] { Id };
 69
 070            return LibraryManager.GetItemList(query);
 71        }
 72
 73        public static string GetPath(string name)
 74        {
 075            return GetPath(name, true);
 76        }
 77
 78        public static string GetPath(string name, bool normalizeName)
 79        {
 80            // Trim the period at the end because windows will have a hard time with that
 081            var validName = normalizeName ?
 082                FileSystem.GetValidFilename(name).Trim().TrimEnd('.') :
 083                name;
 84
 085            return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.StudioPath, validName);
 86        }
 87
 88        private string GetRebasedPath()
 89        {
 090            return GetPath(System.IO.Path.GetFileName(Path), false);
 91        }
 92
 93        public override bool RequiresRefresh()
 94        {
 095            var newPath = GetRebasedPath();
 096            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 97            {
 098                Logger.LogDebug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath);
 099                return true;
 100            }
 101
 0102            return base.RequiresRefresh();
 103        }
 104
 105        /// <summary>
 106        /// This is called before any metadata refresh and returns true or false indicating if changes were made.
 107        /// </summary>
 108        /// <param name="replaceAllMetadata"><c>true</c> to replace all metadata, <c>false</c> to not.</param>
 109        /// <returns><c>true</c> if changes were made, <c>false</c> if not.</returns>
 110        public override bool BeforeMetadataRefresh(bool replaceAllMetadata)
 111        {
 0112            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata);
 113
 0114            var newPath = GetRebasedPath();
 0115            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 116            {
 0117                Path = newPath;
 0118                hasChanges = true;
 119            }
 120
 0121            return hasChanges;
 122        }
 123    }
 124}