< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Movies.Movie
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Movies/Movie.cs
Line coverage
5%
Covered lines: 2
Uncovered lines: 33
Coverable lines: 35
Total lines: 125
Line coverage: 5.7%
Branch coverage
0%
Covered branches: 0
Total branches: 18
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

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_SpecialFeatureIds()100%210%
get_LocalTrailers()100%210%
get_CollectionName()100%11100%
set_CollectionName(...)100%11100%
GetDefaultPrimaryImageAspectRatio()0%620%
GetBlockUnratedType()100%210%
GetLookupInfo()0%7280%
BeforeMetadataRefresh(...)0%7280%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/Movies/Movie.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Globalization;
 8using System.Linq;
 9using System.Text.Json.Serialization;
 10using Jellyfin.Data.Enums;
 11using MediaBrowser.Controller.Providers;
 12using MediaBrowser.Model.Entities;
 13using MediaBrowser.Model.Providers;
 14
 15namespace MediaBrowser.Controller.Entities.Movies
 16{
 17    /// <summary>
 18    /// Class Movie.
 19    /// </summary>
 20    public class Movie : Video, IHasSpecialFeatures, IHasTrailers, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping
 21    {
 22        /// <inheritdoc />
 23        [JsonIgnore]
 024        public IReadOnlyList<Guid> SpecialFeatureIds => GetExtras()
 025            .Where(extra => extra.ExtraType is not null && extra is Video)
 026            .Select(extra => extra.Id)
 027            .ToArray();
 28
 29        /// <inheritdoc />
 30        [JsonIgnore]
 031        public IReadOnlyList<BaseItem> LocalTrailers => GetExtras()
 032            .Where(extra => extra.ExtraType == Model.Entities.ExtraType.Trailer)
 033            .ToArray();
 34
 35        /// <summary>
 36        /// Gets or sets the name of the TMDb collection.
 37        /// </summary>
 38        /// <value>The name of the TMDb collection.</value>
 39        public string TmdbCollectionName { get; set; }
 40
 41        [JsonIgnore]
 42        public string CollectionName
 43        {
 144            get => TmdbCollectionName;
 145            set => TmdbCollectionName = value;
 46        }
 47
 48        public override double GetDefaultPrimaryImageAspectRatio()
 49        {
 50            // hack for tv plugins
 051            if (SourceType == SourceType.Channel)
 52            {
 053                return 0;
 54            }
 55
 056            return 2.0 / 3;
 57        }
 58
 59        /// <inheritdoc />
 60        public override UnratedItem GetBlockUnratedType()
 61        {
 062            return UnratedItem.Movie;
 63        }
 64
 65        public MovieInfo GetLookupInfo()
 66        {
 067            var info = GetItemLookupInfo<MovieInfo>();
 68
 069            if (!IsInMixedFolder)
 70            {
 071                var name = System.IO.Path.GetFileName(ContainingFolderPath);
 72
 073                if (VideoType == VideoType.VideoFile || VideoType == VideoType.Iso)
 74                {
 075                    if (string.Equals(name, System.IO.Path.GetFileName(Path), StringComparison.OrdinalIgnoreCase))
 76                    {
 77                        // if the folder has the file extension, strip it
 078                        name = System.IO.Path.GetFileNameWithoutExtension(name);
 79                    }
 80                }
 81
 082                info.Name = name;
 83            }
 84
 085            return info;
 86        }
 87
 88        /// <inheritdoc />
 89        public override bool BeforeMetadataRefresh(bool replaceAllMetadata)
 90        {
 091            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata);
 92
 093            if (!ProductionYear.HasValue)
 94            {
 095                var info = LibraryManager.ParseName(Name);
 96
 097                var yearInName = info.Year;
 98
 099                if (yearInName.HasValue)
 100                {
 0101                    ProductionYear = yearInName;
 0102                    hasChanges = true;
 103                }
 104                else
 105                {
 106                    // Try to get the year from the folder name
 0107                    if (!IsInMixedFolder)
 108                    {
 0109                        info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
 110
 0111                        yearInName = info.Year;
 112
 0113                        if (yearInName.HasValue)
 114                        {
 0115                            ProductionYear = yearInName;
 0116                            hasChanges = true;
 117                        }
 118                    }
 119                }
 120            }
 121
 0122            return hasChanges;
 123        }
 124    }
 125}