< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.LiveTv.LiveTvChannel
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
Line coverage
3%
Covered lines: 1
Uncovered lines: 32
Coverable lines: 33
Total lines: 161
Line coverage: 3%
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
get_SupportsPositionTicksResume()100%210%
get_SourceType()100%210%
get_EnableRememberingTrackSelections()100%210%
get_LocationType()100%210%
get_MediaType()0%620%
get_IsKids()100%210%
GetUserDataKeys()0%620%
GetBlockUnratedType()100%210%
CreateSortName()0%7280%
GetClientTypeName()100%11100%
GetTaggedItems()100%210%
GetMediaSources(...)100%210%
GetMediaStreams()100%210%
GetInternalMetadataPath(...)100%210%
CanDelete()100%210%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/LiveTv/LiveTvChannel.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 Jellyfin.Extensions;
 12using MediaBrowser.Controller.Entities;
 13using MediaBrowser.Model.Dto;
 14using MediaBrowser.Model.Entities;
 15using MediaBrowser.Model.LiveTv;
 16using MediaBrowser.Model.MediaInfo;
 17
 18namespace MediaBrowser.Controller.LiveTv
 19{
 20    public class LiveTvChannel : BaseItem, IHasMediaSources, IHasProgramAttributes
 21    {
 22        [JsonIgnore]
 023        public override bool SupportsPositionTicksResume => false;
 24
 25        [JsonIgnore]
 026        public override SourceType SourceType => SourceType.LiveTV;
 27
 28        [JsonIgnore]
 029        public override bool EnableRememberingTrackSelections => false;
 30
 31        /// <summary>
 32        /// Gets or sets the number.
 33        /// </summary>
 34        /// <value>The number.</value>
 35        public string Number { get; set; }
 36
 37        /// <summary>
 38        /// Gets or sets the type of the channel.
 39        /// </summary>
 40        /// <value>The type of the channel.</value>
 41        public ChannelType ChannelType { get; set; }
 42
 43        [JsonIgnore]
 044        public override LocationType LocationType => LocationType.Remote;
 45
 46        [JsonIgnore]
 047        public override MediaType MediaType => ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video;
 48
 49        [JsonIgnore]
 50        public bool IsMovie { get; set; }
 51
 52        /// <summary>
 53        /// Gets or sets a value indicating whether this instance is sports.
 54        /// </summary>
 55        /// <value><c>true</c> if this instance is sports; otherwise, <c>false</c>.</value>
 56        [JsonIgnore]
 57        public bool IsSports { get; set; }
 58
 59        /// <summary>
 60        /// Gets or sets a value indicating whether this instance is series.
 61        /// </summary>
 62        /// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value>
 63        [JsonIgnore]
 64        public bool IsSeries { get; set; }
 65
 66        /// <summary>
 67        /// Gets or sets a value indicating whether this instance is news.
 68        /// </summary>
 69        /// <value><c>true</c> if this instance is news; otherwise, <c>false</c>.</value>
 70        [JsonIgnore]
 71        public bool IsNews { get; set; }
 72
 73        /// <summary>
 74        /// Gets a value indicating whether this instance is kids.
 75        /// </summary>
 76        /// <value><c>true</c> if this instance is kids; otherwise, <c>false</c>.</value>
 77        [JsonIgnore]
 078        public bool IsKids => Tags.Contains("Kids", StringComparison.OrdinalIgnoreCase);
 79
 80        [JsonIgnore]
 81        public bool IsRepeat { get; set; }
 82
 83        /// <summary>
 84        /// Gets or sets the episode title.
 85        /// </summary>
 86        /// <value>The episode title.</value>
 87        [JsonIgnore]
 88        public string EpisodeTitle { get; set; }
 89
 90        public override List<string> GetUserDataKeys()
 91        {
 092            var list = base.GetUserDataKeys();
 93
 094            if (!ConfigurationManager.Configuration.DisableLiveTvChannelUserDataName)
 95            {
 096                list.Insert(0, GetClientTypeName() + "-" + Name);
 97            }
 98
 099            return list;
 100        }
 101
 102        public override UnratedItem GetBlockUnratedType()
 103        {
 0104            return UnratedItem.LiveTvChannel;
 105        }
 106
 107        protected override string CreateSortName()
 108        {
 0109            if (double.TryParse(Number, CultureInfo.InvariantCulture, out double number))
 110            {
 0111                return string.Format(CultureInfo.InvariantCulture, "{0:00000.0}", number) + "-" + (Name ?? string.Empty)
 112            }
 113
 0114            return (Number ?? string.Empty) + "-" + (Name ?? string.Empty);
 115        }
 116
 117        public override string GetClientTypeName()
 118        {
 1119            return "TvChannel";
 120        }
 121
 122        public IEnumerable<BaseItem> GetTaggedItems()
 0123            => Enumerable.Empty<BaseItem>();
 124
 125        public override List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
 126        {
 0127            var list = new List<MediaSourceInfo>();
 128
 0129            var info = new MediaSourceInfo
 0130            {
 0131                Id = Id.ToString("N", CultureInfo.InvariantCulture),
 0132                Protocol = PathProtocol ?? MediaProtocol.File,
 0133                MediaStreams = Array.Empty<MediaStream>(),
 0134                Name = Name,
 0135                Path = Path,
 0136                RunTimeTicks = RunTimeTicks,
 0137                Type = MediaSourceType.Placeholder,
 0138                IsInfiniteStream = RunTimeTicks is null
 0139            };
 140
 0141            list.Add(info);
 142
 0143            return list;
 144        }
 145
 146        public override List<MediaStream> GetMediaStreams()
 147        {
 0148            return new List<MediaStream>();
 149        }
 150
 151        protected override string GetInternalMetadataPath(string basePath)
 152        {
 0153            return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N", CultureInfo.InvariantCulture), "metadata"
 154        }
 155
 156        public override bool CanDelete()
 157        {
 0158            return false;
 159        }
 160    }
 161}