2020-06-21 22:12:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-09-05 23:11:44 +00:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-06-23 17:48:37 +00:00
|
|
|
|
using System.IO;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
using System.Linq;
|
2020-08-13 21:50:19 +00:00
|
|
|
|
using System.Net.Http;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
using System.Net.Mime;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-09-01 23:26:49 +00:00
|
|
|
|
using Jellyfin.Api.Attributes;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
using Jellyfin.Api.Constants;
|
|
|
|
|
using Jellyfin.Api.Extensions;
|
|
|
|
|
using Jellyfin.Api.Helpers;
|
|
|
|
|
using Jellyfin.Api.Models.LiveTvDtos;
|
|
|
|
|
using Jellyfin.Data.Enums;
|
|
|
|
|
using MediaBrowser.Common;
|
|
|
|
|
using MediaBrowser.Common.Configuration;
|
2020-08-31 17:05:21 +00:00
|
|
|
|
using MediaBrowser.Common.Net;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
using MediaBrowser.Controller.Dto;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.LiveTv;
|
|
|
|
|
using MediaBrowser.Controller.Net;
|
|
|
|
|
using MediaBrowser.Model.Dto;
|
2020-10-09 23:52:39 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
using MediaBrowser.Model.LiveTv;
|
2020-06-23 17:48:37 +00:00
|
|
|
|
using MediaBrowser.Model.Net;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace Jellyfin.Api.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Live tv controller.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LiveTvController : BaseJellyfinApiController
|
|
|
|
|
{
|
|
|
|
|
private readonly ILiveTvManager _liveTvManager;
|
|
|
|
|
private readonly IUserManager _userManager;
|
2020-08-13 21:50:19 +00:00
|
|
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
private readonly IDtoService _dtoService;
|
|
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
|
|
private readonly IMediaSourceManager _mediaSourceManager;
|
|
|
|
|
private readonly IConfigurationManager _configurationManager;
|
2020-07-27 19:42:40 +00:00
|
|
|
|
private readonly TranscodingJobHelper _transcodingJobHelper;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="LiveTvController"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="liveTvManager">Instance of the <see cref="ILiveTvManager"/> interface.</param>
|
|
|
|
|
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
|
2020-08-13 21:50:19 +00:00
|
|
|
|
/// <param name="httpClientFactory">Instance of the <see cref="IHttpClientFactory"/> interface.</param>
|
2020-06-21 22:12:21 +00:00
|
|
|
|
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
|
|
|
|
/// <param name="dtoService">Instance of the <see cref="IDtoService"/> interface.</param>
|
|
|
|
|
/// <param name="sessionContext">Instance of the <see cref="ISessionContext"/> interface.</param>
|
|
|
|
|
/// <param name="mediaSourceManager">Instance of the <see cref="IMediaSourceManager"/> interface.</param>
|
|
|
|
|
/// <param name="configurationManager">Instance of the <see cref="IConfigurationManager"/> interface.</param>
|
2020-07-27 19:42:40 +00:00
|
|
|
|
/// <param name="transcodingJobHelper">Instance of the <see cref="TranscodingJobHelper"/> class.</param>
|
2020-06-21 22:12:21 +00:00
|
|
|
|
public LiveTvController(
|
|
|
|
|
ILiveTvManager liveTvManager,
|
|
|
|
|
IUserManager userManager,
|
2020-08-13 21:50:19 +00:00
|
|
|
|
IHttpClientFactory httpClientFactory,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
ILibraryManager libraryManager,
|
|
|
|
|
IDtoService dtoService,
|
|
|
|
|
ISessionContext sessionContext,
|
|
|
|
|
IMediaSourceManager mediaSourceManager,
|
2020-07-27 19:42:40 +00:00
|
|
|
|
IConfigurationManager configurationManager,
|
|
|
|
|
TranscodingJobHelper transcodingJobHelper)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
_liveTvManager = liveTvManager;
|
|
|
|
|
_userManager = userManager;
|
2020-08-13 21:50:19 +00:00
|
|
|
|
_httpClientFactory = httpClientFactory;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
|
_dtoService = dtoService;
|
|
|
|
|
_sessionContext = sessionContext;
|
|
|
|
|
_mediaSourceManager = mediaSourceManager;
|
|
|
|
|
_configurationManager = configurationManager;
|
2020-07-27 19:42:40 +00:00
|
|
|
|
_transcodingJobHelper = transcodingJobHelper;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets available live tv services.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <response code="200">Available live tv services returned.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// An <see cref="OkResult"/> containing the available live tv services.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("Info")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
public ActionResult<LiveTvInfo> GetLiveTvInfo()
|
|
|
|
|
{
|
|
|
|
|
return _liveTvManager.GetLiveTvInfo(CancellationToken.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets available live tv channels.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type">Optional. Filter by channel type.</param>
|
|
|
|
|
/// <param name="userId">Optional. Filter by user and attach user data.</param>
|
|
|
|
|
/// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
|
|
|
|
|
/// <param name="isMovie">Optional. Filter for movies.</param>
|
|
|
|
|
/// <param name="isSeries">Optional. Filter for series.</param>
|
|
|
|
|
/// <param name="isNews">Optional. Filter for news.</param>
|
|
|
|
|
/// <param name="isKids">Optional. Filter for kids.</param>
|
|
|
|
|
/// <param name="isSports">Optional. Filter for sports.</param>
|
|
|
|
|
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
|
|
|
|
/// <param name="isFavorite">Optional. Filter by channels that are favorites, or not.</param>
|
|
|
|
|
/// <param name="isLiked">Optional. Filter by channels that are liked, or not.</param>
|
|
|
|
|
/// <param name="isDisliked">Optional. Filter by channels that are disliked, or not.</param>
|
|
|
|
|
/// <param name="enableImages">Optional. Include image information in output.</param>
|
|
|
|
|
/// <param name="imageTypeLimit">Optional. The max number of images to return, per image type.</param>
|
|
|
|
|
/// <param name="enableImageTypes">"Optional. The image types to include in the output.</param>
|
|
|
|
|
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
|
|
|
|
/// <param name="enableUserData">Optional. Include user data.</param>
|
|
|
|
|
/// <param name="sortBy">Optional. Key to sort by.</param>
|
|
|
|
|
/// <param name="sortOrder">Optional. Sort order.</param>
|
2020-07-07 15:10:51 +00:00
|
|
|
|
/// <param name="enableFavoriteSorting">Optional. Incorporate favorite and like status into channel sorting.</param>
|
2020-06-21 22:12:21 +00:00
|
|
|
|
/// <param name="addCurrentProgram">Optional. Adds current program info to each channel.</param>
|
|
|
|
|
/// <response code="200">Available live tv channels returned.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// An <see cref="OkResult"/> containing the resulting available live tv channels.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("Channels")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-08-03 20:38:51 +00:00
|
|
|
|
public ActionResult<QueryResult<BaseItemDto>> GetLiveTvChannels(
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] ChannelType? type,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] Guid? userId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] int? startIndex,
|
|
|
|
|
[FromQuery] bool? isMovie,
|
|
|
|
|
[FromQuery] bool? isSeries,
|
|
|
|
|
[FromQuery] bool? isNews,
|
|
|
|
|
[FromQuery] bool? isKids,
|
|
|
|
|
[FromQuery] bool? isSports,
|
|
|
|
|
[FromQuery] int? limit,
|
|
|
|
|
[FromQuery] bool? isFavorite,
|
|
|
|
|
[FromQuery] bool? isLiked,
|
|
|
|
|
[FromQuery] bool? isDisliked,
|
|
|
|
|
[FromQuery] bool? enableImages,
|
|
|
|
|
[FromQuery] int? imageTypeLimit,
|
2020-10-09 23:52:39 +00:00
|
|
|
|
[FromQuery] ImageType[] enableImageTypes,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? fields,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableUserData,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? sortBy,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] SortOrder? sortOrder,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] bool enableFavoriteSorting = false,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool addCurrentProgram = true)
|
|
|
|
|
{
|
|
|
|
|
var dtoOptions = new DtoOptions()
|
|
|
|
|
.AddItemFields(fields)
|
|
|
|
|
.AddClientFields(Request)
|
|
|
|
|
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
|
|
|
|
|
|
|
|
|
var channelResult = _liveTvManager.GetInternalChannels(
|
|
|
|
|
new LiveTvChannelQuery
|
|
|
|
|
{
|
|
|
|
|
ChannelType = type,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
UserId = userId ?? Guid.Empty,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
StartIndex = startIndex,
|
|
|
|
|
Limit = limit,
|
|
|
|
|
IsFavorite = isFavorite,
|
|
|
|
|
IsLiked = isLiked,
|
|
|
|
|
IsDisliked = isDisliked,
|
|
|
|
|
EnableFavoriteSorting = enableFavoriteSorting,
|
|
|
|
|
IsMovie = isMovie,
|
|
|
|
|
IsSeries = isSeries,
|
|
|
|
|
IsNews = isNews,
|
|
|
|
|
IsKids = isKids,
|
|
|
|
|
IsSports = isSports,
|
|
|
|
|
SortBy = RequestHelpers.Split(sortBy, ',', true),
|
|
|
|
|
SortOrder = sortOrder ?? SortOrder.Ascending,
|
|
|
|
|
AddCurrentProgram = addCurrentProgram
|
|
|
|
|
},
|
|
|
|
|
dtoOptions,
|
|
|
|
|
CancellationToken.None);
|
|
|
|
|
|
2020-07-07 15:10:51 +00:00
|
|
|
|
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
|
|
|
|
? _userManager.GetUserById(userId.Value)
|
|
|
|
|
: null;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
|
|
|
|
|
var fieldsList = dtoOptions.Fields.ToList();
|
|
|
|
|
fieldsList.Remove(ItemFields.CanDelete);
|
|
|
|
|
fieldsList.Remove(ItemFields.CanDownload);
|
|
|
|
|
fieldsList.Remove(ItemFields.DisplayPreferencesId);
|
|
|
|
|
fieldsList.Remove(ItemFields.Etag);
|
|
|
|
|
dtoOptions.Fields = fieldsList.ToArray();
|
|
|
|
|
dtoOptions.AddCurrentProgram = addCurrentProgram;
|
|
|
|
|
|
|
|
|
|
var returnArray = _dtoService.GetBaseItemDtos(channelResult.Items, dtoOptions, user);
|
|
|
|
|
return new QueryResult<BaseItemDto>
|
|
|
|
|
{
|
|
|
|
|
Items = returnArray,
|
|
|
|
|
TotalRecordCount = channelResult.TotalRecordCount
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a live tv channel.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="channelId">Channel id.</param>
|
|
|
|
|
/// <param name="userId">Optional. Attach user data.</param>
|
|
|
|
|
/// <response code="200">Live tv channel returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the live tv channel.</returns>
|
|
|
|
|
[HttpGet("Channels/{channelId}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public ActionResult<BaseItemDto> GetChannel([FromRoute, Required] Guid channelId, [FromQuery] Guid? userId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
2020-07-07 15:10:51 +00:00
|
|
|
|
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
|
|
|
|
? _userManager.GetUserById(userId.Value)
|
|
|
|
|
: null;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
var item = channelId.Equals(Guid.Empty)
|
|
|
|
|
? _libraryManager.GetUserRootFolder()
|
|
|
|
|
: _libraryManager.GetItemById(channelId);
|
|
|
|
|
|
|
|
|
|
var dtoOptions = new DtoOptions()
|
|
|
|
|
.AddClientFields(Request);
|
|
|
|
|
return _dtoService.GetBaseItemDto(item, dtoOptions, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets live tv recordings.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="channelId">Optional. Filter by channel id.</param>
|
|
|
|
|
/// <param name="userId">Optional. Filter by user and attach user data.</param>
|
|
|
|
|
/// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
|
|
|
|
|
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
|
|
|
|
/// <param name="status">Optional. Filter by recording status.</param>
|
|
|
|
|
/// <param name="isInProgress">Optional. Filter by recordings that are in progress, or not.</param>
|
|
|
|
|
/// <param name="seriesTimerId">Optional. Filter by recordings belonging to a series timer.</param>
|
|
|
|
|
/// <param name="enableImages">Optional. Include image information in output.</param>
|
|
|
|
|
/// <param name="imageTypeLimit">Optional. The max number of images to return, per image type.</param>
|
|
|
|
|
/// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
|
|
|
|
|
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
|
|
|
|
/// <param name="enableUserData">Optional. Include user data.</param>
|
|
|
|
|
/// <param name="isMovie">Optional. Filter for movies.</param>
|
|
|
|
|
/// <param name="isSeries">Optional. Filter for series.</param>
|
|
|
|
|
/// <param name="isKids">Optional. Filter for kids.</param>
|
|
|
|
|
/// <param name="isSports">Optional. Filter for sports.</param>
|
|
|
|
|
/// <param name="isNews">Optional. Filter for news.</param>
|
|
|
|
|
/// <param name="isLibraryItem">Optional. Filter for is library item.</param>
|
|
|
|
|
/// <param name="enableTotalRecordCount">Optional. Return total record count.</param>
|
|
|
|
|
/// <response code="200">Live tv recordings returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the live tv recordings.</returns>
|
|
|
|
|
[HttpGet("Recordings")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
public ActionResult<QueryResult<BaseItemDto>> GetRecordings(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? channelId,
|
|
|
|
|
[FromQuery] Guid? userId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] int? startIndex,
|
|
|
|
|
[FromQuery] int? limit,
|
|
|
|
|
[FromQuery] RecordingStatus? status,
|
|
|
|
|
[FromQuery] bool? isInProgress,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? seriesTimerId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableImages,
|
|
|
|
|
[FromQuery] int? imageTypeLimit,
|
2020-10-09 23:52:39 +00:00
|
|
|
|
[FromQuery] ImageType[] enableImageTypes,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? fields,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableUserData,
|
|
|
|
|
[FromQuery] bool? isMovie,
|
|
|
|
|
[FromQuery] bool? isSeries,
|
|
|
|
|
[FromQuery] bool? isKids,
|
|
|
|
|
[FromQuery] bool? isSports,
|
|
|
|
|
[FromQuery] bool? isNews,
|
|
|
|
|
[FromQuery] bool? isLibraryItem,
|
|
|
|
|
[FromQuery] bool enableTotalRecordCount = true)
|
|
|
|
|
{
|
|
|
|
|
var dtoOptions = new DtoOptions()
|
|
|
|
|
.AddItemFields(fields)
|
|
|
|
|
.AddClientFields(Request)
|
|
|
|
|
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
|
|
|
|
|
|
|
|
|
return _liveTvManager.GetRecordings(
|
|
|
|
|
new RecordingQuery
|
|
|
|
|
{
|
|
|
|
|
ChannelId = channelId,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
UserId = userId ?? Guid.Empty,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
StartIndex = startIndex,
|
|
|
|
|
Limit = limit,
|
|
|
|
|
Status = status,
|
|
|
|
|
SeriesTimerId = seriesTimerId,
|
|
|
|
|
IsInProgress = isInProgress,
|
|
|
|
|
EnableTotalRecordCount = enableTotalRecordCount,
|
|
|
|
|
IsMovie = isMovie,
|
|
|
|
|
IsNews = isNews,
|
|
|
|
|
IsSeries = isSeries,
|
|
|
|
|
IsKids = isKids,
|
|
|
|
|
IsSports = isSports,
|
|
|
|
|
IsLibraryItem = isLibraryItem,
|
|
|
|
|
Fields = RequestHelpers.GetItemFields(fields),
|
|
|
|
|
ImageTypeLimit = imageTypeLimit,
|
|
|
|
|
EnableImages = enableImages
|
|
|
|
|
}, dtoOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets live tv recording series.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="channelId">Optional. Filter by channel id.</param>
|
|
|
|
|
/// <param name="userId">Optional. Filter by user and attach user data.</param>
|
|
|
|
|
/// <param name="groupId">Optional. Filter by recording group.</param>
|
|
|
|
|
/// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
|
|
|
|
|
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
|
|
|
|
/// <param name="status">Optional. Filter by recording status.</param>
|
|
|
|
|
/// <param name="isInProgress">Optional. Filter by recordings that are in progress, or not.</param>
|
|
|
|
|
/// <param name="seriesTimerId">Optional. Filter by recordings belonging to a series timer.</param>
|
|
|
|
|
/// <param name="enableImages">Optional. Include image information in output.</param>
|
|
|
|
|
/// <param name="imageTypeLimit">Optional. The max number of images to return, per image type.</param>
|
|
|
|
|
/// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
|
|
|
|
|
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
|
|
|
|
/// <param name="enableUserData">Optional. Include user data.</param>
|
|
|
|
|
/// <param name="enableTotalRecordCount">Optional. Return total record count.</param>
|
|
|
|
|
/// <response code="200">Live tv recordings returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the live tv recordings.</returns>
|
|
|
|
|
[HttpGet("Recordings/Series")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[Obsolete("This endpoint is obsolete.")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "channelId", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "userId", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "groupId", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "startIndex", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "limit", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "status", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "isInProgress", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "seriesTimerId", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "enableImages", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "imageTypeLimit", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "enableImageTypes", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "fields", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "enableUserData", Justification = "Imported from ServiceStack")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "enableTotalRecordCount", Justification = "Imported from ServiceStack")]
|
|
|
|
|
public ActionResult<QueryResult<BaseItemDto>> GetRecordingsSeries(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? channelId,
|
|
|
|
|
[FromQuery] Guid? userId,
|
|
|
|
|
[FromQuery] string? groupId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] int? startIndex,
|
|
|
|
|
[FromQuery] int? limit,
|
|
|
|
|
[FromQuery] RecordingStatus? status,
|
|
|
|
|
[FromQuery] bool? isInProgress,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? seriesTimerId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableImages,
|
|
|
|
|
[FromQuery] int? imageTypeLimit,
|
2020-10-09 23:52:39 +00:00
|
|
|
|
[FromQuery] ImageType[] enableImageTypes,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? fields,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableUserData,
|
|
|
|
|
[FromQuery] bool enableTotalRecordCount = true)
|
|
|
|
|
{
|
|
|
|
|
return new QueryResult<BaseItemDto>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets live tv recording groups.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId">Optional. Filter by user and attach user data.</param>
|
|
|
|
|
/// <response code="200">Recording groups returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the recording groups.</returns>
|
|
|
|
|
[HttpGet("Recordings/Groups")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[Obsolete("This endpoint is obsolete.")]
|
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "userId", Justification = "Imported from ServiceStack")]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public ActionResult<QueryResult<BaseItemDto>> GetRecordingGroups([FromQuery] Guid? userId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return new QueryResult<BaseItemDto>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets recording folders.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId">Optional. Filter by user and attach user data.</param>
|
|
|
|
|
/// <response code="200">Recording folders returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the recording folders.</returns>
|
|
|
|
|
[HttpGet("Recordings/Folders")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public ActionResult<QueryResult<BaseItemDto>> GetRecordingFolders([FromQuery] Guid? userId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
2020-07-07 15:10:51 +00:00
|
|
|
|
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
|
|
|
|
? _userManager.GetUserById(userId.Value)
|
|
|
|
|
: null;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
var folders = _liveTvManager.GetRecordingFolders(user);
|
|
|
|
|
|
|
|
|
|
var returnArray = _dtoService.GetBaseItemDtos(folders, new DtoOptions(), user);
|
|
|
|
|
|
|
|
|
|
return new QueryResult<BaseItemDto>
|
|
|
|
|
{
|
|
|
|
|
Items = returnArray,
|
|
|
|
|
TotalRecordCount = returnArray.Count
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a live tv recording.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="recordingId">Recording id.</param>
|
|
|
|
|
/// <param name="userId">Optional. Attach user data.</param>
|
|
|
|
|
/// <response code="200">Recording returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the live tv recording.</returns>
|
|
|
|
|
[HttpGet("Recordings/{recordingId}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public ActionResult<BaseItemDto> GetRecording([FromRoute, Required] Guid recordingId, [FromQuery] Guid? userId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
2020-07-07 15:10:51 +00:00
|
|
|
|
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
|
|
|
|
? _userManager.GetUserById(userId.Value)
|
|
|
|
|
: null;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
var item = recordingId.Equals(Guid.Empty) ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(recordingId);
|
|
|
|
|
|
|
|
|
|
var dtoOptions = new DtoOptions()
|
|
|
|
|
.AddClientFields(Request);
|
|
|
|
|
|
|
|
|
|
return _dtoService.GetBaseItemDto(item, dtoOptions, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resets a tv tuner.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tunerId">Tuner id.</param>
|
|
|
|
|
/// <response code="204">Tuner reset.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpPost("Tuners/{tunerId}/Reset")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public ActionResult ResetTuner([FromRoute, Required] string tunerId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
_liveTvManager.ResetTuner(tunerId, CancellationToken.None);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timerId">Timer id.</param>
|
|
|
|
|
/// <response code="200">Timer returned.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// A <see cref="Task"/> containing an <see cref="OkResult"/> which contains the timer.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("Timers/{timerId}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-09-07 23:17:26 +00:00
|
|
|
|
public async Task<ActionResult<TimerInfoDto>> GetTimer([FromRoute, Required] string timerId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return await _liveTvManager.GetTimer(timerId, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the default values for a new timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="programId">Optional. To attach default values based on a program.</param>
|
|
|
|
|
/// <response code="200">Default values returned.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// A <see cref="Task"/> containing an <see cref="OkResult"/> which contains the default values for a timer.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("Timers/Defaults")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public async Task<ActionResult<SeriesTimerInfoDto>> GetDefaultTimer([FromQuery] string? programId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return string.IsNullOrEmpty(programId)
|
|
|
|
|
? await _liveTvManager.GetNewTimerDefaults(CancellationToken.None).ConfigureAwait(false)
|
|
|
|
|
: await _liveTvManager.GetNewTimerDefaults(programId, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the live tv timers.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="channelId">Optional. Filter by channel id.</param>
|
|
|
|
|
/// <param name="seriesTimerId">Optional. Filter by timers belonging to a series timer.</param>
|
|
|
|
|
/// <param name="isActive">Optional. Filter by timers that are active.</param>
|
|
|
|
|
/// <param name="isScheduled">Optional. Filter by timers that are scheduled.</param>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// A <see cref="Task"/> containing an <see cref="OkResult"/> which contains the live tv timers.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("Timers")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
public async Task<ActionResult<QueryResult<TimerInfoDto>>> GetTimers(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? channelId,
|
|
|
|
|
[FromQuery] string? seriesTimerId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? isActive,
|
|
|
|
|
[FromQuery] bool? isScheduled)
|
|
|
|
|
{
|
|
|
|
|
return await _liveTvManager.GetTimers(
|
|
|
|
|
new TimerQuery
|
|
|
|
|
{
|
|
|
|
|
ChannelId = channelId,
|
|
|
|
|
SeriesTimerId = seriesTimerId,
|
|
|
|
|
IsActive = isActive,
|
|
|
|
|
IsScheduled = isScheduled
|
|
|
|
|
}, CancellationToken.None)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets available live tv epgs.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="channelIds">The channels to return guide information for.</param>
|
|
|
|
|
/// <param name="userId">Optional. Filter by user id.</param>
|
|
|
|
|
/// <param name="minStartDate">Optional. The minimum premiere start date.</param>
|
|
|
|
|
/// <param name="hasAired">Optional. Filter by programs that have completed airing, or not.</param>
|
|
|
|
|
/// <param name="isAiring">Optional. Filter by programs that are currently airing, or not.</param>
|
|
|
|
|
/// <param name="maxStartDate">Optional. The maximum premiere start date.</param>
|
|
|
|
|
/// <param name="minEndDate">Optional. The minimum premiere end date.</param>
|
|
|
|
|
/// <param name="maxEndDate">Optional. The maximum premiere end date.</param>
|
|
|
|
|
/// <param name="isMovie">Optional. Filter for movies.</param>
|
|
|
|
|
/// <param name="isSeries">Optional. Filter for series.</param>
|
|
|
|
|
/// <param name="isNews">Optional. Filter for news.</param>
|
|
|
|
|
/// <param name="isKids">Optional. Filter for kids.</param>
|
|
|
|
|
/// <param name="isSports">Optional. Filter for sports.</param>
|
|
|
|
|
/// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
|
|
|
|
|
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
|
|
|
|
/// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited. Options: Name, StartDate.</param>
|
|
|
|
|
/// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
|
|
|
|
|
/// <param name="genres">The genres to return guide information for.</param>
|
|
|
|
|
/// <param name="genreIds">The genre ids to return guide information for.</param>
|
|
|
|
|
/// <param name="enableImages">Optional. Include image information in output.</param>
|
|
|
|
|
/// <param name="imageTypeLimit">Optional. The max number of images to return, per image type.</param>
|
|
|
|
|
/// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
|
|
|
|
|
/// <param name="enableUserData">Optional. Include user data.</param>
|
|
|
|
|
/// <param name="seriesTimerId">Optional. Filter by series timer id.</param>
|
|
|
|
|
/// <param name="librarySeriesId">Optional. Filter by library series id.</param>
|
|
|
|
|
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
|
|
|
|
/// <param name="enableTotalRecordCount">Retrieve total record count.</param>
|
|
|
|
|
/// <response code="200">Live tv epgs returned.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// A <see cref="Task"/> containing a <see cref="OkResult"/> which contains the live tv epgs.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("Programs")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-08-03 20:38:51 +00:00
|
|
|
|
public async Task<ActionResult<QueryResult<BaseItemDto>>> GetLiveTvPrograms(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? channelIds,
|
|
|
|
|
[FromQuery] Guid? userId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] DateTime? minStartDate,
|
|
|
|
|
[FromQuery] bool? hasAired,
|
|
|
|
|
[FromQuery] bool? isAiring,
|
|
|
|
|
[FromQuery] DateTime? maxStartDate,
|
|
|
|
|
[FromQuery] DateTime? minEndDate,
|
|
|
|
|
[FromQuery] DateTime? maxEndDate,
|
|
|
|
|
[FromQuery] bool? isMovie,
|
|
|
|
|
[FromQuery] bool? isSeries,
|
|
|
|
|
[FromQuery] bool? isNews,
|
|
|
|
|
[FromQuery] bool? isKids,
|
|
|
|
|
[FromQuery] bool? isSports,
|
|
|
|
|
[FromQuery] int? startIndex,
|
|
|
|
|
[FromQuery] int? limit,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? sortBy,
|
|
|
|
|
[FromQuery] string? sortOrder,
|
|
|
|
|
[FromQuery] string? genres,
|
|
|
|
|
[FromQuery] string? genreIds,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableImages,
|
|
|
|
|
[FromQuery] int? imageTypeLimit,
|
2020-10-09 23:52:39 +00:00
|
|
|
|
[FromQuery] ImageType[] enableImageTypes,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableUserData,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? seriesTimerId,
|
|
|
|
|
[FromQuery] Guid? librarySeriesId,
|
|
|
|
|
[FromQuery] string? fields,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool enableTotalRecordCount = true)
|
|
|
|
|
{
|
2020-07-07 15:10:51 +00:00
|
|
|
|
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
|
|
|
|
? _userManager.GetUserById(userId.Value)
|
|
|
|
|
: null;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
|
|
|
|
|
var query = new InternalItemsQuery(user)
|
|
|
|
|
{
|
|
|
|
|
ChannelIds = RequestHelpers.Split(channelIds, ',', true)
|
|
|
|
|
.Select(i => new Guid(i)).ToArray(),
|
|
|
|
|
HasAired = hasAired,
|
|
|
|
|
IsAiring = isAiring,
|
|
|
|
|
EnableTotalRecordCount = enableTotalRecordCount,
|
|
|
|
|
MinStartDate = minStartDate,
|
|
|
|
|
MinEndDate = minEndDate,
|
|
|
|
|
MaxStartDate = maxStartDate,
|
|
|
|
|
MaxEndDate = maxEndDate,
|
|
|
|
|
StartIndex = startIndex,
|
|
|
|
|
Limit = limit,
|
|
|
|
|
OrderBy = RequestHelpers.GetOrderBy(sortBy, sortOrder),
|
|
|
|
|
IsNews = isNews,
|
|
|
|
|
IsMovie = isMovie,
|
|
|
|
|
IsSeries = isSeries,
|
|
|
|
|
IsKids = isKids,
|
|
|
|
|
IsSports = isSports,
|
|
|
|
|
SeriesTimerId = seriesTimerId,
|
2020-11-02 01:53:02 +00:00
|
|
|
|
Genres = RequestHelpers.Split(genres, '|', true),
|
2020-06-21 22:12:21 +00:00
|
|
|
|
GenreIds = RequestHelpers.GetGuids(genreIds)
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-12 20:41:10 +00:00
|
|
|
|
if (librarySeriesId != null && !librarySeriesId.Equals(Guid.Empty))
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
query.IsSeries = true;
|
|
|
|
|
|
2020-08-12 20:41:10 +00:00
|
|
|
|
if (_libraryManager.GetItemById(librarySeriesId.Value) is Series series)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
query.Name = series.Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dtoOptions = new DtoOptions()
|
|
|
|
|
.AddItemFields(fields)
|
|
|
|
|
.AddClientFields(Request)
|
|
|
|
|
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
|
|
|
|
return await _liveTvManager.GetPrograms(query, dtoOptions, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets available live tv epgs.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="body">Request body.</param>
|
|
|
|
|
/// <response code="200">Live tv epgs returned.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// A <see cref="Task"/> containing a <see cref="OkResult"/> which contains the live tv epgs.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpPost("Programs")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
public async Task<ActionResult<QueryResult<BaseItemDto>>> GetPrograms([FromBody] GetProgramsDto body)
|
|
|
|
|
{
|
|
|
|
|
var user = body.UserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(body.UserId);
|
|
|
|
|
|
|
|
|
|
var query = new InternalItemsQuery(user)
|
|
|
|
|
{
|
|
|
|
|
ChannelIds = RequestHelpers.Split(body.ChannelIds, ',', true)
|
|
|
|
|
.Select(i => new Guid(i)).ToArray(),
|
|
|
|
|
HasAired = body.HasAired,
|
|
|
|
|
IsAiring = body.IsAiring,
|
|
|
|
|
EnableTotalRecordCount = body.EnableTotalRecordCount,
|
|
|
|
|
MinStartDate = body.MinStartDate,
|
|
|
|
|
MinEndDate = body.MinEndDate,
|
|
|
|
|
MaxStartDate = body.MaxStartDate,
|
|
|
|
|
MaxEndDate = body.MaxEndDate,
|
|
|
|
|
StartIndex = body.StartIndex,
|
|
|
|
|
Limit = body.Limit,
|
|
|
|
|
OrderBy = RequestHelpers.GetOrderBy(body.SortBy, body.SortOrder),
|
|
|
|
|
IsNews = body.IsNews,
|
|
|
|
|
IsMovie = body.IsMovie,
|
|
|
|
|
IsSeries = body.IsSeries,
|
|
|
|
|
IsKids = body.IsKids,
|
|
|
|
|
IsSports = body.IsSports,
|
|
|
|
|
SeriesTimerId = body.SeriesTimerId,
|
2020-11-02 01:53:02 +00:00
|
|
|
|
Genres = RequestHelpers.Split(body.Genres, '|', true),
|
2020-06-21 22:12:21 +00:00
|
|
|
|
GenreIds = RequestHelpers.GetGuids(body.GenreIds)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!body.LibrarySeriesId.Equals(Guid.Empty))
|
|
|
|
|
{
|
|
|
|
|
query.IsSeries = true;
|
|
|
|
|
|
|
|
|
|
if (_libraryManager.GetItemById(body.LibrarySeriesId) is Series series)
|
|
|
|
|
{
|
|
|
|
|
query.Name = series.Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dtoOptions = new DtoOptions()
|
|
|
|
|
.AddItemFields(body.Fields)
|
|
|
|
|
.AddClientFields(Request)
|
2020-10-27 19:32:59 +00:00
|
|
|
|
.AddAdditionalDtoOptions(body.EnableImages, body.EnableUserData, body.ImageTypeLimit, body.EnableImageTypes);
|
2020-06-21 22:12:21 +00:00
|
|
|
|
return await _liveTvManager.GetPrograms(query, dtoOptions, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets recommended live tv epgs.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId">Optional. filter by user id.</param>
|
|
|
|
|
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
|
|
|
|
/// <param name="isAiring">Optional. Filter by programs that are currently airing, or not.</param>
|
|
|
|
|
/// <param name="hasAired">Optional. Filter by programs that have completed airing, or not.</param>
|
|
|
|
|
/// <param name="isSeries">Optional. Filter for series.</param>
|
|
|
|
|
/// <param name="isMovie">Optional. Filter for movies.</param>
|
|
|
|
|
/// <param name="isNews">Optional. Filter for news.</param>
|
|
|
|
|
/// <param name="isKids">Optional. Filter for kids.</param>
|
|
|
|
|
/// <param name="isSports">Optional. Filter for sports.</param>
|
|
|
|
|
/// <param name="enableImages">Optional. Include image information in output.</param>
|
|
|
|
|
/// <param name="imageTypeLimit">Optional. The max number of images to return, per image type.</param>
|
|
|
|
|
/// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
|
|
|
|
|
/// <param name="genreIds">The genres to return guide information for.</param>
|
|
|
|
|
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
|
|
|
|
/// <param name="enableUserData">Optional. include user data.</param>
|
|
|
|
|
/// <param name="enableTotalRecordCount">Retrieve total record count.</param>
|
|
|
|
|
/// <response code="200">Recommended epgs returned.</response>
|
|
|
|
|
/// <returns>A <see cref="OkResult"/> containing the queryresult of recommended epgs.</returns>
|
|
|
|
|
[HttpGet("Programs/Recommended")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public ActionResult<QueryResult<BaseItemDto>> GetRecommendedPrograms(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] Guid? userId,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] int? limit,
|
|
|
|
|
[FromQuery] bool? isAiring,
|
|
|
|
|
[FromQuery] bool? hasAired,
|
|
|
|
|
[FromQuery] bool? isSeries,
|
|
|
|
|
[FromQuery] bool? isMovie,
|
|
|
|
|
[FromQuery] bool? isNews,
|
|
|
|
|
[FromQuery] bool? isKids,
|
|
|
|
|
[FromQuery] bool? isSports,
|
|
|
|
|
[FromQuery] bool? enableImages,
|
|
|
|
|
[FromQuery] int? imageTypeLimit,
|
2020-10-09 23:52:39 +00:00
|
|
|
|
[FromQuery] ImageType[] enableImageTypes,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? genreIds,
|
|
|
|
|
[FromQuery] string? fields,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[FromQuery] bool? enableUserData,
|
|
|
|
|
[FromQuery] bool enableTotalRecordCount = true)
|
|
|
|
|
{
|
2020-07-07 15:10:51 +00:00
|
|
|
|
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
|
|
|
|
? _userManager.GetUserById(userId.Value)
|
|
|
|
|
: null;
|
2020-06-21 22:12:21 +00:00
|
|
|
|
|
|
|
|
|
var query = new InternalItemsQuery(user)
|
|
|
|
|
{
|
|
|
|
|
IsAiring = isAiring,
|
|
|
|
|
Limit = limit,
|
|
|
|
|
HasAired = hasAired,
|
|
|
|
|
IsSeries = isSeries,
|
|
|
|
|
IsMovie = isMovie,
|
|
|
|
|
IsKids = isKids,
|
|
|
|
|
IsNews = isNews,
|
|
|
|
|
IsSports = isSports,
|
|
|
|
|
EnableTotalRecordCount = enableTotalRecordCount,
|
|
|
|
|
GenreIds = RequestHelpers.GetGuids(genreIds)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var dtoOptions = new DtoOptions()
|
|
|
|
|
.AddItemFields(fields)
|
|
|
|
|
.AddClientFields(Request)
|
|
|
|
|
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
|
|
|
|
return _liveTvManager.GetRecommendedPrograms(query, dtoOptions, CancellationToken.None);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-03 16:25:26 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a live tv program.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="programId">Program id.</param>
|
|
|
|
|
/// <param name="userId">Optional. Attach user data.</param>
|
|
|
|
|
/// <response code="200">Program returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the livetv program.</returns>
|
2020-07-03 17:04:45 +00:00
|
|
|
|
[HttpGet("Programs/{programId}")]
|
2020-07-03 16:25:26 +00:00
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult<BaseItemDto>> GetProgram(
|
2020-09-06 15:07:27 +00:00
|
|
|
|
[FromRoute, Required] string programId,
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] Guid? userId)
|
2020-07-03 16:25:26 +00:00
|
|
|
|
{
|
2020-07-07 15:10:51 +00:00
|
|
|
|
var user = userId.HasValue && !userId.Equals(Guid.Empty)
|
|
|
|
|
? _userManager.GetUserById(userId.Value)
|
|
|
|
|
: null;
|
2020-07-03 16:25:26 +00:00
|
|
|
|
|
|
|
|
|
return await _liveTvManager.GetProgram(programId, CancellationToken.None, user).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 22:12:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes a live tv recording.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="recordingId">Recording id.</param>
|
|
|
|
|
/// <response code="204">Recording deleted.</response>
|
|
|
|
|
/// <response code="404">Item not found.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/> on success, or a <see cref="NotFoundResult"/> if item not found.</returns>
|
|
|
|
|
[HttpDelete("Recordings/{recordingId}")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public ActionResult DeleteRecording([FromRoute, Required] Guid recordingId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
|
|
|
|
|
var item = _libraryManager.GetItemById(recordingId);
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_libraryManager.DeleteItem(item, new DeleteOptions
|
|
|
|
|
{
|
|
|
|
|
DeleteFileLocation = false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cancels a live tv timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timerId">Timer id.</param>
|
|
|
|
|
/// <response code="204">Timer deleted.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpDelete("Timers/{timerId}")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public async Task<ActionResult> CancelTimer([FromRoute, Required] string timerId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
await _liveTvManager.CancelTimer(timerId).ConfigureAwait(false);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates a live tv timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timerId">Timer id.</param>
|
|
|
|
|
/// <param name="timerInfo">New timer info.</param>
|
|
|
|
|
/// <response code="204">Timer updated.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpPost("Timers/{timerId}")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-07-03 16:25:26 +00:00
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "timerId", Justification = "Imported from ServiceStack")]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public async Task<ActionResult> UpdateTimer([FromRoute, Required] string timerId, [FromBody] TimerInfoDto timerInfo)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
await _liveTvManager.UpdateTimer(timerInfo, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a live tv timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timerInfo">New timer info.</param>
|
|
|
|
|
/// <response code="204">Timer created.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpPost("Timers")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
public async Task<ActionResult> CreateTimer([FromBody] TimerInfoDto timerInfo)
|
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
await _liveTvManager.CreateTimer(timerInfo, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a live tv series timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timerId">Timer id.</param>
|
|
|
|
|
/// <response code="200">Series timer returned.</response>
|
|
|
|
|
/// <response code="404">Series timer not found.</response>
|
|
|
|
|
/// <returns>A <see cref="OkResult"/> on success, or a <see cref="NotFoundResult"/> if timer not found.</returns>
|
|
|
|
|
[HttpGet("SeriesTimers/{timerId}")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public async Task<ActionResult<SeriesTimerInfoDto>> GetSeriesTimer([FromRoute, Required] string timerId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
var timer = await _liveTvManager.GetSeriesTimer(timerId, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
if (timer == null)
|
|
|
|
|
{
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return timer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets live tv series timers.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sortBy">Optional. Sort by SortName or Priority.</param>
|
|
|
|
|
/// <param name="sortOrder">Optional. Sort in Ascending or Descending order.</param>
|
|
|
|
|
/// <response code="200">Timers returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> of live tv series timers.</returns>
|
|
|
|
|
[HttpGet("SeriesTimers")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public async Task<ActionResult<QueryResult<SeriesTimerInfoDto>>> GetSeriesTimers([FromQuery] string? sortBy, [FromQuery] SortOrder? sortOrder)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return await _liveTvManager.GetSeriesTimers(
|
|
|
|
|
new SeriesTimerQuery
|
|
|
|
|
{
|
2020-07-07 15:10:51 +00:00
|
|
|
|
SortOrder = sortOrder ?? SortOrder.Ascending,
|
2020-06-21 22:12:21 +00:00
|
|
|
|
SortBy = sortBy
|
|
|
|
|
}, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cancels a live tv series timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timerId">Timer id.</param>
|
|
|
|
|
/// <response code="204">Timer cancelled.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpDelete("SeriesTimers/{timerId}")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public async Task<ActionResult> CancelSeriesTimer([FromRoute, Required] string timerId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
await _liveTvManager.CancelSeriesTimer(timerId).ConfigureAwait(false);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates a live tv series timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timerId">Timer id.</param>
|
|
|
|
|
/// <param name="seriesTimerInfo">New series timer info.</param>
|
|
|
|
|
/// <response code="204">Series timer updated.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpPost("SeriesTimers/{timerId}")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-06-23 17:48:37 +00:00
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "timerId", Justification = "Imported from ServiceStack")]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public async Task<ActionResult> UpdateSeriesTimer([FromRoute, Required] string timerId, [FromBody] SeriesTimerInfoDto seriesTimerInfo)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
await _liveTvManager.UpdateSeriesTimer(seriesTimerInfo, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a live tv series timer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="seriesTimerInfo">New series timer info.</param>
|
|
|
|
|
/// <response code="204">Series timer info created.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpPost("SeriesTimers")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
|
|
|
public async Task<ActionResult> CreateSeriesTimer([FromBody] SeriesTimerInfoDto seriesTimerInfo)
|
|
|
|
|
{
|
|
|
|
|
AssertUserCanManageLiveTv();
|
|
|
|
|
await _liveTvManager.CreateSeriesTimer(seriesTimerInfo, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get recording group.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="groupId">Group id.</param>
|
|
|
|
|
/// <returns>A <see cref="NotFoundResult"/>.</returns>
|
|
|
|
|
[HttpGet("Recordings/Groups/{groupId}")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
|
|
|
[Obsolete("This endpoint is obsolete.")]
|
2020-09-08 00:45:06 +00:00
|
|
|
|
public ActionResult<BaseItemDto> GetRecordingGroup([FromRoute, Required] Guid groupId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get guid info.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <response code="200">Guid info returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the guide info.</returns>
|
|
|
|
|
[HttpGet("GuideInfo")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public ActionResult<GuideInfo> GetGuideInfo()
|
|
|
|
|
{
|
|
|
|
|
return _liveTvManager.GetGuideInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds a tuner host.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tunerHostInfo">New tuner host.</param>
|
|
|
|
|
/// <response code="200">Created tuner host returned.</response>
|
|
|
|
|
/// <returns>A <see cref="OkResult"/> containing the created tuner host.</returns>
|
|
|
|
|
[HttpPost("TunerHosts")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult<TunerHostInfo>> AddTunerHost([FromBody] TunerHostInfo tunerHostInfo)
|
|
|
|
|
{
|
|
|
|
|
return await _liveTvManager.SaveTunerHost(tunerHostInfo).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes a tuner host.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Tuner host id.</param>
|
|
|
|
|
/// <response code="204">Tuner host deleted.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
|
|
|
|
[HttpDelete("TunerHosts")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public ActionResult DeleteTunerHost([FromQuery] string? id)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
var config = _configurationManager.GetConfiguration<LiveTvOptions>("livetv");
|
|
|
|
|
config.TunerHosts = config.TunerHosts.Where(i => !string.Equals(id, i.Id, StringComparison.OrdinalIgnoreCase)).ToArray();
|
|
|
|
|
_configurationManager.SaveConfiguration("livetv", config);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets default listings provider info.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <response code="200">Default listings provider info returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the default listings provider info.</returns>
|
|
|
|
|
[HttpGet("ListingProviders/Default")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public ActionResult<ListingsProviderInfo> GetDefaultListingProvider()
|
|
|
|
|
{
|
|
|
|
|
return new ListingsProviderInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds a listings provider.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pw">Password.</param>
|
|
|
|
|
/// <param name="listingsProviderInfo">New listings info.</param>
|
2020-07-07 15:10:51 +00:00
|
|
|
|
/// <param name="validateListings">Validate listings.</param>
|
|
|
|
|
/// <param name="validateLogin">Validate login.</param>
|
2020-06-21 22:12:21 +00:00
|
|
|
|
/// <response code="200">Created listings provider returned.</response>
|
|
|
|
|
/// <returns>A <see cref="OkResult"/> containing the created listings provider.</returns>
|
2020-08-12 19:14:42 +00:00
|
|
|
|
[HttpPost("ListingProviders")]
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-06-23 17:48:37 +00:00
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA5350:RemoveSha1", MessageId = "AddListingProvider", Justification = "Imported from ServiceStack")]
|
2020-06-21 22:12:21 +00:00
|
|
|
|
public async Task<ActionResult<ListingsProviderInfo>> AddListingProvider(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? pw,
|
|
|
|
|
[FromBody] ListingsProviderInfo listingsProviderInfo,
|
|
|
|
|
[FromQuery] bool validateListings = false,
|
|
|
|
|
[FromQuery] bool validateLogin = false)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(pw))
|
|
|
|
|
{
|
2020-09-16 12:16:44 +00:00
|
|
|
|
using var sha = SHA1.Create();
|
2020-06-21 22:12:21 +00:00
|
|
|
|
listingsProviderInfo.Password = Hex.Encode(sha.ComputeHash(Encoding.UTF8.GetBytes(pw)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await _liveTvManager.SaveListingProvider(listingsProviderInfo, validateLogin, validateListings).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Delete listing provider.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Listing provider id.</param>
|
|
|
|
|
/// <response code="204">Listing provider deleted.</response>
|
|
|
|
|
/// <returns>A <see cref="NoContentResult"/>.</returns>
|
2020-06-23 17:53:08 +00:00
|
|
|
|
[HttpDelete("ListingProviders")]
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public ActionResult DeleteListingProvider([FromQuery] string? id)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
_liveTvManager.DeleteListingsProvider(id);
|
|
|
|
|
return NoContent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets available lineups.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Provider id.</param>
|
|
|
|
|
/// <param name="type">Provider type.</param>
|
|
|
|
|
/// <param name="location">Location.</param>
|
|
|
|
|
/// <param name="country">Country.</param>
|
|
|
|
|
/// <response code="200">Available lineups returned.</response>
|
|
|
|
|
/// <returns>A <see cref="OkResult"/> containing the available lineups.</returns>
|
|
|
|
|
[HttpGet("ListingProviders/Lineups")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult<IEnumerable<NameIdPair>>> GetLineups(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? id,
|
|
|
|
|
[FromQuery] string? type,
|
|
|
|
|
[FromQuery] string? location,
|
|
|
|
|
[FromQuery] string? country)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return await _liveTvManager.GetLineups(type, id, country, location).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets available countries.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <response code="200">Available countries returned.</response>
|
|
|
|
|
/// <returns>A <see cref="FileResult"/> containing the available countries.</returns>
|
|
|
|
|
[HttpGet("ListingProviders/SchedulesDirect/Countries")]
|
2020-08-17 19:41:16 +00:00
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
2020-06-21 22:12:21 +00:00
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-09-01 23:26:49 +00:00
|
|
|
|
[ProducesFile(MediaTypeNames.Application.Json)]
|
2020-06-21 22:12:21 +00:00
|
|
|
|
public async Task<ActionResult> GetSchedulesDirectCountries()
|
|
|
|
|
{
|
2020-08-31 17:05:21 +00:00
|
|
|
|
var client = _httpClientFactory.CreateClient(NamedClient.Default);
|
2020-06-21 22:12:21 +00:00
|
|
|
|
// https://json.schedulesdirect.org/20141201/available/countries
|
2020-08-17 21:03:45 +00:00
|
|
|
|
// Can't dispose the response as it's required up the call chain.
|
2020-08-17 19:22:42 +00:00
|
|
|
|
var response = await client.GetAsync("https://json.schedulesdirect.org/20141201/available/countries")
|
2020-08-13 21:50:19 +00:00
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
return File(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), MediaTypeNames.Application.Json);
|
2020-06-21 22:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get channel mapping options.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="providerId">Provider id.</param>
|
|
|
|
|
/// <response code="200">Channel mapping options returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the channel mapping options.</returns>
|
|
|
|
|
[HttpGet("ChannelMappingOptions")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public async Task<ActionResult<ChannelMappingOptionsDto>> GetChannelMappingOptions([FromQuery] string? providerId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
var config = _configurationManager.GetConfiguration<LiveTvOptions>("livetv");
|
|
|
|
|
|
|
|
|
|
var listingsProviderInfo = config.ListingProviders.First(i => string.Equals(providerId, i.Id, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
var listingsProviderName = _liveTvManager.ListingProviders.First(i => string.Equals(i.Type, listingsProviderInfo.Type, StringComparison.OrdinalIgnoreCase)).Name;
|
|
|
|
|
|
|
|
|
|
var tunerChannels = await _liveTvManager.GetChannelsForListingsProvider(providerId, CancellationToken.None)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
var providerChannels = await _liveTvManager.GetChannelsFromListingsProviderData(providerId, CancellationToken.None)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
var mappings = listingsProviderInfo.ChannelMappings;
|
|
|
|
|
|
|
|
|
|
return new ChannelMappingOptionsDto
|
|
|
|
|
{
|
|
|
|
|
TunerChannels = tunerChannels.Select(i => _liveTvManager.GetTunerChannelMapping(i, mappings, providerChannels)).ToList(),
|
|
|
|
|
ProviderChannels = providerChannels.Select(i => new NameIdPair
|
|
|
|
|
{
|
|
|
|
|
Name = i.Name,
|
|
|
|
|
Id = i.Id
|
|
|
|
|
}).ToList(),
|
|
|
|
|
Mappings = mappings,
|
|
|
|
|
ProviderName = listingsProviderName
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set channel mappings.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="providerId">Provider id.</param>
|
|
|
|
|
/// <param name="tunerChannelId">Tuner channel id.</param>
|
|
|
|
|
/// <param name="providerChannelId">Provider channel id.</param>
|
|
|
|
|
/// <response code="200">Created channel mapping returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the created channel mapping.</returns>
|
|
|
|
|
[HttpPost("ChannelMappings")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public async Task<ActionResult<TunerChannelMapping>> SetChannelMapping(
|
2020-07-07 15:10:51 +00:00
|
|
|
|
[FromQuery] string? providerId,
|
|
|
|
|
[FromQuery] string? tunerChannelId,
|
|
|
|
|
[FromQuery] string? providerChannelId)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return await _liveTvManager.SetChannelMapping(providerId, tunerChannelId, providerChannelId).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get tuner host types.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <response code="200">Tuner host types returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the tuner host types.</returns>
|
|
|
|
|
[HttpGet("TunerHosts/Types")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
public ActionResult<IEnumerable<NameIdPair>> GetTunerHostTypes()
|
|
|
|
|
{
|
|
|
|
|
return _liveTvManager.GetTunerHostTypes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Discover tuners.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="newDevicesOnly">Only discover new tuners.</param>
|
|
|
|
|
/// <response code="200">Tuners returned.</response>
|
|
|
|
|
/// <returns>An <see cref="OkResult"/> containing the tuners.</returns>
|
|
|
|
|
[HttpGet("Tuners/Discvover")]
|
|
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-07-07 15:10:51 +00:00
|
|
|
|
public async Task<ActionResult<IEnumerable<TunerHostInfo>>> DiscoverTuners([FromQuery] bool newDevicesOnly = false)
|
2020-06-21 22:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
return await _liveTvManager.DiscoverTuners(newDevicesOnly, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-23 17:48:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a live tv recording stream.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="recordingId">Recording id.</param>
|
|
|
|
|
/// <response code="200">Recording stream returned.</response>
|
|
|
|
|
/// <response code="404">Recording not found.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// An <see cref="OkResult"/> containing the recording stream on success,
|
|
|
|
|
/// or a <see cref="NotFoundResult"/> if recording not found.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("LiveRecordings/{recordingId}/stream")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2020-09-01 23:26:49 +00:00
|
|
|
|
[ProducesVideoFile]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public async Task<ActionResult> GetLiveRecordingFile([FromRoute, Required] string recordingId)
|
2020-06-23 17:48:37 +00:00
|
|
|
|
{
|
|
|
|
|
var path = _liveTvManager.GetEmbyTvActiveRecordingPath(recordingId);
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
|
|
|
{
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await using var memoryStream = new MemoryStream();
|
2020-07-27 19:42:40 +00:00
|
|
|
|
await new ProgressiveFileCopier(path, null, _transcodingJobHelper, CancellationToken.None)
|
|
|
|
|
.WriteToAsync(memoryStream, CancellationToken.None)
|
|
|
|
|
.ConfigureAwait(false);
|
2020-06-23 17:48:37 +00:00
|
|
|
|
return File(memoryStream, MimeTypes.GetMimeType(path));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a live tv channel stream.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="streamId">Stream id.</param>
|
|
|
|
|
/// <param name="container">Container type.</param>
|
|
|
|
|
/// <response code="200">Stream returned.</response>
|
|
|
|
|
/// <response code="404">Stream not found.</response>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// An <see cref="OkResult"/> containing the channel stream on success,
|
|
|
|
|
/// or a <see cref="NotFoundResult"/> if stream not found.
|
|
|
|
|
/// </returns>
|
|
|
|
|
[HttpGet("LiveStreamFiles/{streamId}/stream.{container}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2020-09-01 23:26:49 +00:00
|
|
|
|
[ProducesVideoFile]
|
2020-09-06 15:07:27 +00:00
|
|
|
|
public async Task<ActionResult> GetLiveStreamFile([FromRoute, Required] string streamId, [FromRoute, Required] string container)
|
2020-06-23 17:48:37 +00:00
|
|
|
|
{
|
|
|
|
|
var liveStreamInfo = await _mediaSourceManager.GetDirectStreamProviderByUniqueId(streamId, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
if (liveStreamInfo == null)
|
|
|
|
|
{
|
|
|
|
|
return NotFound();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-27 19:42:40 +00:00
|
|
|
|
await new ProgressiveFileCopier(liveStreamInfo, null, _transcodingJobHelper, CancellationToken.None)
|
2020-10-29 19:56:29 +00:00
|
|
|
|
.WriteToAsync(Response.Body, CancellationToken.None)
|
2020-07-27 19:42:40 +00:00
|
|
|
|
.ConfigureAwait(false);
|
2020-10-29 19:56:29 +00:00
|
|
|
|
Response.ContentType = MimeTypes.GetMimeType("file." + container);
|
|
|
|
|
return Ok();
|
2020-06-23 17:48:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 22:12:21 +00:00
|
|
|
|
private void AssertUserCanManageLiveTv()
|
|
|
|
|
{
|
|
|
|
|
var user = _sessionContext.GetUser(Request);
|
|
|
|
|
|
|
|
|
|
if (user == null)
|
|
|
|
|
{
|
|
|
|
|
throw new SecurityException("Anonymous live tv management is not allowed.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!user.HasPermission(PermissionKind.EnableLiveTvManagement))
|
|
|
|
|
{
|
|
|
|
|
throw new SecurityException("The current user does not have permission to manage live tv.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|