using System; using Jellyfin.Api.Constants; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Querying; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; namespace Jellyfin.Api.Controllers { /// /// The trailers controller. /// [Authorize(Policy = Policies.DefaultAuthorization)] public class TrailersController : BaseJellyfinApiController { private readonly IUserManager _userManager; private readonly ILibraryManager _libraryManager; private readonly ILogger _logger; private readonly IDtoService _dtoService; private readonly ILocalizationManager _localizationManager; /// /// Initializes a new instance of the class. /// /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. public TrailersController( ILoggerFactory loggerFactory, IUserManager userManager, ILibraryManager libraryManager, IDtoService dtoService, ILocalizationManager localizationManager) { _userManager = userManager; _libraryManager = libraryManager; _dtoService = dtoService; _localizationManager = localizationManager; _logger = loggerFactory.CreateLogger(); } /// /// Finds movies and trailers similar to a given trailer. /// /// The user id. /// Optional filter by maximum official rating (PG, PG-13, TV-MA, etc). /// Optional filter by items with theme songs. /// Optional filter by items with theme videos. /// Optional filter by items with subtitles. /// Optional filter by items with special features. /// Optional filter by items with trailers. /// Optional. Return items that are siblings of a supplied item. /// Optional filter by parent index number. /// Optional filter by items that have or do not have a parental rating. /// Optional filter by items that are HD or not. /// Optional filter by items that are 4K or not. /// Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted. /// Optional. If specified, results will be filtered based on the LocationType. This allows multiple, comma delimeted. /// Optional filter by items that are missing episodes or not. /// Optional filter by items that are unaired episodes or not. /// Optional filter by minimum community rating. /// Optional filter by minimum critic rating. /// Optional. The minimum premiere date. Format = ISO. /// Optional. The minimum last saved date. Format = ISO. /// Optional. The minimum last saved date for the current user. Format = ISO. /// Optional. The maximum premiere date. Format = ISO. /// Optional filter by items that have an overview or not. /// Optional filter by items that have an imdb id or not. /// Optional filter by items that have a tmdb id or not. /// Optional filter by items that have a tvdb id or not. /// Optional. If specified, results will be filtered by exxcluding item ids. This allows multiple, comma delimeted. /// Optional. The record index to start at. All items with a lower index will be dropped from the results. /// Optional. The maximum number of records to return. /// When searching within folders, this determines whether or not the search will be recursive. true/false. /// Optional. Filter based on a search term. /// Sort Order - Ascending,Descending. /// Specify this to localize the search to a specific item or folder. Omit to use the root. /// Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines. /// Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted. /// Optional. Specify additional filters to apply. This allows multiple, comma delimeted. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsResumable, Likes, Dislikes. /// Optional filter by items that are marked as favorite, or not. /// Optional filter by MediaType. Allows multiple, comma delimited. /// Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited. /// Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime. /// Optional filter by items that are played, or not. /// Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimeted. /// Optional, include user data. /// Optional, the max number of images to return, per image type. /// Optional. The image types to include in the output. /// Optional. If specified, results will be filtered to include only those containing the specified person. /// Optional. If specified, results will be filtered to include only those containing the specified person id. /// Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited. /// Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered based on artists. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered based on artist id. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered to include only those containing the specified artist id. /// Optional. If specified, results will be filtered to include only those containing the specified album artist id. /// Optional. If specified, results will be filtered to include only those containing the specified contributing artist id. /// Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered based on album id. This allows multiple, pipe delimeted. /// Optional. If specific items are needed, specify a list of item id's to retrieve. This allows multiple, comma delimited. /// Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma delimeted. /// Optional filter by minimum official rating (PG, PG-13, TV-MA, etc). /// Optional filter by items that are locked. /// Optional filter by items that are placeholders. /// Optional filter by items that have official ratings. /// Whether or not to hide items behind their boxsets. /// Optional. Filter by the minimum width of the item. /// Optional. Filter by the minimum height of the item. /// Optional. Filter by the maximum width of the item. /// Optional. Filter by the maximum height of the item. /// Optional filter by items that are 3D, or not. /// Optional filter by Series Status. Allows multiple, comma delimeted. /// Optional filter by items whose name is sorted equally or greater than a given input string. /// Optional filter by items whose name is sorted equally than a given input string. /// Optional filter by items whose name is equally or lesser than a given input string. /// Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimeted. /// Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimeted. /// Optional. Enable the total record count. /// Optional, include image information in output. /// A with the trailers. [HttpGet("/Trailers")] [ProducesResponseType(StatusCodes.Status200OK)] public ActionResult> GetTrailers( [FromQuery] Guid? userId, [FromQuery] string? maxOfficialRating, [FromQuery] bool? hasThemeSong, [FromQuery] bool? hasThemeVideo, [FromQuery] bool? hasSubtitles, [FromQuery] bool? hasSpecialFeature, [FromQuery] bool? hasTrailer, [FromQuery] string? adjacentTo, [FromQuery] int? parentIndexNumber, [FromQuery] bool? hasParentalRating, [FromQuery] bool? isHd, [FromQuery] bool? is4K, [FromQuery] string? locationTypes, [FromQuery] string? excludeLocationTypes, [FromQuery] bool? isMissing, [FromQuery] bool? isUnaired, [FromQuery] double? minCommunityRating, [FromQuery] double? minCriticRating, [FromQuery] DateTime? minPremiereDate, [FromQuery] DateTime? minDateLastSaved, [FromQuery] DateTime? minDateLastSavedForUser, [FromQuery] DateTime? maxPremiereDate, [FromQuery] bool? hasOverview, [FromQuery] bool? hasImdbId, [FromQuery] bool? hasTmdbId, [FromQuery] bool? hasTvdbId, [FromQuery] string? excludeItemIds, [FromQuery] int? startIndex, [FromQuery] int? limit, [FromQuery] bool? recursive, [FromQuery] string? searchTerm, [FromQuery] string? sortOrder, [FromQuery] string? parentId, [FromQuery] string? fields, [FromQuery] string? excludeItemTypes, [FromQuery] string? filters, [FromQuery] bool? isFavorite, [FromQuery] string? mediaTypes, [FromQuery] string? imageTypes, [FromQuery] string? sortBy, [FromQuery] bool? isPlayed, [FromQuery] string? genres, [FromQuery] string? officialRatings, [FromQuery] string? tags, [FromQuery] string? years, [FromQuery] bool? enableUserData, [FromQuery] int? imageTypeLimit, [FromQuery] string? enableImageTypes, [FromQuery] string? person, [FromQuery] string? personIds, [FromQuery] string? personTypes, [FromQuery] string? studios, [FromQuery] string? artists, [FromQuery] string? excludeArtistIds, [FromQuery] string? artistIds, [FromQuery] string? albumArtistIds, [FromQuery] string? contributingArtistIds, [FromQuery] string? albums, [FromQuery] string? albumIds, [FromQuery] string? ids, [FromQuery] string? videoTypes, [FromQuery] string? minOfficialRating, [FromQuery] bool? isLocked, [FromQuery] bool? isPlaceHolder, [FromQuery] bool? hasOfficialRating, [FromQuery] bool? collapseBoxSetItems, [FromQuery] int? minWidth, [FromQuery] int? minHeight, [FromQuery] int? maxWidth, [FromQuery] int? maxHeight, [FromQuery] bool? is3D, [FromQuery] string? seriesStatus, [FromQuery] string? nameStartsWithOrGreater, [FromQuery] string? nameStartsWith, [FromQuery] string? nameLessThan, [FromQuery] string? studioIds, [FromQuery] string? genreIds, [FromQuery] bool enableTotalRecordCount = true, [FromQuery] bool? enableImages = true) { var includeItemTypes = "Trailer"; return new ItemsController( _userManager, _libraryManager, _localizationManager, _dtoService, _logger) .GetItems( userId, userId, maxOfficialRating, hasThemeSong, hasThemeVideo, hasSubtitles, hasSpecialFeature, hasTrailer, adjacentTo, parentIndexNumber, hasParentalRating, isHd, is4K, locationTypes, excludeLocationTypes, isMissing, isUnaired, minCommunityRating, minCriticRating, minPremiereDate, minDateLastSaved, minDateLastSavedForUser, maxPremiereDate, hasOverview, hasImdbId, hasTmdbId, hasTvdbId, excludeItemIds, startIndex, limit, recursive, searchTerm, sortOrder, parentId, fields, excludeItemTypes, includeItemTypes, filters, isFavorite, mediaTypes, imageTypes, sortBy, isPlayed, genres, officialRatings, tags, years, enableUserData, imageTypeLimit, enableImageTypes, person, personIds, personTypes, studios, artists, excludeArtistIds, artistIds, albumArtistIds, contributingArtistIds, albums, albumIds, ids, videoTypes, minOfficialRating, isLocked, isPlaceHolder, hasOfficialRating, collapseBoxSetItems, minWidth, minHeight, maxWidth, maxHeight, is3D, seriesStatus, nameStartsWithOrGreater, nameStartsWith, nameLessThan, studioIds, genreIds, enableTotalRecordCount, enableImages); } } }