sync updates
This commit is contained in:
parent
306c5041f0
commit
ea92065df0
|
@ -1,15 +1,19 @@
|
|||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Activity;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using ServiceStack;
|
||||
using System;
|
||||
|
@ -251,24 +255,24 @@ namespace MediaBrowser.Api.Library
|
|||
private readonly IUserDataManager _userDataManager;
|
||||
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IAuthorizationContext _authContext;
|
||||
private readonly IActivityManager _activityManager;
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
/// <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, IAuthorizationContext authContext)
|
||||
IDtoService dtoService, IUserDataManager userDataManager, IAuthorizationContext authContext, IActivityManager activityManager, ILocalizationManager localization)
|
||||
{
|
||||
_itemRepo = itemRepo;
|
||||
_libraryManager = libraryManager;
|
||||
_userManager = userManager;
|
||||
_dtoService = dtoService;
|
||||
_userDataManager = userDataManager;
|
||||
_channelManager = channelManager;
|
||||
_sessionManager = sessionManager;
|
||||
_authContext = authContext;
|
||||
_activityManager = activityManager;
|
||||
_localization = localization;
|
||||
}
|
||||
|
||||
public object Get(GetMediaFolders request)
|
||||
|
@ -302,10 +306,23 @@ namespace MediaBrowser.Api.Library
|
|||
public object Get(GetDownload request)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(request.Id);
|
||||
var auth = _authContext.GetAuthorizationInfo(Request);
|
||||
|
||||
if (!item.CanDelete())
|
||||
var user = _userManager.GetUserById(auth.UserId);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
throw new ArgumentException("Item does not support downloading");
|
||||
if (!item.CanDownload(user))
|
||||
{
|
||||
throw new ArgumentException("Item does not support downloading");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!item.CanDownload())
|
||||
{
|
||||
throw new ArgumentException("Item does not support downloading");
|
||||
}
|
||||
}
|
||||
|
||||
var headers = new Dictionary<string, string>();
|
||||
|
@ -314,6 +331,11 @@ namespace MediaBrowser.Api.Library
|
|||
var filename = Path.GetFileName(item.Path).Replace("\"", string.Empty);
|
||||
headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
LogDownload(item, user, auth);
|
||||
}
|
||||
|
||||
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||
{
|
||||
Path = item.Path,
|
||||
|
@ -321,6 +343,25 @@ namespace MediaBrowser.Api.Library
|
|||
});
|
||||
}
|
||||
|
||||
private async void LogDownload(BaseItem item, User user, AuthorizationInfo auth)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _activityManager.Create(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(_localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Name, item.Name),
|
||||
Type = "UserDownloadingContent",
|
||||
ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device),
|
||||
UserId = auth.UserId
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Logged at lower levels
|
||||
}
|
||||
}
|
||||
|
||||
public object Get(GetFile request)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(request.Id);
|
||||
|
|
|
@ -323,13 +323,13 @@ namespace MediaBrowser.Api.Playback
|
|||
switch (qualitySetting)
|
||||
{
|
||||
case EncodingQuality.HighSpeed:
|
||||
param += " -subq 0 -crf 23";
|
||||
param += " -crf 23";
|
||||
break;
|
||||
case EncodingQuality.HighQuality:
|
||||
param += " -subq 3 -crf 20";
|
||||
param += " -crf 20";
|
||||
break;
|
||||
case EncodingQuality.MaxQuality:
|
||||
param += " -subq 6 -crf 18";
|
||||
param += " -crf 18";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -631,13 +631,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
switch (qualitySetting)
|
||||
{
|
||||
case EncodingQuality.HighSpeed:
|
||||
param += " -subq 0 -crf 23";
|
||||
param += " -crf 28";
|
||||
break;
|
||||
case EncodingQuality.HighQuality:
|
||||
param += " -subq 3 -crf 20";
|
||||
param += " -crf 25";
|
||||
break;
|
||||
case EncodingQuality.MaxQuality:
|
||||
param += " -subq 6 -crf 18";
|
||||
param += " -crf 21";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,6 +129,20 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
|||
if (tokenInfo != null)
|
||||
{
|
||||
info.UserId = tokenInfo.UserId;
|
||||
|
||||
// TODO: Remove these checks for IsNullOrWhiteSpace
|
||||
if (string.IsNullOrWhiteSpace(info.Client))
|
||||
{
|
||||
info.Client = tokenInfo.AppName;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(info.Device))
|
||||
{
|
||||
info.Device = tokenInfo.DeviceName;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(info.DeviceId))
|
||||
{
|
||||
info.DeviceId = tokenInfo.DeviceId;
|
||||
}
|
||||
}
|
||||
httpReq.Items["OriginalAuthenticationInfo"] = tokenInfo;
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
dto.HasPassword = !IsPasswordEmpty(offlinePasswordHash);
|
||||
|
||||
// Hash the pin with the device Id to create a unique result for this device
|
||||
dto.OfflinePassword = GetSha1String(offlinePasswordHash + deviceId);
|
||||
dto.OfflinePassword = GetSha1String((offlinePasswordHash + deviceId).ToLower());
|
||||
|
||||
dto.ServerName = _appHost.FriendlyName;
|
||||
|
||||
|
|
|
@ -1114,6 +1114,7 @@
|
|||
"MessageApplicationUpdated": "Media Browser Server has been updated",
|
||||
"AuthenticationSucceededWithUserName": "{0} successfully authenticated",
|
||||
"FailedLoginAttemptWithUserName": "Failed login attempt from {0}",
|
||||
"UserDownloadingItemWithValues": "{0} is downloading {1}",
|
||||
"UserStartedPlayingItemWithValues": "{0} has started playing {1}",
|
||||
"UserStoppedPlayingItemWithValues": "{0} has stopped playing {1}",
|
||||
"AppDeviceValues": "App: {0}, Device: {1}",
|
||||
|
|
|
@ -439,6 +439,16 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
return true;
|
||||
}
|
||||
|
||||
if (item is Person)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item is Year)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase) ||
|
||||
|
|
Loading…
Reference in New Issue
Block a user