diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs
index 0c95f6112..17c36254e 100644
--- a/MediaBrowser.Api/BaseApiService.cs
+++ b/MediaBrowser.Api/BaseApiService.cs
@@ -1,5 +1,7 @@
using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
using ServiceStack.Common.Web;
using ServiceStack.ServiceHost;
@@ -100,6 +102,8 @@ namespace MediaBrowser.Api
/// The user manager.
public IUserManager UserManager { get; set; }
+ public ISessionManager SessionManager { get; set; }
+
///
/// Gets or sets the logger.
///
@@ -122,11 +126,20 @@ namespace MediaBrowser.Api
{
var userId = auth["UserId"];
+ User user = null;
+
if (!string.IsNullOrEmpty(userId))
{
- var user = UserManager.GetUserById(new Guid(userId));
+ user = UserManager.GetUserById(new Guid(userId));
+ }
- UserManager.LogUserActivity(user, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
+ var deviceId = auth["DeviceId"];
+ var device = auth["Device"];
+ var client = auth["Client"];
+
+ if (!string.IsNullOrEmpty(client) && !string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(device))
+ {
+ SessionManager.LogConnectionActivity(client, deviceId, device, user);
}
}
}
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index b17412ee6..7ed030a87 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -88,6 +88,7 @@
+
diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs
new file mode 100644
index 000000000..03a352307
--- /dev/null
+++ b/MediaBrowser.Api/SessionsService.cs
@@ -0,0 +1,54 @@
+using MediaBrowser.Controller.Session;
+using MediaBrowser.Model.Session;
+using ServiceStack.ServiceHost;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace MediaBrowser.Api
+{
+ ///
+ /// Class GetSessions
+ ///
+ [Route("/Sessions", "GET")]
+ [Api(("Gets a list of sessions"))]
+ public class GetSessions : IReturn>
+ {
+ ///
+ /// Gets or sets a value indicating whether this instance is recent.
+ ///
+ /// true if this instance is recent; otherwise, false.
+ public bool IsRecent { get; set; }
+ }
+
+ ///
+ /// Class SessionsService
+ ///
+ public class SessionsService : BaseApiService
+ {
+ ///
+ /// The _session manager
+ ///
+ private readonly ISessionManager _sessionManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The session manager.
+ public SessionsService(ISessionManager sessionManager)
+ {
+ _sessionManager = sessionManager;
+ }
+
+ ///
+ /// Gets the specified request.
+ ///
+ /// The request.
+ /// System.Object.
+ public object Get(GetSessions request)
+ {
+ var result = request.IsRecent ? _sessionManager.RecentConnections : _sessionManager.AllConnections;
+
+ return ToOptimizedResult(result.ToList());
+ }
+ }
+}
diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
index 5c1eff954..53f2e9bca 100644
--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
+++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
+using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Querying;
using ServiceStack.ServiceHost;
@@ -401,6 +402,8 @@ namespace MediaBrowser.Api.UserLibrary
private readonly IItemRepository _itemRepo;
+ private readonly ISessionManager _sessionManager;
+
///
/// Initializes a new instance of the class.
///
@@ -409,13 +412,14 @@ namespace MediaBrowser.Api.UserLibrary
/// The user data repository.
/// The item repo.
/// jsonSerializer
- public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
+ public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, ISessionManager sessionManager)
: base()
{
_userManager = userManager;
_libraryManager = libraryManager;
_userDataRepository = userDataRepository;
_itemRepo = itemRepo;
+ _sessionManager = sessionManager;
}
///
@@ -693,7 +697,7 @@ namespace MediaBrowser.Api.UserLibrary
if (auth != null)
{
- _userManager.OnPlaybackStart(user, item, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
+ _sessionManager.OnPlaybackStart(user, item, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
}
}
@@ -711,7 +715,7 @@ namespace MediaBrowser.Api.UserLibrary
if (auth != null)
{
- var task = _userManager.OnPlaybackProgress(user, item, request.PositionTicks, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
+ var task = _sessionManager.OnPlaybackProgress(user, item, request.PositionTicks, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
Task.WaitAll(task);
}
@@ -731,7 +735,7 @@ namespace MediaBrowser.Api.UserLibrary
if (auth != null)
{
- var task = _userManager.OnPlaybackStopped(user, item, request.PositionTicks, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
+ var task = _sessionManager.OnPlaybackStopped(user, item, request.PositionTicks, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
Task.WaitAll(task);
}
diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs
index d84227059..167ff2f78 100644
--- a/MediaBrowser.Controller/Dto/DtoBuilder.cs
+++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs
@@ -832,6 +832,7 @@ namespace MediaBrowser.Controller.Dto
{
Id = GetClientItemId(item),
Name = item.Name,
+ MediaType = item.MediaType,
Type = item.GetType().Name,
IsFolder = item.IsFolder,
RunTimeTicks = item.RunTimeTicks
@@ -844,16 +845,6 @@ namespace MediaBrowser.Controller.Dto
info.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Primary, imagePath);
}
- if (item.BackdropImagePaths != null && item.BackdropImagePaths.Count > 0)
- {
- imagePath = item.BackdropImagePaths[0];
-
- if (!string.IsNullOrEmpty(imagePath))
- {
- info.BackdropImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Backdrop, imagePath);
- }
- }
-
return info;
}
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index e31939d59..43c629505 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -683,7 +683,7 @@ namespace MediaBrowser.Controller.Entities
/// Loads local trailers from the file system
///
/// List{Video}.
- private List LoadLocalTrailers()
+ private IEnumerable LoadLocalTrailers()
{
if (LocationType != LocationType.FileSystem)
{
@@ -746,7 +746,7 @@ namespace MediaBrowser.Controller.Entities
/// Loads the theme songs.
///
/// List{Audio.Audio}.
- private List LoadThemeSongs()
+ private IEnumerable LoadThemeSongs()
{
if (LocationType != LocationType.FileSystem)
{
@@ -809,7 +809,7 @@ namespace MediaBrowser.Controller.Entities
/// Loads the video backdrops.
///
/// List{Video}.
- private List