enable user device access

pull/702/head
Luke Pulverenti 10 years ago
parent 800a16a213
commit 8a9f16ff6a

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Security;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
@ -299,6 +300,7 @@ namespace MediaBrowser.Api.Session
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IAuthorizationContext _authContext; private readonly IAuthorizationContext _authContext;
private readonly IAuthenticationRepository _authRepo; private readonly IAuthenticationRepository _authRepo;
private readonly IDeviceManager _deviceManager;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SessionsService" /> class. /// Initializes a new instance of the <see cref="SessionsService" /> class.
@ -307,12 +309,13 @@ namespace MediaBrowser.Api.Session
/// <param name="userManager">The user manager.</param> /// <param name="userManager">The user manager.</param>
/// <param name="authContext">The authentication context.</param> /// <param name="authContext">The authentication context.</param>
/// <param name="authRepo">The authentication repo.</param> /// <param name="authRepo">The authentication repo.</param>
public SessionsService(ISessionManager sessionManager, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo) public SessionsService(ISessionManager sessionManager, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo, IDeviceManager deviceManager)
{ {
_sessionManager = sessionManager; _sessionManager = sessionManager;
_userManager = userManager; _userManager = userManager;
_authContext = authContext; _authContext = authContext;
_authRepo = authRepo; _authRepo = authRepo;
_deviceManager = deviceManager;
} }
public void Delete(RevokeKey request) public void Delete(RevokeKey request)
@ -382,6 +385,21 @@ namespace MediaBrowser.Api.Session
{ {
result = result.Where(i => !i.UserId.HasValue); result = result.Where(i => !i.UserId.HasValue);
} }
result = result.Where(i =>
{
var deviceId = i.DeviceId;
if (!string.IsNullOrWhiteSpace(deviceId))
{
if (!_deviceManager.CanAccessDevice(user.Id.ToString("N"), deviceId))
{
return false;
}
}
return true;
});
} }
return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList()); return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList());

@ -52,6 +52,10 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.3.1.0.0\lib\net45\NLog.dll</HintPath> <HintPath>..\packages\NLog.3.1.0.0\lib\net45\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="SharpCompress, Version=0.10.2.0, Culture=neutral, PublicKeyToken=beaf6f427e128133, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="SimpleInjector, Version=2.6.1.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL"> <Reference Include="SimpleInjector, Version=2.6.1.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SimpleInjector.2.6.1\lib\net45\SimpleInjector.dll</HintPath> <HintPath>..\packages\SimpleInjector.2.6.1\lib\net45\SimpleInjector.dll</HintPath>
@ -65,9 +69,6 @@
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net" /> <Reference Include="System.Net" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="SharpCompress">
<HintPath>..\packages\sharpcompress.0.10.2\lib\net40\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text"> <Reference Include="ServiceStack.Text">
<HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath> <HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath>
</Reference> </Reference>

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="NLog" version="3.1.0.0" targetFramework="net45" /> <package id="NLog" version="3.1.0.0" targetFramework="net45" />
<package id="SharpCompress" version="0.10.2" targetFramework="net45" />
<package id="SimpleInjector" version="2.6.1" targetFramework="net45" /> <package id="SimpleInjector" version="2.6.1" targetFramework="net45" />
</packages> </packages>

@ -85,5 +85,13 @@ namespace MediaBrowser.Controller.Devices
/// <param name="file">The file.</param> /// <param name="file">The file.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file); Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file);
/// <summary>
/// Determines whether this instance [can access device] the specified user identifier.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="deviceId">The device identifier.</param>
/// <returns><c>true</c> if this instance [can access device] the specified user identifier; otherwise, <c>false</c>.</returns>
bool CanAccessDevice(string userId, string deviceId);
} }
} }

@ -89,6 +89,21 @@ namespace MediaBrowser.Controller.Entities.Audio
} }
} }
[IgnoreDataMember]
public bool IsArchive
{
get
{
if (string.IsNullOrWhiteSpace(Path))
{
return false;
}
var ext = System.IO.Path.GetExtension(Path) ?? string.Empty;
return new[] { ".zip", ".rar", ".7z" }.Contains(ext, StringComparer.OrdinalIgnoreCase);
}
}
/// <summary> /// <summary>
/// Gets or sets the artist. /// Gets or sets the artist.
/// </summary> /// </summary>

@ -91,6 +91,21 @@ namespace MediaBrowser.Controller.Entities
get { return LocalAlternateVersions.Count > 0; } get { return LocalAlternateVersions.Count > 0; }
} }
[IgnoreDataMember]
public bool IsArchive
{
get
{
if (string.IsNullOrWhiteSpace(Path))
{
return false;
}
var ext = System.IO.Path.GetExtension(Path) ?? string.Empty;
return new[] { ".zip", ".rar", ".7z" }.Contains(ext, StringComparer.OrdinalIgnoreCase);
}
}
public IEnumerable<Guid> GetAdditionalPartIds() public IEnumerable<Guid> GetAdditionalPartIds()
{ {
return AdditionalParts.Select(i => LibraryManager.GetNewItemId(i, typeof(Video))); return AdditionalParts.Select(i => LibraryManager.GetNewItemId(i, typeof(Video)));

@ -73,11 +73,19 @@ namespace MediaBrowser.Model.Net
{".m4v", "video/x-m4v"} {".m4v", "video/x-m4v"}
}; };
private static readonly Dictionary<string, string> ExtensionLookup = private static readonly Dictionary<string, string> ExtensionLookup = CreateExtensionLookup();
MimeTypeLookup
private static Dictionary<string, string> CreateExtensionLookup()
{
var dict = MimeTypeLookup
.GroupBy(i => i.Value) .GroupBy(i => i.Value)
.ToDictionary(x => x.Key, x => x.First().Key, StringComparer.OrdinalIgnoreCase); .ToDictionary(x => x.Key, x => x.First().Key, StringComparer.OrdinalIgnoreCase);
dict["image/jpg"] = ".jpg";
return dict;
}
/// <summary> /// <summary>
/// Gets the type of the MIME. /// Gets the type of the MIME.
/// </summary> /// </summary>

@ -49,6 +49,9 @@ namespace MediaBrowser.Model.Users
/// <value><c>true</c> if [enable synchronize]; otherwise, <c>false</c>.</value> /// <value><c>true</c> if [enable synchronize]; otherwise, <c>false</c>.</value>
public bool EnableSync { get; set; } public bool EnableSync { get; set; }
public string[] EnabledDevices { get; set; }
public bool EnableAllDevices { get; set; }
public UserPolicy() public UserPolicy()
{ {
EnableLiveTvManagement = true; EnableLiveTvManagement = true;
@ -64,6 +67,9 @@ namespace MediaBrowser.Model.Users
EnableUserPreferenceAccess = true; EnableUserPreferenceAccess = true;
AccessSchedules = new AccessSchedule[] { }; AccessSchedules = new AccessSchedule[] { };
EnabledDevices = new string[] { };
EnableAllDevices = true;
} }
} }
} }

@ -6,7 +6,6 @@ using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -132,7 +131,9 @@ namespace MediaBrowser.Providers.MediaInfo
public bool Supports(IHasImages item) public bool Supports(IHasImages item)
{ {
return item is Audio; var audio = item as Audio;
return item.LocationType == LocationType.FileSystem && audio != null && !audio.IsArchive;
} }
public bool HasChanged(IHasMetadata item, MetadataStatus status, IDirectoryService directoryService) public bool HasChanged(IHasMetadata item, MetadataStatus status, IDirectoryService directoryService)

@ -38,6 +38,13 @@ namespace MediaBrowser.Providers.MediaInfo
public async Task<ItemUpdateType> Probe<T>(T item, CancellationToken cancellationToken) public async Task<ItemUpdateType> Probe<T>(T item, CancellationToken cancellationToken)
where T : Audio where T : Audio
{ {
if (item.IsArchive)
{
var ext = Path.GetExtension(item.Path) ?? string.Empty;
item.Container = ext.TrimStart('.');
return ItemUpdateType.MetadataImport;
}
var result = await GetMediaInfo(item, cancellationToken).ConfigureAwait(false); var result = await GetMediaInfo(item, cancellationToken).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();

@ -71,6 +71,13 @@ namespace MediaBrowser.Providers.MediaInfo
CancellationToken cancellationToken) CancellationToken cancellationToken)
where T : Video where T : Video
{ {
if (item.IsArchive)
{
var ext = Path.GetExtension(item.Path) ?? string.Empty;
item.Container = ext.TrimStart('.');
return ItemUpdateType.MetadataImport;
}
var isoMount = await MountIsoIfNeeded(item, cancellationToken).ConfigureAwait(false); var isoMount = await MountIsoIfNeeded(item, cancellationToken).ConfigureAwait(false);
BlurayDiscInfo blurayDiscInfo = null; BlurayDiscInfo blurayDiscInfo = null;

@ -123,7 +123,7 @@ namespace MediaBrowser.Providers.MediaInfo
{ {
var video = item as Video; var video = item as Video;
return item.LocationType == LocationType.FileSystem && video != null && !video.IsPlaceHolder && !video.IsShortcut; return item.LocationType == LocationType.FileSystem && video != null && !video.IsPlaceHolder && !video.IsShortcut && !video.IsArchive;
} }
public int Order public int Order

@ -5,6 +5,7 @@ using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Devices; using MediaBrowser.Model.Devices;
using MediaBrowser.Model.Events; using MediaBrowser.Model.Events;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Session; using MediaBrowser.Model.Session;
@ -13,6 +14,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Server.Implementations.Devices namespace MediaBrowser.Server.Implementations.Devices
{ {
@ -188,6 +190,41 @@ namespace MediaBrowser.Server.Implementations.Devices
EventHelper.FireEventIfNotNull(DeviceOptionsUpdated, this, new GenericEventArgs<DeviceInfo>(device), _logger); EventHelper.FireEventIfNotNull(DeviceOptionsUpdated, this, new GenericEventArgs<DeviceInfo>(device), _logger);
} }
public bool CanAccessDevice(string userId, string deviceId)
{
if (string.IsNullOrWhiteSpace(userId))
{
throw new ArgumentNullException("userId");
}
if (string.IsNullOrWhiteSpace(deviceId))
{
throw new ArgumentNullException("deviceId");
}
var user = _userManager.GetUserById(userId);
if (!CanAccessDevice(user.Policy, deviceId))
{
var capabilities = GetCapabilities(deviceId);
if (capabilities.SupportsUniqueIdentifier)
{
return false;
}
}
return true;
}
private bool CanAccessDevice(UserPolicy policy, string id)
{
if (policy.EnableAllDevices)
{
return true;
}
return ListHelper.ContainsIgnoreCase(policy.EnabledDevices, id);
}
} }
public class DevicesConfigStore : IConfigurationFactory public class DevicesConfigStore : IConfigurationFactory

@ -1,5 +1,6 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
@ -15,10 +16,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
{ {
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
public AuthService(IUserManager userManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config, IConnectManager connectManager, ISessionManager sessionManager) public AuthService(IUserManager userManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config, IConnectManager connectManager, ISessionManager sessionManager, IDeviceManager deviceManager)
{ {
AuthorizationContext = authorizationContext; AuthorizationContext = authorizationContext;
_config = config; _config = config;
DeviceManager = deviceManager;
SessionManager = sessionManager; SessionManager = sessionManager;
ConnectManager = connectManager; ConnectManager = connectManager;
UserManager = userManager; UserManager = userManager;
@ -28,6 +30,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
public IAuthorizationContext AuthorizationContext { get; private set; } public IAuthorizationContext AuthorizationContext { get; private set; }
public IConnectManager ConnectManager { get; private set; } public IConnectManager ConnectManager { get; private set; }
public ISessionManager SessionManager { get; private set; } public ISessionManager SessionManager { get; private set; }
public IDeviceManager DeviceManager { get; private set; }
/// <summary> /// <summary>
/// Redirect the client to a specific URL if authentication failed. /// Redirect the client to a specific URL if authentication failed.
@ -67,6 +70,33 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
} }
if (user != null) if (user != null)
{
ValidateUserAccess(user, request, authAttribtues, auth);
}
if (!IsExemptFromRoles(auth, authAttribtues))
{
var roles = authAttribtues.GetRoles().ToList();
ValidateRoles(roles, user);
}
if (!string.IsNullOrWhiteSpace(auth.DeviceId) &&
!string.IsNullOrWhiteSpace(auth.Client) &&
!string.IsNullOrWhiteSpace(auth.Device))
{
SessionManager.LogSessionActivity(auth.Client,
auth.Version,
auth.DeviceId,
auth.Device,
request.RemoteIp,
user);
}
}
private void ValidateUserAccess(User user, IServiceRequest request,
IAuthenticationAttributes authAttribtues,
AuthorizationInfo auth)
{ {
if (user.Policy.IsDisabled) if (user.Policy.IsDisabled)
{ {
@ -81,30 +111,22 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
!user.IsParentalScheduleAllowed()) !user.IsParentalScheduleAllowed())
{ {
request.AddResponseHeader("X-Application-Error-Code", "ParentalControl"); request.AddResponseHeader("X-Application-Error-Code", "ParentalControl");
throw new SecurityException("This user account is not allowed access at this time.") throw new SecurityException("This user account is not allowed access at this time.")
{ {
SecurityExceptionType = SecurityExceptionType.ParentalControl SecurityExceptionType = SecurityExceptionType.ParentalControl
}; };
} }
}
if (!IsExemptFromRoles(auth, authAttribtues)) if (!string.IsNullOrWhiteSpace(auth.DeviceId))
{ {
var roles = authAttribtues.GetRoles().ToList(); if (!DeviceManager.CanAccessDevice(user.Id.ToString("N"), auth.DeviceId))
ValidateRoles(roles, user);
}
if (!string.IsNullOrWhiteSpace(auth.DeviceId) &&
!string.IsNullOrWhiteSpace(auth.Client) &&
!string.IsNullOrWhiteSpace(auth.Device))
{ {
SessionManager.LogSessionActivity(auth.Client, throw new SecurityException("User is not allowed access from this device.")
auth.Version, {
auth.DeviceId, SecurityExceptionType = SecurityExceptionType.ParentalControl
auth.Device, };
request.RemoteIp, }
user);
} }
} }

@ -25,11 +25,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Contains [boxset] in the path // Contains [boxset] in the path
if (args.IsDirectory) if (args.IsDirectory)
{ {
if (IsInvalid(args.GetCollectionType()))
{
return null;
}
var filename = Path.GetFileName(args.Path); var filename = Path.GetFileName(args.Path);
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(filename))

@ -1,12 +1,9 @@
using MediaBrowser.Common.IO; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Naming.Common; using MediaBrowser.Naming.Common;
using MediaBrowser.Naming.IO; using MediaBrowser.Naming.IO;
using MediaBrowser.Naming.Video; using MediaBrowser.Naming.Video;
@ -22,16 +19,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
/// </summary> /// </summary>
public class MovieResolver : BaseVideoResolver<Video>, IMultiItemResolver public class MovieResolver : BaseVideoResolver<Video>, IMultiItemResolver
{ {
private readonly IServerApplicationPaths _applicationPaths; public MovieResolver(ILibraryManager libraryManager) : base(libraryManager)
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
public MovieResolver(ILibraryManager libraryManager, IServerApplicationPaths applicationPaths, ILogger logger, IFileSystem fileSystem)
: base(libraryManager)
{ {
_applicationPaths = applicationPaths;
_logger = logger;
_fileSystem = fileSystem;
} }
/// <summary> /// <summary>
@ -62,12 +51,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
{ {
return ResolveVideos<MusicVideo>(parent, files, directoryService, collectionType); return ResolveVideos<MusicVideo>(parent, files, directoryService, collectionType, false);
} }
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
{ {
return ResolveVideos<Video>(parent, files, directoryService, collectionType); return ResolveVideos<Video>(parent, files, directoryService, collectionType, false);
} }
if (string.IsNullOrEmpty(collectionType)) if (string.IsNullOrEmpty(collectionType))
@ -75,21 +64,21 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Owned items should just use the plain video type // Owned items should just use the plain video type
if (parent == null) if (parent == null)
{ {
return ResolveVideos<Video>(parent, files, directoryService, collectionType); return ResolveVideos<Video>(parent, files, directoryService, collectionType, false);
} }
return ResolveVideos<Video>(parent, files, directoryService, collectionType); return ResolveVideos<Video>(parent, files, directoryService, collectionType, false);
} }
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{ {
return ResolveVideos<Movie>(parent, files, directoryService, collectionType); return ResolveVideos<Movie>(parent, files, directoryService, collectionType, false);
} }
return null; return null;
} }
private MultiItemResolverResult ResolveVideos<T>(Folder parent, IEnumerable<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, string collectionType) private MultiItemResolverResult ResolveVideos<T>(Folder parent, IEnumerable<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool suppportMultiEditions)
where T : Video, new() where T : Video, new()
{ {
var files = new List<FileSystemInfo>(); var files = new List<FileSystemInfo>();
@ -115,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
FullName = i.FullName, FullName = i.FullName,
Type = FileInfoType.File Type = FileInfoType.File
}).ToList(), false).ToList(); }).ToList(), suppportMultiEditions).ToList();
var result = new MultiItemResolverResult var result = new MultiItemResolverResult
{ {
@ -135,7 +124,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
IsInMixedFolder = isInMixedFolder, IsInMixedFolder = isInMixedFolder,
ProductionYear = video.Year, ProductionYear = video.Year,
Name = video.Name, Name = video.Name,
AdditionalParts = video.Files.Skip(1).Select(i => i.Path).ToList() AdditionalParts = video.Files.Skip(1).Select(i => i.Path).ToList(),
LocalAlternateVersions = video.AlternateVersions.Select(i => i.Path).ToList()
}; };
SetVideoType(videoItem, firstVideo); SetVideoType(videoItem, firstVideo);
@ -315,31 +305,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
} }
} }
var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, collectionType);
var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) && var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) &&
!string.Equals(collectionType, CollectionType.MusicVideos); !string.Equals(collectionType, CollectionType.MusicVideos);
// Test for multi-editions var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, collectionType, supportsMultiVersion);
if (result.Items.Count > 1 && supportsMultiVersion)
{
var filenamePrefix = Path.GetFileName(path);
if (!string.IsNullOrWhiteSpace(filenamePrefix))
{
if (result.Items.All(i => _fileSystem.GetFileNameWithoutExtension(i.Path).StartsWith(filenamePrefix + " - ", StringComparison.OrdinalIgnoreCase)))
{
var movie = (T)result.Items[0];
movie.Name = filenamePrefix;
movie.LocalAlternateVersions = result.Items.Skip(1).Select(i => i.Path).ToList();
movie.IsInMixedFolder = false;
_logger.Debug("Multi-version video found: " + movie.Path);
return movie;
}
}
}
if (result.Items.Count == 1) if (result.Items.Count == 1)
{ {

@ -41,6 +41,10 @@
"LabelCancelled": "(cancelled)", "LabelCancelled": "(cancelled)",
"LabelFailed": "(failed)", "LabelFailed": "(failed)",
"ButtonHelp": "Help", "ButtonHelp": "Help",
"HeaderLibraryAccess": "Library Access",
"HeaderChannelAccess": "Channel Access",
"HeaderDeviceAccess": "Device Access",
"HeaderSelectDevices": "Select Devices",
"LabelAbortedByServerShutdown": "(Aborted by server shutdown)", "LabelAbortedByServerShutdown": "(Aborted by server shutdown)",
"LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.", "LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.",
"HeaderDeleteTaskTrigger": "Delete Task Trigger", "HeaderDeleteTaskTrigger": "Delete Task Trigger",

@ -63,12 +63,16 @@
"TabPreferences": "Preferences", "TabPreferences": "Preferences",
"TabPassword": "Password", "TabPassword": "Password",
"TabLibraryAccess": "Library Access", "TabLibraryAccess": "Library Access",
"TabAccess": "Access",
"TabImage": "Image", "TabImage": "Image",
"TabProfile": "Profile", "TabProfile": "Profile",
"TabMetadata": "Metadata", "TabMetadata": "Metadata",
"TabImages": "Images", "TabImages": "Images",
"TabNotifications": "Notifications", "TabNotifications": "Notifications",
"TabCollectionTitles": "Titles", "TabCollectionTitles": "Titles",
"HeaderDeviceAccess": "Device Access",
"OptionEnableAccessFromAllDevices": "Enable access from all devices",
"DeviceAccessHelp": "This only applies to devices that can be uniquely identified and will not prevent browser access.",
"LabelDisplayMissingEpisodesWithinSeasons": "Display missing episodes within seasons", "LabelDisplayMissingEpisodesWithinSeasons": "Display missing episodes within seasons",
"LabelUnairedMissingEpisodesWithinSeasons": "Display unaired episodes within seasons", "LabelUnairedMissingEpisodesWithinSeasons": "Display unaired episodes within seasons",
"HeaderVideoPlaybackSettings": "Video Playback Settings", "HeaderVideoPlaybackSettings": "Video Playback Settings",

@ -51,7 +51,7 @@
</Reference> </Reference>
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.23\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath> <HintPath>..\packages\MediaBrowser.Naming.1.0.0.24\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
</Reference> </Reference>
<Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>

@ -1191,6 +1191,14 @@ namespace MediaBrowser.Server.Implementations.Session
var user = _userManager.Users var user = _userManager.Users
.FirstOrDefault(i => string.Equals(request.Username, i.Name, StringComparison.OrdinalIgnoreCase)); .FirstOrDefault(i => string.Equals(request.Username, i.Name, StringComparison.OrdinalIgnoreCase));
if (user != null && !string.IsNullOrWhiteSpace(request.DeviceId))
{
if (!_deviceManager.CanAccessDevice(user.Id.ToString("N"), request.DeviceId))
{
throw new UnauthorizedAccessException("User is not allowed access from this device.");
}
}
var result = await _userManager.AuthenticateUser(request.Username, request.PasswordSha1, request.PasswordMd5, request.RemoteEndPoint).ConfigureAwait(false); var result = await _userManager.AuthenticateUser(request.Username, request.PasswordSha1, request.PasswordMd5, request.RemoteEndPoint).ConfigureAwait(false);
if (!result) if (!result)

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.Naming" version="1.0.0.23" targetFramework="net45" /> <package id="MediaBrowser.Naming" version="1.0.0.24" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" /> <package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
<package id="morelinq" version="1.1.0" targetFramework="net45" /> <package id="morelinq" version="1.1.0" targetFramework="net45" />
</packages> </packages>

@ -558,7 +558,7 @@ namespace MediaBrowser.Server.Startup.Common
var authContext = new AuthorizationContext(AuthenticationRepository); var authContext = new AuthorizationContext(AuthenticationRepository);
RegisterSingleInstance<IAuthorizationContext>(authContext); RegisterSingleInstance<IAuthorizationContext>(authContext);
RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager)); RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
RegisterSingleInstance<IAuthService>(new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager, SessionManager)); RegisterSingleInstance<IAuthService>(new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager, SessionManager, DeviceManager));
RegisterSingleInstance<ISubtitleEncoder>(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer)); RegisterSingleInstance<ISubtitleEncoder>(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer));

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.537</version> <version>3.0.538</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,10 +12,9 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description> <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> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.537" /> <dependency id="MediaBrowser.Common" version="3.0.538" />
<dependency id="NLog" version="3.1.0.0" /> <dependency id="NLog" version="3.1.0.0" />
<dependency id="SimpleInjector" version="2.6.1" /> <dependency id="SimpleInjector" version="2.6.1" />
<dependency id="sharpcompress" version="0.10.2" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.537</version> <version>3.0.538</version>
<title>MediaBrowser.Common</title> <title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Model.Signed</id> <id>MediaBrowser.Model.Signed</id>
<version>3.0.537</version> <version>3.0.538</version>
<title>MediaBrowser.Model - Signed Edition</title> <title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.537</version> <version>3.0.538</version>
<title>Media Browser.Server.Core</title> <title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description> <description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.537" /> <dependency id="MediaBrowser.Common" version="3.0.538" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>

Loading…
Cancel
Save