< 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: 93
Coverable lines: 93
Total lines: 300
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 1/23/2026 - 12:11:06 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: 300

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