diff options
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/Library/LibraryService.cs | 56 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/VideoService.cs | 1 |
3 files changed, 45 insertions, 24 deletions
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index f147234fe..a97e2b52e 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -226,6 +226,18 @@ namespace MediaBrowser.Api.Library public string TvdbId { get; set; } } + [Route("/Items/{Id}/Download", "GET", Summary = "Downloads item media")] + [Authenticated(Roles = "download")] + public class GetDownload + { + /// <summary> + /// Gets or sets the id. + /// </summary> + /// <value>The id.</value> + [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + } + /// <summary> /// Class LibraryService /// </summary> @@ -273,7 +285,7 @@ namespace MediaBrowser.Api.Library } var dtoOptions = GetDtoOptions(request); - + var result = new ItemsResult { TotalRecordCount = items.Count, @@ -289,6 +301,28 @@ namespace MediaBrowser.Api.Library Task.Run(() => _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None)); } + public object Get(GetDownload request) + { + var item = _libraryManager.GetItemById(request.Id); + + if (!item.CanDelete()) + { + throw new ArgumentException("Item does not support downloading"); + } + + var headers = new Dictionary<string, string>(); + + // Quotes are valid in linux. They'll possibly cause issues here + var filename = Path.GetFileName(item.Path).Replace("\"", string.Empty); + headers["Content-Disposition"] = string.Format("inline; filename=\"{0}\"", filename); + + return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions + { + Path = item.Path, + ResponseHeaders = headers + }); + } + public object Get(GetFile request) { var item = _libraryManager.GetItemById(request.Id); @@ -347,7 +381,7 @@ namespace MediaBrowser.Api.Library var dtoOptions = GetDtoOptions(request); BaseItem parent = item.Parent; - + while (parent != null) { if (user != null) @@ -458,23 +492,9 @@ namespace MediaBrowser.Api.Library var auth = _authContext.GetAuthorizationInfo(Request); var user = _userManager.GetUserById(auth.UserId); - if (item is Playlist || item is BoxSet) + if (!item.CanDelete(user)) { - // For now this is allowed if user can see the playlist - } - else if (item is ILiveTvRecording) - { - if (!user.Policy.EnableLiveTvManagement) - { - throw new UnauthorizedAccessException(); - } - } - else - { - if (!user.Policy.EnableContentDeletion) - { - throw new UnauthorizedAccessException(); - } + throw new UnauthorizedAccessException(); } var task = _libraryManager.DeleteItem(item); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6d555e136..d26ca2721 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -123,7 +123,7 @@ namespace MediaBrowser.Api.Playback private string GetOutputFilePath(StreamState state) { var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath; - + var outputFileExtension = GetOutputFileExtension(state); var data = GetCommandLineArguments("dummy\\dummy", "dummyTranscodingId", state, false); @@ -323,13 +323,13 @@ namespace MediaBrowser.Api.Playback switch (qualitySetting) { case EncodingQuality.HighSpeed: - param += " -crf 23"; + param += " -subq 0 -crf 23"; break; case EncodingQuality.HighQuality: - param += " -crf 20"; + param += " -subq 3 -crf 20"; break; case EncodingQuality.MaxQuality: - param += " -crf 18"; + param += " -subq 6 -crf 18"; break; } } @@ -507,7 +507,7 @@ namespace MediaBrowser.Api.Playback } } - return param; + return "-pix_fmt yuv420p " + param; } protected string GetAudioFilterParam(StreamState state, bool isHls) @@ -918,7 +918,7 @@ namespace MediaBrowser.Api.Playback if (SupportsThrottleWithStream) { var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; - + url += "&transcodingJobId=" + transcodingJobId; return string.Format("\"{0}\"", url); diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 8924bb38f..7e86b867f 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -97,6 +97,7 @@ namespace MediaBrowser.Api.Playback.Progressive if (string.Equals(Path.GetExtension(outputPath), ".mp4", StringComparison.OrdinalIgnoreCase)) { + // Comparison: https://github.com/jansmolders86/mediacenterjs/blob/master/lib/transcoding/desktop.js format = " -f mp4 -movflags frag_keyframe+empty_moov"; } |
