< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Trailer
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Trailer.cs
Line coverage
13%
Covered lines: 3
Uncovered lines: 20
Coverable lines: 23
Total lines: 84
Line coverage: 13%
Branch coverage
0%
Covered branches: 0
Total branches: 12
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
.ctor()100%11100%
GetDefaultPrimaryImageAspectRatio()100%210%
GetBlockUnratedType()100%210%
GetLookupInfo()0%2040%
BeforeMetadataRefresh(...)0%7280%

File(s)

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

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CA1819, CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Globalization;
 8using System.Text.Json.Serialization;
 9using Jellyfin.Data.Enums;
 10using MediaBrowser.Controller.Providers;
 11using MediaBrowser.Model.Entities;
 12using MediaBrowser.Model.Providers;
 13
 14namespace MediaBrowser.Controller.Entities
 15{
 16    /// <summary>
 17    /// Class Trailer.
 18    /// </summary>
 19    public class Trailer : Video, IHasLookupInfo<TrailerInfo>
 20    {
 821        public Trailer()
 22        {
 823            TrailerTypes = Array.Empty<TrailerType>();
 824        }
 25
 26        public TrailerType[] TrailerTypes { get; set; }
 27
 28        public override double GetDefaultPrimaryImageAspectRatio()
 029            => 2.0 / 3;
 30
 31        public override UnratedItem GetBlockUnratedType()
 32        {
 033            return UnratedItem.Trailer;
 34        }
 35
 36        public TrailerInfo GetLookupInfo()
 37        {
 038            var info = GetItemLookupInfo<TrailerInfo>();
 39
 040            if (!IsInMixedFolder && IsFileProtocol)
 41            {
 042                info.Name = System.IO.Path.GetFileName(ContainingFolderPath);
 43            }
 44
 045            return info;
 46        }
 47
 48        public override bool BeforeMetadataRefresh(bool replaceAllMetadata)
 49        {
 050            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata);
 51
 052            if (!ProductionYear.HasValue)
 53            {
 054                var info = LibraryManager.ParseName(Name);
 55
 056                var yearInName = info.Year;
 57
 058                if (yearInName.HasValue)
 59                {
 060                    ProductionYear = yearInName;
 061                    hasChanges = true;
 62                }
 63                else
 64                {
 65                    // Try to get the year from the folder name
 066                    if (!IsInMixedFolder)
 67                    {
 068                        info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
 69
 070                        yearInName = info.Year;
 71
 072                        if (yearInName.HasValue)
 73                        {
 074                            ProductionYear = yearInName;
 075                            hasChanges = true;
 76                        }
 77                    }
 78                }
 79            }
 80
 081            return hasChanges;
 82        }
 83    }
 84}