Skip to content

Commit

Permalink
Merge pull request #1012 from MediaBrowser/dev
Browse files Browse the repository at this point in the history
3.0.5518.4
  • Loading branch information
LukePulverenti committed Feb 13, 2015
2 parents c0ea228 + 1155298 commit d69562f
Show file tree
Hide file tree
Showing 81 changed files with 537 additions and 334 deletions.
57 changes: 49 additions & 8 deletions MediaBrowser.Api/Library/LibraryService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -251,24 +255,24 @@ public class LibraryService : BaseApiService
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)
Expand Down Expand Up @@ -302,10 +306,23 @@ public void Post(PostUpdatedSeries request)
public object Get(GetDownload request)
{
var item = _libraryManager.GetItemById(request.Id);
var auth = _authContext.GetAuthorizationInfo(Request);

var user = _userManager.GetUserById(auth.UserId);

if (!item.CanDelete())
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>();
Expand All @@ -314,13 +331,37 @@ public object Get(GetDownload request)
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,
ResponseHeaders = headers
});
}

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);
Expand Down
6 changes: 3 additions & 3 deletions MediaBrowser.Api/Playback/BaseStreamingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ protected string GetVideoQualityParam(StreamState state, string videoCodec, bool
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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,13 @@ protected string GetVideoQualityParam(EncodingJob state, string videoCodec, bool
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;
}
}
Expand Down
18 changes: 10 additions & 8 deletions MediaBrowser.Server.Implementations/Dto/DtoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public IEnumerable<BaseItemDto> GetBaseItemDtos(IEnumerable<BaseItem> items, Dto
SetItemByNameInfo(item, dto, libraryItems.ToList(), user);
}

FillSyncInfo(dto, item, itemIdsWithSyncJobs, options);
FillSyncInfo(dto, item, itemIdsWithSyncJobs, options, user);

list.Add(dto);
}
Expand All @@ -128,11 +128,11 @@ public BaseItemDto GetBaseItemDto(BaseItem item, DtoOptions options, User user =

SetItemByNameInfo(item, dto, libraryItems.ToList(), user);

FillSyncInfo(dto, item, options);
FillSyncInfo(dto, item, options, user);
return dto;
}

FillSyncInfo(dto, item, options);
FillSyncInfo(dto, item, options, user);

return dto;
}
Expand Down Expand Up @@ -171,11 +171,12 @@ private IEnumerable<string> GetItemIdsWithSyncJobs(DtoOptions options)
return result.Items;
}

private void FillSyncInfo(BaseItemDto dto, BaseItem item, DtoOptions options)
private void FillSyncInfo(BaseItemDto dto, BaseItem item, DtoOptions options, User user)
{
if (options.Fields.Contains(ItemFields.SyncInfo))
{
dto.SupportsSync = _syncManager.SupportsSync(item);
var userCanSync = user != null && user.Policy.EnableSync;
dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item);
}

if (dto.SupportsSync ?? false)
Expand All @@ -184,11 +185,12 @@ private void FillSyncInfo(BaseItemDto dto, BaseItem item, DtoOptions options)
}
}

private void FillSyncInfo(BaseItemDto dto, BaseItem item, IEnumerable<string> itemIdsWithSyncJobs, DtoOptions options)
private void FillSyncInfo(BaseItemDto dto, BaseItem item, IEnumerable<string> itemIdsWithSyncJobs, DtoOptions options, User user)
{
if (options.Fields.Contains(ItemFields.SyncInfo))
{
dto.SupportsSync = _syncManager.SupportsSync(item);
var userCanSync = user != null && user.Policy.EnableSync;
dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item);
}

if (dto.SupportsSync ?? false)
Expand Down Expand Up @@ -308,7 +310,7 @@ public BaseItemDto GetItemByNameDto<T>(T item, DtoOptions options, List<BaseItem
var dto = GetBaseItemDtoInternal(item, options, user);

SetItemByNameInfo(item, dto, taggedItems, user);
FillSyncInfo(dto, item, options);
FillSyncInfo(dto, item, options, user);

return dto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ private AuthorizationInfo GetAuthorization(IServiceRequest httpReq)
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;
}
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.Server.Implementations/Library/UserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public UserDto GetOfflineUserDto(User user, string deviceId)
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"HeaderSelectCertificatePath": "Select Certificate Path",
"ConfirmMessageScheduledTaskButton": "This operation normally runs automatically as a scheduled task. It can also be run manually here. To configure the scheduled task, see:",
"HeaderSupporterBenefit": "A supporter membership provides additional benefits such as access to premium plugins, internet channel content, and more. {0}Learn more{1}.",
"LabelSyncNoTargetsHelp": "It looks like you don't currently have any apps that support sync.",
"HeaderWelcomeToMediaBrowserServerDashboard": "Welcome to the Media Browser Dashboard",
"HeaderWelcomeToMediaBrowserWebClient": "Welcome to the Media Browser Web Client",
"ButtonTakeTheTour": "Take the tour",
Expand All @@ -83,6 +84,7 @@
"ButtonCancelItem": "Cancel item",
"ButtonQueueForRetry": "Queue for retry",
"ButtonReenable": "Re-enable",
"ButtonLearnMore": "Learn more",
"SyncJobItemStatusSyncedMarkForRemoval": "Marked for removal",
"LabelAbortedByServerShutdown": "(Aborted by server shutdown)",
"LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.",
Expand Down Expand Up @@ -644,6 +646,7 @@
"WebClientTourUserPreferences4": "Configure backdrops, theme songs and external players",
"WebClientTourMobile1": "The web client works great on smartphones and tablets...",
"WebClientTourMobile2": "and easily controls other devices and Media Browser apps",
"WebClientTourMySync": "Sync your personal media to your devices for offline viewing.",
"MessageEnjoyYourStay": "Enjoy your stay",
"DashboardTourDashboard": "The server dashboard allows you to monitor your server and your users. You'll always know who is doing what and where they are.",
"DashboardTourHelp": "In-app help provides easy buttons to open wiki pages relating to the on-screen content.",
Expand All @@ -655,6 +658,7 @@
"DashboardTourNotifications": "Automatically send notifications of server events to your mobile device, email and more.",
"DashboardTourScheduledTasks": "Easily manage long running operations with scheduled tasks. Decide when they run, and how often.",
"DashboardTourMobile": "The Media Browser dashboard works great on smartphones and tablets. Manage your server from the palm of your hand anytime, anywhere.",
"DashboardTourSync": "Sync your personal media to your devices for offline viewing.",
"MessageRefreshQueued": "Refresh queued",
"TabDevices": "Devices",
"TabExtras": "Extras",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"HeaderSelectCertificatePath": "Select Certificate Path",
"ConfirmMessageScheduledTaskButton": "This operation normally runs automatically as a scheduled task. It can also be run manually here. To configure the scheduled task, see:",
"HeaderSupporterBenefit": "\u041f\u0440\u0438\u0432\u044a\u0440\u0436\u0435\u043d\u0441\u043a\u043e\u0442\u043e \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u043e \u043e\u0441\u0438\u0433\u0443\u0440\u044f\u0432\u0430 \u0434\u043e\u043f\u044a\u043b\u043d\u0438\u0442\u0435\u043b\u043d\u0438 \u043e\u0431\u043b\u0430\u0433\u0438, \u043a\u0430\u0442\u043e \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u044a\u043f \u0434\u043e \u043f\u044a\u0440\u0432\u043e\u043a\u043b\u0430\u0441\u043d\u0438 \u043f\u043b\u044a\u0433\u0438\u043d\u0438, \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0441\u044a\u0434\u044a\u0440\u0436\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u0430\u043d\u0430\u043b\u0438\u0442\u0435, \u0438 \u0434\u0440\u0443\u0433\u0438. {0} \u041d\u0430\u0443\u0447\u0435\u0442\u0435 \u043f\u043e\u0432\u0435\u0447\u0435 {1}.",
"LabelSyncNoTargetsHelp": "It looks like you don't currently have any apps that support sync.",
"HeaderWelcomeToMediaBrowserServerDashboard": "\u0414\u043e\u0431\u0440\u0435 \u0434\u043e\u0448\u043b\u0438 \u0432 \u0433\u043b\u0430\u0432\u043d\u0438\u044f \u043f\u0430\u043d\u0435\u043b \u043d\u0430 Media Browser",
"HeaderWelcomeToMediaBrowserWebClient": "\u0414\u043e\u0431\u0440\u0435 \u0434\u043e\u0448\u043b\u0438 \u0432 \u0443\u0435\u0431 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 Media Browser",
"ButtonTakeTheTour": "\u0420\u0430\u0437\u0433\u043b\u0435\u0434\u0430\u0439 \u043d\u0430\u043e\u043a\u043e\u043b\u043e",
Expand All @@ -83,6 +84,7 @@
"ButtonCancelItem": "Cancel item",
"ButtonQueueForRetry": "Queue for retry",
"ButtonReenable": "Re-enable",
"ButtonLearnMore": "Learn more",
"SyncJobItemStatusSyncedMarkForRemoval": "Marked for removal",
"LabelAbortedByServerShutdown": "(Aborted by server shutdown)",
"LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.",
Expand Down Expand Up @@ -644,6 +646,7 @@
"WebClientTourUserPreferences4": "Configure backdrops, theme songs and external players",
"WebClientTourMobile1": "The web client works great on smartphones and tablets...",
"WebClientTourMobile2": "and easily controls other devices and Media Browser apps",
"WebClientTourMySync": "Sync your personal media to your devices for offline viewing.",
"MessageEnjoyYourStay": "Enjoy your stay",
"DashboardTourDashboard": "The server dashboard allows you to monitor your server and your users. You'll always know who is doing what and where they are.",
"DashboardTourHelp": "In-app help provides easy buttons to open wiki pages relating to the on-screen content.",
Expand All @@ -655,6 +658,7 @@
"DashboardTourNotifications": "Automatically send notifications of server events to your mobile device, email and more.",
"DashboardTourScheduledTasks": "Easily manage long running operations with scheduled tasks. Decide when they run, and how often.",
"DashboardTourMobile": "The Media Browser dashboard works great on smartphones and tablets. Manage your server from the palm of your hand anytime, anywhere.",
"DashboardTourSync": "Sync your personal media to your devices for offline viewing.",
"MessageRefreshQueued": "Refresh queued",
"TabDevices": "Devices",
"TabExtras": "Extras",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"HeaderSelectCertificatePath": "Select Certificate Path",
"ConfirmMessageScheduledTaskButton": "This operation normally runs automatically as a scheduled task. It can also be run manually here. To configure the scheduled task, see:",
"HeaderSupporterBenefit": "A supporter membership provides additional benefits such as access to premium plugins, internet channel content, and more. {0}Learn more{1}.",
"LabelSyncNoTargetsHelp": "It looks like you don't currently have any apps that support sync.",
"HeaderWelcomeToMediaBrowserServerDashboard": "Welcome to the Media Browser Dashboard",
"HeaderWelcomeToMediaBrowserWebClient": "Welcome to the Media Browser Web Client",
"ButtonTakeTheTour": "Take the tour",
Expand All @@ -83,6 +84,7 @@
"ButtonCancelItem": "Cancel item",
"ButtonQueueForRetry": "Queue for retry",
"ButtonReenable": "Re-enable",
"ButtonLearnMore": "Learn more",
"SyncJobItemStatusSyncedMarkForRemoval": "Marked for removal",
"LabelAbortedByServerShutdown": "(Aborted by server shutdown)",
"LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.",
Expand Down Expand Up @@ -644,6 +646,7 @@
"WebClientTourUserPreferences4": "Configure backdrops, theme songs and external players",
"WebClientTourMobile1": "The web client works great on smartphones and tablets...",
"WebClientTourMobile2": "and easily controls other devices and Media Browser apps",
"WebClientTourMySync": "Sync your personal media to your devices for offline viewing.",
"MessageEnjoyYourStay": "Enjoy your stay",
"DashboardTourDashboard": "The server dashboard allows you to monitor your server and your users. You'll always know who is doing what and where they are.",
"DashboardTourHelp": "In-app help provides easy buttons to open wiki pages relating to the on-screen content.",
Expand All @@ -655,6 +658,7 @@
"DashboardTourNotifications": "Automatically send notifications of server events to your mobile device, email and more.",
"DashboardTourScheduledTasks": "Easily manage long running operations with scheduled tasks. Decide when they run, and how often.",
"DashboardTourMobile": "The Media Browser dashboard works great on smartphones and tablets. Manage your server from the palm of your hand anytime, anywhere.",
"DashboardTourSync": "Sync your personal media to your devices for offline viewing.",
"MessageRefreshQueued": "Refresh queued",
"TabDevices": "Devices",
"TabExtras": "Extras",
Expand Down
Loading

0 comments on commit d69562f

Please sign in to comment.