diff options
| author | dkanada <dkanada@users.noreply.github.com> | 2020-02-02 00:16:11 +0900 |
|---|---|---|
| committer | dkanada <dkanada@users.noreply.github.com> | 2020-02-02 00:16:11 +0900 |
| commit | 1bc8ca25421dd3b66a58e1ff0938ee7874d8448e (patch) | |
| tree | 2b658fdf068b70777e4aba51e34812cc6b7472eb | |
| parent | 26dd67a441d251bef56c14d8058e7068e38e06af (diff) | |
add session view endpoint
| -rw-r--r-- | Emby.Server.Implementations/Session/SessionManager.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Api/Session/SessionsService.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Session/SessionInfo.cs | 2 |
3 files changed, 25 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 659483a36..8e52f2415 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1686,18 +1686,18 @@ namespace Emby.Server.Implementations.Session throw new ArgumentNullException(nameof(itemId)); } - //var item = _libraryManager.GetItemById(new Guid(itemId)); + var item = _libraryManager.GetItemById(new Guid(itemId)); - //var info = GetItemInfo(item, null, null); + var info = GetItemInfo(item, null); - //ReportNowViewingItem(sessionId, info); + ReportNowViewingItem(sessionId, info); } public void ReportNowViewingItem(string sessionId, BaseItemDto item) { - //var session = GetSession(sessionId); + var session = GetSession(sessionId); - //session.NowViewingItem = item; + session.NowViewingItem = item; } public void ReportTranscodingInfo(string deviceId, TranscodingInfo info) diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index 8e53490ff..df816927a 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -230,6 +230,17 @@ namespace MediaBrowser.Api.Session public string Id { get; set; } } + [Route("/Sessions/Viewing", "POST", Summary = "Reports that a session is viewing an item")] + [Authenticated] + public class ReportViewing : IReturnVoid + { + [ApiMember(Name = "SessionId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] + public string SessionId { get; set; } + + [ApiMember(Name = "ItemId", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string ItemId { get; set; } + } + [Route("/Sessions/Logout", "POST", Summary = "Reports that a session has ended")] [Authenticated] public class ReportSessionEnded : IReturnVoid @@ -536,5 +547,12 @@ namespace MediaBrowser.Api.Session _sessionManager.ReportCapabilities(request.Id, request); } + + public void Post(ReportViewing request) + { + request.SessionId = GetSession(_sessionContext).Id; + + _sessionManager.ReportNowViewingItem(request.SessionId, request.ItemId); + } } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 964fc9b19..7bc50eb41 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -106,6 +106,8 @@ namespace MediaBrowser.Controller.Session public BaseItem FullNowPlayingItem { get; set; } + public BaseItemDto NowViewingItem { get; set; } + /// <summary> /// Gets or sets the device id. /// </summary> |
