get channel media info at runtime
This commit is contained in:
parent
124754a04f
commit
dc8c24ed29
|
@ -5,8 +5,10 @@ using MediaBrowser.Controller.Entities.Audio;
|
|||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
@ -146,7 +148,7 @@ namespace MediaBrowser.Api.Library
|
|||
}
|
||||
|
||||
[Route("/Items/{Id}", "DELETE", Summary = "Deletes an item from the library and file system")]
|
||||
[Authenticated(Roles = "Delete")]
|
||||
[Authenticated]
|
||||
public class DeleteItem : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
||||
|
@ -241,12 +243,13 @@ namespace MediaBrowser.Api.Library
|
|||
private readonly IDtoService _dtoService;
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IAuthorizationContext _authContext;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryService" /> class.
|
||||
/// </summary>
|
||||
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager,
|
||||
IDtoService dtoService, IUserDataManager userDataManager, IChannelManager channelManager, ISessionManager sessionManager)
|
||||
IDtoService dtoService, IUserDataManager userDataManager, IChannelManager channelManager, ISessionManager sessionManager, IAuthorizationContext authContext)
|
||||
{
|
||||
_itemRepo = itemRepo;
|
||||
_libraryManager = libraryManager;
|
||||
|
@ -255,6 +258,7 @@ namespace MediaBrowser.Api.Library
|
|||
_userDataManager = userDataManager;
|
||||
_channelManager = channelManager;
|
||||
_sessionManager = sessionManager;
|
||||
_authContext = authContext;
|
||||
}
|
||||
|
||||
public object Get(GetMediaFolders request)
|
||||
|
@ -466,6 +470,28 @@ namespace MediaBrowser.Api.Library
|
|||
{
|
||||
var item = _libraryManager.GetItemById(request.Id);
|
||||
|
||||
var auth = _authContext.GetAuthorizationInfo(Request);
|
||||
var user = _userManager.GetUserById(auth.UserId);
|
||||
|
||||
if (item is Playlist)
|
||||
{
|
||||
// For now this is allowed if user can see the playlist
|
||||
}
|
||||
else if (item is ILiveTvRecording)
|
||||
{
|
||||
if (!user.Configuration.EnableLiveTvManagement)
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!user.Configuration.EnableContentDeletion)
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
}
|
||||
|
||||
var task = _libraryManager.DeleteItem(item);
|
||||
|
||||
Task.WaitAll(task);
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
<Compile Include="FilterService.cs" />
|
||||
<Compile Include="Library\ChapterService.cs" />
|
||||
<Compile Include="Playback\Hls\MpegDashService.cs" />
|
||||
<Compile Include="Playback\MediaInfoService.cs" />
|
||||
<Compile Include="PlaylistService.cs" />
|
||||
<Compile Include="StartupWizardService.cs" />
|
||||
<Compile Include="Subtitles\SubtitleService.cs" />
|
||||
|
|
64
MediaBrowser.Api/Playback/MediaInfoService.cs
Normal file
64
MediaBrowser.Api/Playback/MediaInfoService.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using ServiceStack;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
[Route("/Items/{Id}/MediaInfo", "GET", Summary = "Gets live playback media info for an item")]
|
||||
public class GetLiveMediaInfo : IReturn<LiveMediaInfoResult>
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string UserId { get; set; }
|
||||
}
|
||||
|
||||
[Authenticated]
|
||||
public class MediaInfoService : BaseApiService
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public MediaInfoService(ILibraryManager libraryManager, IChannelManager channelManager, IUserManager userManager)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_channelManager = channelManager;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public async Task<object> Get(GetLiveMediaInfo request)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(request.Id);
|
||||
IEnumerable<MediaSourceInfo> mediaSources;
|
||||
|
||||
var channelItem = item as IChannelMediaItem;
|
||||
var user = _userManager.GetUserById(request.UserId);
|
||||
|
||||
if (channelItem != null)
|
||||
{
|
||||
mediaSources = await _channelManager.GetChannelItemMediaSources(request.Id, true, CancellationToken.None)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var hasMediaSources = (IHasMediaSources)item;
|
||||
mediaSources = hasMediaSources.GetMediaSources(true, user);
|
||||
}
|
||||
|
||||
return ToOptimizedResult(new LiveMediaInfoResult
|
||||
{
|
||||
MediaSources = mediaSources.ToList()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -357,7 +357,12 @@ namespace MediaBrowser.Api.Session
|
|||
|
||||
if (!user.Configuration.EnableRemoteControlOfOtherUsers)
|
||||
{
|
||||
result = result.Where(i => !i.UserId.HasValue || i.ContainsUser(request.ControllableByUserId.Value));
|
||||
result = result.Where(i => i.ContainsUser(request.ControllableByUserId.Value));
|
||||
}
|
||||
|
||||
if (!user.Configuration.EnableSharedDeviceControl)
|
||||
{
|
||||
result = result.Where(i => !i.UserId.HasValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -764,6 +764,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\MediaInfo\IBlurayExaminer.cs">
|
||||
<Link>MediaInfo\IBlurayExaminer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\MediaInfo\LiveMediaInfoResult.cs">
|
||||
<Link>MediaInfo\LiveMediaInfoResult.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\MediaInfo\MediaProtocol.cs">
|
||||
<Link>MediaInfo\MediaProtocol.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -723,6 +723,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\MediaInfo\IBlurayExaminer.cs">
|
||||
<Link>MediaInfo\IBlurayExaminer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\MediaInfo\LiveMediaInfoResult.cs">
|
||||
<Link>MediaInfo\LiveMediaInfoResult.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\MediaInfo\MediaProtocol.cs">
|
||||
<Link>MediaInfo\MediaProtocol.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -6,6 +6,7 @@ using MediaBrowser.Model.Entities;
|
|||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using MediaBrowser.Model.Playlists;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
|
@ -223,6 +224,13 @@ namespace MediaBrowser.Model.ApiClient
|
|||
/// <returns>Task{BaseItemDto[]}.</returns>
|
||||
Task<ItemsResult> GetAdditionalParts(string itemId, string userId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the live media information.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <returns>Task<LiveMediaInfoResult>.</returns>
|
||||
Task<LiveMediaInfoResult> GetLiveMediaInfo(string itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the users async.
|
||||
/// </summary>
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace MediaBrowser.Model.Configuration
|
|||
public bool DisplayMissingEpisodes { get; set; }
|
||||
public bool DisplayUnairedEpisodes { get; set; }
|
||||
public bool EnableRemoteControlOfOtherUsers { get; set; }
|
||||
public bool EnableSharedDeviceControl { get; set; }
|
||||
|
||||
public bool EnableLiveTvManagement { get; set; }
|
||||
public bool EnableLiveTvAccess { get; set; }
|
||||
|
@ -95,6 +96,7 @@ namespace MediaBrowser.Model.Configuration
|
|||
EnableLiveTvManagement = true;
|
||||
EnableMediaPlayback = true;
|
||||
EnableLiveTvAccess = true;
|
||||
EnableSharedDeviceControl = true;
|
||||
|
||||
LatestItemsExcludes = new string[] { };
|
||||
OrderedViews = new string[] { };
|
||||
|
|
|
@ -126,6 +126,7 @@
|
|||
<Compile Include="Dlna\SubtitleStreamInfo.cs" />
|
||||
<Compile Include="Drawing\ImageOrientation.cs" />
|
||||
<Compile Include="Dto\IHasServerId.cs" />
|
||||
<Compile Include="MediaInfo\LiveMediaInfoResult.cs" />
|
||||
<Compile Include="Dto\MediaSourceType.cs" />
|
||||
<Compile Include="Dto\StreamOptions.cs" />
|
||||
<Compile Include="Dto\VideoStreamOptions.cs" />
|
||||
|
|
25
MediaBrowser.Model/MediaInfo/LiveMediaInfoResult.cs
Normal file
25
MediaBrowser.Model/MediaInfo/LiveMediaInfoResult.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using MediaBrowser.Model.Dto;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Model.MediaInfo
|
||||
{
|
||||
public class LiveMediaInfoResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the media sources.
|
||||
/// </summary>
|
||||
/// <value>The media sources.</value>
|
||||
public List<MediaSourceInfo> MediaSources { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the live stream identifier.
|
||||
/// </summary>
|
||||
/// <value>The live stream identifier.</value>
|
||||
public string LiveStreamId { get; set; }
|
||||
|
||||
public LiveMediaInfoResult()
|
||||
{
|
||||
MediaSources = new List<MediaSourceInfo>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,8 +53,9 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MediaBrowser.BdInfo.1.0.0.10\lib\net35\DvdLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MediaBrowser.Naming">
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.6\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.7\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MoreLinq, Version=1.1.17511.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.BdInfo" version="1.0.0.10" targetFramework="net45" />
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.6" targetFramework="net45" />
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.7" targetFramework="net45" />
|
||||
<package id="morelinq" version="1.1.0" targetFramework="net45" />
|
||||
<package id="taglib" version="2.1.0.0" targetFramework="net45" />
|
||||
</packages>
|
|
@ -453,6 +453,14 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||
throw new ArgumentNullException("ConnectServerId");
|
||||
}
|
||||
|
||||
var sendingUser = GetUser(sendingUserId);
|
||||
var requesterUserName = sendingUser.ConnectUserName;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(requesterUserName))
|
||||
{
|
||||
throw new ArgumentException("A Connect account is required in order to send invitations.");
|
||||
}
|
||||
|
||||
string connectUserId = null;
|
||||
var result = new UserLinkResult();
|
||||
|
||||
|
@ -482,14 +490,6 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||
}
|
||||
}
|
||||
|
||||
var sendingUser = GetUser(sendingUserId);
|
||||
var requesterUserName = sendingUser.ConnectUserName;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(requesterUserName))
|
||||
{
|
||||
requesterUserName = sendingUser.Name;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(connectUserId))
|
||||
{
|
||||
return await SendNewUserInvitation(requesterUserName, connectUsername).ConfigureAwait(false);
|
||||
|
@ -781,6 +781,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
|||
user.Configuration.EnableLiveTvManagement = false;
|
||||
user.Configuration.EnableContentDeletion = false;
|
||||
user.Configuration.EnableRemoteControlOfOtherUsers = false;
|
||||
user.Configuration.EnableSharedDeviceControl = false;
|
||||
user.Configuration.IsAdministrator = false;
|
||||
|
||||
if (currentPendingEntry != null)
|
||||
|
|
|
@ -631,5 +631,8 @@
|
|||
"MessageForgotPasswordFileCreated": "The following file has been created on your server and contains instructions on how to proceed:",
|
||||
"MessageForgotPasswordFileExpiration": "The reset pin will expire at {0}.",
|
||||
"MessageInvalidForgotPasswordPin": "An invalid or expired pin was entered. Please try again.",
|
||||
"MessagePasswordResetForUsers": "Passwords have been reset for the following users:"
|
||||
"MessagePasswordResetForUsers": "Passwords have been reset for the following users:",
|
||||
"HeaderInviteGuest": "Invite Guest",
|
||||
"ButtonLinkMyMediaBrowserAccount": "Link my account now",
|
||||
"MessageConnectAccountRequiredToInviteGuest": "In order to invite guests you need to first link your Media Browser account to this server."
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
"OptionBudget": "Budget",
|
||||
"OptionRevenue": "Revenue",
|
||||
"OptionPoster": "Poster",
|
||||
"OptionPosterCard": "Poster card",
|
||||
"OptionPosterCard": "Poster card",
|
||||
"OptionBackdrop": "Backdrop",
|
||||
"OptionTimeline": "Timeline",
|
||||
"OptionThumb": "Thumb",
|
||||
|
@ -234,6 +234,9 @@
|
|||
"OptionAllowDeleteLibraryContent": "Allow this user to delete library content",
|
||||
"OptionAllowManageLiveTv": "Allow management of live tv recordings",
|
||||
"OptionAllowRemoteControlOthers": "Allow this user to remote control other users",
|
||||
"OptionAllowRemoteSharedDevices": "Allow this user to remote control shared devices",
|
||||
"OptionAllowRemoteSharedDevicesHelp": "Dlna devices are considered shared until a user begins controlling it.",
|
||||
"HeaderRemoteControl": "Remote Control",
|
||||
"OptionMissingTmdbId": "Missing Tmdb Id",
|
||||
"OptionIsHD": "HD",
|
||||
"OptionIsSD": "SD",
|
||||
|
@ -1237,7 +1240,7 @@
|
|||
"LabelConnectGuestUserNameHelp": "This is the username that your friend uses to sign in to the Media Browser website, or their email address.",
|
||||
"HeaderInviteUserHelp": "Sharing your media with friends is easier than ever before with Media Browser Connect.",
|
||||
"ButtonSendInvitation": "Send Invitation",
|
||||
"HeaderSignInWithConnect": "Sign in with Media Browser Connect",
|
||||
"HeaderSignInWithConnect": "Sign in with Media Browser Connect",
|
||||
"HeaderGuests": "Guests",
|
||||
"HeaderLocalUsers": "Local Users",
|
||||
"HeaderPendingInvitations": "Pending Invitations",
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</Reference>
|
||||
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.6\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.7\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.6" targetFramework="net45" />
|
||||
<package id="MediaBrowser.Naming" version="1.0.0.7" targetFramework="net45" />
|
||||
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
|
||||
<package id="morelinq" version="1.1.0" targetFramework="net45" />
|
||||
</packages>
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.509</version>
|
||||
<version>3.0.510</version>
|
||||
<title>MediaBrowser.Common.Internal</title>
|
||||
<authors>Luke</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.509" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.510" />
|
||||
<dependency id="NLog" version="3.1.0.0" />
|
||||
<dependency id="SimpleInjector" version="2.6.1" />
|
||||
<dependency id="sharpcompress" version="0.10.2" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.509</version>
|
||||
<version>3.0.510</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Model.Signed</id>
|
||||
<version>3.0.509</version>
|
||||
<version>3.0.510</version>
|
||||
<title>MediaBrowser.Model - Signed Edition</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.509</version>
|
||||
<version>3.0.510</version>
|
||||
<title>Media Browser.Server.Core</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.509" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.510" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
|
Loading…
Reference in New Issue
Block a user