< Summary - Jellyfin

Information
Class: Jellyfin.Api.Controllers.TrailersController
Assembly: Jellyfin.Api
File(s): /srv/git/jellyfin/Jellyfin.Api/Controllers/TrailersController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 307
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 4/8/2026 - 12:11:47 AM Line coverage: 0% (0/92) Total lines: 2984/27/2026 - 12:15:04 AM Line coverage: 0% (0/92) Total lines: 2995/4/2026 - 12:15:16 AM Line coverage: 0% (0/93) Total lines: 3005/16/2026 - 12:15:55 AM Line coverage: 0% (0/95) Total lines: 3066/22/2026 - 12:15:37 AM Line coverage: 0% (0/3) Total lines: 307

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Threading.Tasks;
 3using Jellyfin.Api.ModelBinders;
 4using Jellyfin.Data.Enums;
 5using Jellyfin.Database.Implementations.Enums;
 6using MediaBrowser.Model.Dto;
 7using MediaBrowser.Model.Entities;
 8using MediaBrowser.Model.Querying;
 9using Microsoft.AspNetCore.Authorization;
 10using Microsoft.AspNetCore.Http;
 11using Microsoft.AspNetCore.Mvc;
 12
 13namespace Jellyfin.Api.Controllers;
 14
 15/// <summary>
 16/// The trailers controller.
 17/// </summary>
 18[Authorize]
 19[Tags("Trailer")]
 20public class TrailersController : BaseJellyfinApiController
 21{
 22    private readonly ItemsController _itemsController;
 23
 24    /// <summary>
 25    /// Initializes a new instance of the <see cref="TrailersController"/> class.
 26    /// </summary>
 27    /// <param name="itemsController">Instance of <see cref="ItemsController"/>.</param>
 028    public TrailersController(ItemsController itemsController)
 29    {
 030        _itemsController = itemsController;
 031    }
 32
 33    /// <summary>
 34    /// Finds movies and trailers similar to a given trailer.
 35    /// </summary>
 36    /// <param name="userId">The user id supplied as query parameter; this is required when not using an API key.</param
 37    /// <param name="maxOfficialRating">Optional filter by maximum official rating (PG, PG-13, TV-MA, etc).</param>
 38    /// <param name="hasThemeSong">Optional filter by items with theme songs.</param>
 39    /// <param name="hasThemeVideo">Optional filter by items with theme videos.</param>
 40    /// <param name="hasSubtitles">Optional filter by items with subtitles.</param>
 41    /// <param name="hasSpecialFeature">Optional filter by items with special features.</param>
 42    /// <param name="hasTrailer">Optional filter by items with trailers.</param>
 43    /// <param name="adjacentTo">Optional. Return items that are siblings of a supplied item.</param>
 44    /// <param name="parentIndexNumber">Optional filter by parent index number.</param>
 45    /// <param name="hasParentalRating">Optional filter by items that have or do not have a parental rating.</param>
 46    /// <param name="isHd">Optional filter by items that are HD or not.</param>
 47    /// <param name="is4K">Optional filter by items that are 4K or not.</param>
 48    /// <param name="locationTypes">Optional. If specified, results will be filtered based on LocationType. This allows 
 49    /// <param name="excludeLocationTypes">Optional. If specified, results will be filtered based on the LocationType. T
 50    /// <param name="isMissing">Optional filter by items that are missing episodes or not.</param>
 51    /// <param name="isUnaired">Optional filter by items that are unaired episodes or not.</param>
 52    /// <param name="minCommunityRating">Optional filter by minimum community rating.</param>
 53    /// <param name="minCriticRating">Optional filter by minimum critic rating.</param>
 54    /// <param name="minPremiereDate">Optional. The minimum premiere date. Format = ISO.</param>
 55    /// <param name="minDateLastSaved">Optional. The minimum last saved date. Format = ISO.</param>
 56    /// <param name="minDateLastSavedForUser">Optional. The minimum last saved date for the current user. Format = ISO.<
 57    /// <param name="maxPremiereDate">Optional. The maximum premiere date. Format = ISO.</param>
 58    /// <param name="hasOverview">Optional filter by items that have an overview or not.</param>
 59    /// <param name="hasImdbId">Optional filter by items that have an IMDb id or not.</param>
 60    /// <param name="hasTmdbId">Optional filter by items that have a TMDb id or not.</param>
 61    /// <param name="hasTvdbId">Optional filter by items that have a TVDb id or not.</param>
 62    /// <param name="isMovie">Optional filter for live tv movies.</param>
 63    /// <param name="isSeries">Optional filter for live tv series.</param>
 64    /// <param name="isNews">Optional filter for live tv news.</param>
 65    /// <param name="isKids">Optional filter for live tv kids.</param>
 66    /// <param name="isSports">Optional filter for live tv sports.</param>
 67    /// <param name="excludeItemIds">Optional. If specified, results will be filtered by excluding item ids. This allows
 68    /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped fr
 69    /// <param name="limit">Optional. The maximum number of records to return.</param>
 70    /// <param name="recursive">When searching within folders, this determines whether or not the search will be recursi
 71    /// <param name="searchTerm">Optional. Filter based on a search term.</param>
 72    /// <param name="sortOrder">Sort Order - Ascending, Descending.</param>
 73    /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</
 74    /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows mul
 75    /// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows 
 76    /// <param name="filters">Optional. Specify additional filters to apply. This allows multiple, comma delimited. Opti
 77    /// <param name="isFavorite">Optional filter by items that are marked as favorite, or not.</param>
 78    /// <param name="mediaTypes">Optional filter by MediaType. Allows multiple, comma delimited.</param>
 79    /// <param name="imageTypes">Optional. If specified, results will be filtered based on those containing image types.
 80    /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited. Options: Album, AlbumArtist, Ar
 81    /// <param name="isPlayed">Optional filter by items that are played, or not.</param>
 82    /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe
 83    /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This all
 84    /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe del
 85    /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multi
 86    /// <param name="enableUserData">Optional, include user data.</param>
 87    /// <param name="imageTypeLimit">Optional, the max number of images to return, per image type.</param>
 88    /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
 89    /// <param name="person">Optional. If specified, results will be filtered to include only those containing the speci
 90    /// <param name="personIds">Optional. If specified, results will be filtered to include only those containing the sp
 91    /// <param name="personTypes">Optional. If specified, along with Person, results will be filtered to include only th
 92    /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pi
 93    /// <param name="artists">Optional. If specified, results will be filtered based on artists. This allows multiple, p
 94    /// <param name="excludeArtistIds">Optional. If specified, results will be filtered based on artist id. This allows 
 95    /// <param name="artistIds">Optional. If specified, results will be filtered to include only those containing the sp
 96    /// <param name="albumArtistIds">Optional. If specified, results will be filtered to include only those containing t
 97    /// <param name="contributingArtistIds">Optional. If specified, results will be filtered to include only those conta
 98    /// <param name="albums">Optional. If specified, results will be filtered based on album. This allows multiple, pipe
 99    /// <param name="albumIds">Optional. If specified, results will be filtered based on album id. This allows multiple,
 100    /// <param name="ids">Optional. If specific items are needed, specify a list of item id's to retrieve. This allows m
 101    /// <param name="videoTypes">Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma deli
 102    /// <param name="minOfficialRating">Optional filter by minimum official rating (PG, PG-13, TV-MA, etc).</param>
 103    /// <param name="isLocked">Optional filter by items that are locked.</param>
 104    /// <param name="isPlaceHolder">Optional filter by items that are placeholders.</param>
 105    /// <param name="hasOfficialRating">Optional filter by items that have official ratings.</param>
 106    /// <param name="collapseBoxSetItems">Whether or not to hide items behind their boxsets.</param>
 107    /// <param name="minWidth">Optional. Filter by the minimum width of the item.</param>
 108    /// <param name="minHeight">Optional. Filter by the minimum height of the item.</param>
 109    /// <param name="maxWidth">Optional. Filter by the maximum width of the item.</param>
 110    /// <param name="maxHeight">Optional. Filter by the maximum height of the item.</param>
 111    /// <param name="is3D">Optional filter by items that are 3D, or not.</param>
 112    /// <param name="seriesStatus">Optional filter by Series Status. Allows multiple, comma delimited.</param>
 113    /// <param name="nameStartsWithOrGreater">Optional filter by items whose name is sorted equally or greater than a gi
 114    /// <param name="nameStartsWith">Optional filter by items whose name is sorted equally than a given input string.</p
 115    /// <param name="nameLessThan">Optional filter by items whose name is equally or lesser than a given input string.</
 116    /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multipl
 117    /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple,
 118    /// <param name="audioLanguages">Optional. If specified, results will be filtered based on audio language. This allo
 119    /// <param name="subtitleLanguages">Optional. If specified, results will be filtered based on subtitale language. Th
 120    /// <param name="enableTotalRecordCount">Optional. Enable the total record count.</param>
 121    /// <param name="enableImages">Optional, include image information in output.</param>
 122    /// <returns>A <see cref="QueryResult{BaseItemDto}"/> with the trailers.</returns>
 123    [HttpGet]
 124    [ProducesResponseType(StatusCodes.Status200OK)]
 125    [Obsolete("Use GetItems with includeItemTypes=Trailer instead.")]
 126    public async Task<ActionResult<QueryResult<BaseItemDto>>> GetTrailers(
 127        [FromQuery] Guid? userId,
 128        [FromQuery] string? maxOfficialRating,
 129        [FromQuery] bool? hasThemeSong,
 130        [FromQuery] bool? hasThemeVideo,
 131        [FromQuery] bool? hasSubtitles,
 132        [FromQuery] bool? hasSpecialFeature,
 133        [FromQuery] bool? hasTrailer,
 134        [FromQuery] Guid? adjacentTo,
 135        [FromQuery] int? parentIndexNumber,
 136        [FromQuery] bool? hasParentalRating,
 137        [FromQuery] bool? isHd,
 138        [FromQuery] bool? is4K,
 139        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] locationTypes,
 140        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] excludeLocationTypes,
 141        [FromQuery] bool? isMissing,
 142        [FromQuery] bool? isUnaired,
 143        [FromQuery] double? minCommunityRating,
 144        [FromQuery] double? minCriticRating,
 145        [FromQuery] DateTime? minPremiereDate,
 146        [FromQuery] DateTime? minDateLastSaved,
 147        [FromQuery] DateTime? minDateLastSavedForUser,
 148        [FromQuery] DateTime? maxPremiereDate,
 149        [FromQuery] bool? hasOverview,
 150        [FromQuery] bool? hasImdbId,
 151        [FromQuery] bool? hasTmdbId,
 152        [FromQuery] bool? hasTvdbId,
 153        [FromQuery] bool? isMovie,
 154        [FromQuery] bool? isSeries,
 155        [FromQuery] bool? isNews,
 156        [FromQuery] bool? isKids,
 157        [FromQuery] bool? isSports,
 158        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeItemIds,
 159        [FromQuery] int? startIndex,
 160        [FromQuery] int? limit,
 161        [FromQuery] bool? recursive,
 162        [FromQuery] string? searchTerm,
 163        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
 164        [FromQuery] Guid? parentId,
 165        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
 166        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
 167        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
 168        [FromQuery] bool? isFavorite,
 169        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
 170        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] imageTypes,
 171        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
 172        [FromQuery] bool? isPlayed,
 173        [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
 174        [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] officialRatings,
 175        [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] tags,
 176        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] int[] years,
 177        [FromQuery] bool? enableUserData,
 178        [FromQuery] int? imageTypeLimit,
 179        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
 180        [FromQuery] string? person,
 181        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] personIds,
 182        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
 183        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] studios,
 184        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] artists,
 185        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeArtistIds,
 186        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] artistIds,
 187        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumArtistIds,
 188        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] contributingArtistIds,
 189        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] albums,
 190        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumIds,
 191        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids,
 192        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] VideoType[] videoTypes,
 193        [FromQuery] string? minOfficialRating,
 194        [FromQuery] bool? isLocked,
 195        [FromQuery] bool? isPlaceHolder,
 196        [FromQuery] bool? hasOfficialRating,
 197        [FromQuery] bool? collapseBoxSetItems,
 198        [FromQuery] int? minWidth,
 199        [FromQuery] int? minHeight,
 200        [FromQuery] int? maxWidth,
 201        [FromQuery] int? maxHeight,
 202        [FromQuery] bool? is3D,
 203        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SeriesStatus[] seriesStatus,
 204        [FromQuery] string? nameStartsWithOrGreater,
 205        [FromQuery] string? nameStartsWith,
 206        [FromQuery] string? nameLessThan,
 207        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] studioIds,
 208        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
 209        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] audioLanguages,
 210        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] subtitleLanguages,
 211        [FromQuery] bool enableTotalRecordCount = true,
 212        [FromQuery] bool? enableImages = true)
 213    {
 214        var includeItemTypes = new[] { BaseItemKind.Trailer };
 215
 216        return await _itemsController
 217            .GetItems(
 218                userId,
 219                maxOfficialRating,
 220                hasThemeSong,
 221                hasThemeVideo,
 222                hasSubtitles,
 223                hasSpecialFeature,
 224                hasTrailer,
 225                adjacentTo,
 226                null,
 227                parentIndexNumber,
 228                hasParentalRating,
 229                isHd,
 230                is4K,
 231                locationTypes,
 232                excludeLocationTypes,
 233                isMissing,
 234                isUnaired,
 235                minCommunityRating,
 236                minCriticRating,
 237                minPremiereDate,
 238                minDateLastSaved,
 239                minDateLastSavedForUser,
 240                maxPremiereDate,
 241                hasOverview,
 242                hasImdbId,
 243                hasTmdbId,
 244                hasTvdbId,
 245                isMovie,
 246                isSeries,
 247                isNews,
 248                isKids,
 249                isSports,
 250                excludeItemIds,
 251                startIndex,
 252                limit,
 253                recursive,
 254                searchTerm,
 255                sortOrder,
 256                parentId,
 257                fields,
 258                excludeItemTypes,
 259                includeItemTypes,
 260                filters,
 261                isFavorite,
 262                mediaTypes,
 263                imageTypes,
 264                sortBy,
 265                isPlayed,
 266                genres,
 267                officialRatings,
 268                tags,
 269                years,
 270                enableUserData,
 271                imageTypeLimit,
 272                enableImageTypes,
 273                person,
 274                personIds,
 275                personTypes,
 276                studios,
 277                artists,
 278                excludeArtistIds,
 279                artistIds,
 280                albumArtistIds,
 281                contributingArtistIds,
 282                albums,
 283                albumIds,
 284                ids,
 285                videoTypes,
 286                minOfficialRating,
 287                isLocked,
 288                isPlaceHolder,
 289                hasOfficialRating,
 290                collapseBoxSetItems,
 291                minWidth,
 292                minHeight,
 293                maxWidth,
 294                maxHeight,
 295                is3D,
 296                seriesStatus,
 297                nameStartsWithOrGreater,
 298                nameStartsWith,
 299                nameLessThan,
 300                studioIds,
 301                genreIds,
 302                audioLanguages,
 303                subtitleLanguages,
 304                enableTotalRecordCount,
 305                enableImages).ConfigureAwait(false);
 306    }
 307}