< 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: 95
Coverable lines: 95
Total lines: 306
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 2/13/2026 - 12:11:21 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: 306

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
GetTrailers()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    public async Task<ActionResult<QueryResult<BaseItemDto>>> GetTrailers(
 126        [FromQuery] Guid? userId,
 127        [FromQuery] string? maxOfficialRating,
 128        [FromQuery] bool? hasThemeSong,
 129        [FromQuery] bool? hasThemeVideo,
 130        [FromQuery] bool? hasSubtitles,
 131        [FromQuery] bool? hasSpecialFeature,
 132        [FromQuery] bool? hasTrailer,
 133        [FromQuery] Guid? adjacentTo,
 134        [FromQuery] int? parentIndexNumber,
 135        [FromQuery] bool? hasParentalRating,
 136        [FromQuery] bool? isHd,
 137        [FromQuery] bool? is4K,
 138        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] locationTypes,
 139        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] excludeLocationTypes,
 140        [FromQuery] bool? isMissing,
 141        [FromQuery] bool? isUnaired,
 142        [FromQuery] double? minCommunityRating,
 143        [FromQuery] double? minCriticRating,
 144        [FromQuery] DateTime? minPremiereDate,
 145        [FromQuery] DateTime? minDateLastSaved,
 146        [FromQuery] DateTime? minDateLastSavedForUser,
 147        [FromQuery] DateTime? maxPremiereDate,
 148        [FromQuery] bool? hasOverview,
 149        [FromQuery] bool? hasImdbId,
 150        [FromQuery] bool? hasTmdbId,
 151        [FromQuery] bool? hasTvdbId,
 152        [FromQuery] bool? isMovie,
 153        [FromQuery] bool? isSeries,
 154        [FromQuery] bool? isNews,
 155        [FromQuery] bool? isKids,
 156        [FromQuery] bool? isSports,
 157        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeItemIds,
 158        [FromQuery] int? startIndex,
 159        [FromQuery] int? limit,
 160        [FromQuery] bool? recursive,
 161        [FromQuery] string? searchTerm,
 162        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
 163        [FromQuery] Guid? parentId,
 164        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
 165        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
 166        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
 167        [FromQuery] bool? isFavorite,
 168        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
 169        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] imageTypes,
 170        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
 171        [FromQuery] bool? isPlayed,
 172        [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
 173        [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] officialRatings,
 174        [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] tags,
 175        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] int[] years,
 176        [FromQuery] bool? enableUserData,
 177        [FromQuery] int? imageTypeLimit,
 178        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
 179        [FromQuery] string? person,
 180        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] personIds,
 181        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
 182        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] studios,
 183        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] artists,
 184        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeArtistIds,
 185        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] artistIds,
 186        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumArtistIds,
 187        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] contributingArtistIds,
 188        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] albums,
 189        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumIds,
 190        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids,
 191        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] VideoType[] videoTypes,
 192        [FromQuery] string? minOfficialRating,
 193        [FromQuery] bool? isLocked,
 194        [FromQuery] bool? isPlaceHolder,
 195        [FromQuery] bool? hasOfficialRating,
 196        [FromQuery] bool? collapseBoxSetItems,
 197        [FromQuery] int? minWidth,
 198        [FromQuery] int? minHeight,
 199        [FromQuery] int? maxWidth,
 200        [FromQuery] int? maxHeight,
 201        [FromQuery] bool? is3D,
 202        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SeriesStatus[] seriesStatus,
 203        [FromQuery] string? nameStartsWithOrGreater,
 204        [FromQuery] string? nameStartsWith,
 205        [FromQuery] string? nameLessThan,
 206        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] studioIds,
 207        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
 208        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] audioLanguages,
 209        [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] subtitleLanguages,
 210        [FromQuery] bool enableTotalRecordCount = true,
 211        [FromQuery] bool? enableImages = true)
 212    {
 0213        var includeItemTypes = new[] { BaseItemKind.Trailer };
 214
 0215        return await _itemsController
 0216            .GetItems(
 0217                userId,
 0218                maxOfficialRating,
 0219                hasThemeSong,
 0220                hasThemeVideo,
 0221                hasSubtitles,
 0222                hasSpecialFeature,
 0223                hasTrailer,
 0224                adjacentTo,
 0225                null,
 0226                parentIndexNumber,
 0227                hasParentalRating,
 0228                isHd,
 0229                is4K,
 0230                locationTypes,
 0231                excludeLocationTypes,
 0232                isMissing,
 0233                isUnaired,
 0234                minCommunityRating,
 0235                minCriticRating,
 0236                minPremiereDate,
 0237                minDateLastSaved,
 0238                minDateLastSavedForUser,
 0239                maxPremiereDate,
 0240                hasOverview,
 0241                hasImdbId,
 0242                hasTmdbId,
 0243                hasTvdbId,
 0244                isMovie,
 0245                isSeries,
 0246                isNews,
 0247                isKids,
 0248                isSports,
 0249                excludeItemIds,
 0250                startIndex,
 0251                limit,
 0252                recursive,
 0253                searchTerm,
 0254                sortOrder,
 0255                parentId,
 0256                fields,
 0257                excludeItemTypes,
 0258                includeItemTypes,
 0259                filters,
 0260                isFavorite,
 0261                mediaTypes,
 0262                imageTypes,
 0263                sortBy,
 0264                isPlayed,
 0265                genres,
 0266                officialRatings,
 0267                tags,
 0268                years,
 0269                enableUserData,
 0270                imageTypeLimit,
 0271                enableImageTypes,
 0272                person,
 0273                personIds,
 0274                personTypes,
 0275                studios,
 0276                artists,
 0277                excludeArtistIds,
 0278                artistIds,
 0279                albumArtistIds,
 0280                contributingArtistIds,
 0281                albums,
 0282                albumIds,
 0283                ids,
 0284                videoTypes,
 0285                minOfficialRating,
 0286                isLocked,
 0287                isPlaceHolder,
 0288                hasOfficialRating,
 0289                collapseBoxSetItems,
 0290                minWidth,
 0291                minHeight,
 0292                maxWidth,
 0293                maxHeight,
 0294                is3D,
 0295                seriesStatus,
 0296                nameStartsWithOrGreater,
 0297                nameStartsWith,
 0298                nameLessThan,
 0299                studioIds,
 0300                genreIds,
 0301                audioLanguages,
 0302                subtitleLanguages,
 0303                enableTotalRecordCount,
 0304                enableImages).ConfigureAwait(false);
 0305    }
 306}