< Summary - Jellyfin

Information
Class: Jellyfin.Api.Controllers.ChannelsController
Assembly: Jellyfin.Api
File(s): /srv/git/jellyfin/Jellyfin.Api/Controllers/ChannelsController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 47
Coverable lines: 47
Total lines: 191
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 1/23/2026 - 12:11:06 AM Line coverage: 0% (0/6) Total lines: 2543/14/2026 - 12:13:58 AM Line coverage: 0% (0/6) Total lines: 1904/19/2026 - 12:14:27 AM Line coverage: 0% (0/47) Branch coverage: 0% (0/6) Total lines: 1904/27/2026 - 12:15:04 AM Line coverage: 0% (0/47) Branch coverage: 0% (0/6) Total lines: 191 4/19/2026 - 12:14:27 AM Line coverage: 0% (0/47) Branch coverage: 0% (0/6) Total lines: 1904/27/2026 - 12:15:04 AM Line coverage: 0% (0/47) Branch coverage: 0% (0/6) Total lines: 191

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
GetChannels()100%210%
GetAllChannelFeatures()100%210%
GetChannelFeatures(...)100%210%
GetChannelItems()0%2040%
GetLatestChannelItems()0%620%

File(s)

/srv/git/jellyfin/Jellyfin.Api/Controllers/ChannelsController.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.ComponentModel.DataAnnotations;
 4using System.Threading;
 5using System.Threading.Tasks;
 6using Jellyfin.Api.Helpers;
 7using Jellyfin.Api.ModelBinders;
 8using Jellyfin.Data.Enums;
 9using Jellyfin.Database.Implementations.Enums;
 10using Jellyfin.Extensions;
 11using MediaBrowser.Controller.Channels;
 12using MediaBrowser.Controller.Dto;
 13using MediaBrowser.Controller.Entities;
 14using MediaBrowser.Controller.Library;
 15using MediaBrowser.Model.Channels;
 16using MediaBrowser.Model.Dto;
 17using MediaBrowser.Model.Querying;
 18using Microsoft.AspNetCore.Authorization;
 19using Microsoft.AspNetCore.Http;
 20using Microsoft.AspNetCore.Mvc;
 21
 22namespace Jellyfin.Api.Controllers;
 23
 24/// <summary>
 25/// Channels Controller.
 26/// </summary>
 27[Authorize]
 28[Tags("Channel")]
 29public class ChannelsController : BaseJellyfinApiController
 30{
 31    private readonly IChannelManager _channelManager;
 32    private readonly IUserManager _userManager;
 33
 34    /// <summary>
 35    /// Initializes a new instance of the <see cref="ChannelsController"/> class.
 36    /// </summary>
 37    /// <param name="channelManager">Instance of the <see cref="IChannelManager"/> interface.</param>
 38    /// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
 039    public ChannelsController(IChannelManager channelManager, IUserManager userManager)
 40    {
 041        _channelManager = channelManager;
 042        _userManager = userManager;
 043    }
 44
 45    /// <summary>
 46    /// Gets available channels.
 47    /// </summary>
 48    /// <param name="userId">User Id to filter by. Use <see cref="Guid.Empty"/> to not filter by user.</param>
 49    /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped fr
 50    /// <param name="limit">Optional. The maximum number of records to return.</param>
 51    /// <param name="supportsLatestItems">Optional. Filter by channels that support getting latest items.</param>
 52    /// <param name="supportsMediaDeletion">Optional. Filter by channels that support media deletion.</param>
 53    /// <param name="isFavorite">Optional. Filter by channels that are favorite.</param>
 54    /// <response code="200">Channels returned.</response>
 55    /// <returns>An <see cref="OkResult"/> containing the channels.</returns>
 56    [HttpGet]
 57    [ProducesResponseType(StatusCodes.Status200OK)]
 58    public async Task<ActionResult<QueryResult<BaseItemDto>>> GetChannels(
 59        [FromQuery] Guid? userId,
 60        [FromQuery] int? startIndex,
 61        [FromQuery] int? limit,
 62        [FromQuery] bool? supportsLatestItems,
 63        [FromQuery] bool? supportsMediaDeletion,
 64        [FromQuery] bool? isFavorite)
 65    {
 066        userId = RequestHelpers.GetUserId(User, userId);
 067        return await _channelManager.GetChannelsAsync(new ChannelQuery
 068        {
 069            Limit = limit,
 070            StartIndex = startIndex,
 071            UserId = userId.Value,
 072            SupportsLatestItems = supportsLatestItems,
 073            SupportsMediaDeletion = supportsMediaDeletion,
 074            IsFavorite = isFavorite
 075        }).ConfigureAwait(false);
 076    }
 77
 78    /// <summary>
 79    /// Get all channel features.
 80    /// </summary>
 81    /// <response code="200">All channel features returned.</response>
 82    /// <returns>An <see cref="OkResult"/> containing the channel features.</returns>
 83    [HttpGet("Features")]
 84    [ProducesResponseType(StatusCodes.Status200OK)]
 85    public ActionResult<IEnumerable<ChannelFeatures>> GetAllChannelFeatures()
 86    {
 087        return _channelManager.GetAllChannelFeatures();
 88    }
 89
 90    /// <summary>
 91    /// Get channel features.
 92    /// </summary>
 93    /// <param name="channelId">Channel id.</param>
 94    /// <response code="200">Channel features returned.</response>
 95    /// <returns>An <see cref="OkResult"/> containing the channel features.</returns>
 96    [HttpGet("{channelId}/Features")]
 97    public ActionResult<ChannelFeatures> GetChannelFeatures([FromRoute, Required] Guid channelId)
 98    {
 099        return _channelManager.GetChannelFeatures(channelId);
 100    }
 101
 102    /// <summary>
 103    /// Get channel items.
 104    /// </summary>
 105    /// <param name="channelId">Channel Id.</param>
 106    /// <param name="folderId">Optional. Folder Id.</param>
 107    /// <param name="userId">Optional. User Id.</param>
 108    /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped fr
 109    /// <param name="limit">Optional. The maximum number of records to return.</param>
 110    /// <param name="sortOrder">Optional. Sort Order - Ascending,Descending.</param>
 111    /// <param name="filters">Optional. Specify additional filters to apply.</param>
 112    /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited. Options: Album, AlbumArtist, Ar
 113    /// <param name="fields">Optional. Specify additional fields of information to return in the output.</param>
 114    /// <response code="200">Channel items returned.</response>
 115    /// <returns>
 116    /// A <see cref="Task"/> representing the request to get the channel items.
 117    /// The task result contains an <see cref="OkResult"/> containing the channel items.
 118    /// </returns>
 119    [HttpGet("{channelId}/Items")]
 120    public async Task<ActionResult<QueryResult<BaseItemDto>>> GetChannelItems(
 121        [FromRoute, Required] Guid channelId,
 122        [FromQuery] Guid? folderId,
 123        [FromQuery] Guid? userId,
 124        [FromQuery] int? startIndex,
 125        [FromQuery] int? limit,
 126        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
 127        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
 128        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
 129        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields)
 130    {
 0131        userId = RequestHelpers.GetUserId(User, userId);
 0132        var user = userId.IsNullOrEmpty()
 0133            ? null
 0134            : _userManager.GetUserById(userId.Value);
 135
 0136        var query = new InternalItemsQuery(user)
 0137        {
 0138            Limit = limit,
 0139            StartIndex = startIndex,
 0140            ChannelIds = [channelId],
 0141            ParentId = folderId ?? Guid.Empty,
 0142            OrderBy = RequestHelpers.GetOrderBy(sortBy, sortOrder),
 0143            DtoOptions = new DtoOptions { Fields = fields }
 0144        };
 145
 0146        query.ApplyFilters(filters);
 147
 0148        return await _channelManager.GetChannelItems(query, CancellationToken.None).ConfigureAwait(false);
 0149    }
 150
 151    /// <summary>
 152    /// Gets latest channel items.
 153    /// </summary>
 154    /// <param name="userId">Optional. User Id.</param>
 155    /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped fr
 156    /// <param name="limit">Optional. The maximum number of records to return.</param>
 157    /// <param name="filters">Optional. Specify additional filters to apply.</param>
 158    /// <param name="fields">Optional. Specify additional fields of information to return in the output.</param>
 159    /// <param name="channelIds">Optional. Specify one or more channel id's, comma delimited.</param>
 160    /// <response code="200">Latest channel items returned.</response>
 161    /// <returns>
 162    /// A <see cref="Task"/> representing the request to get the latest channel items.
 163    /// The task result contains an <see cref="OkResult"/> containing the latest channel items.
 164    /// </returns>
 165    [HttpGet("Items/Latest")]
 166    public async Task<ActionResult<QueryResult<BaseItemDto>>> GetLatestChannelItems(
 167        [FromQuery] Guid? userId,
 168        [FromQuery] int? startIndex,
 169        [FromQuery] int? limit,
 170        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
 171        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
 172        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] channelIds)
 173    {
 0174        userId = RequestHelpers.GetUserId(User, userId);
 0175        var user = userId.IsNullOrEmpty()
 0176            ? null
 0177            : _userManager.GetUserById(userId.Value);
 178
 0179        var query = new InternalItemsQuery(user)
 0180        {
 0181            Limit = limit,
 0182            StartIndex = startIndex,
 0183            ChannelIds = channelIds,
 0184            DtoOptions = new DtoOptions { Fields = fields }
 0185        };
 186
 0187        query.ApplyFilters(filters);
 188
 0189        return await _channelManager.GetLatestChannelItems(query, CancellationToken.None).ConfigureAwait(false);
 0190    }
 191}