The Free Software Media System - Server Backend & API
update shared item page
Luke Pulverentid6aea7d9b41c
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.csindex ab57e561f5..0a432a5802 100644--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs@@ -313,16 +313,17 @@ namespace MediaBrowser.Api.Playback.Hls{var segmentPath = GetSegmentPath(state, playlist, i);- double length;- if (SegmentLengths.TryGetValue(Path.GetFileName(segmentPath), out length))- {- Logger.Debug("Found segment length of {0} for index {1}", length, i);- startSeconds += length;- }- else- {- startSeconds += state.SegmentLength;- }+ //double length;+ //if (SegmentLengths.TryGetValue(Path.GetFileName(segmentPath), out length))+ //{+ // Logger.Debug("Found segment length of {0} for index {1}", length, i);+ // startSeconds += length;+ //}+ //else+ //{+ // startSeconds += state.SegmentLength;+ //}+ startSeconds += state.SegmentLength;}var position = TimeSpan.FromSeconds(startSeconds).Ticks;@@ -441,7 +442,7 @@ namespace MediaBrowser.Api.Playback.HlsCancellationToken cancellationToken){// If all transcoding has completed, just return immediately- if (transcodingJob != null && transcodingJob.HasExited)+ if (transcodingJob != null && transcodingJob.HasExited && File.Exists(segmentPath)){return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob);}@@ -463,7 +464,11 @@ namespace MediaBrowser.Api.Playback.Hls// If it appears in the playlist, it's doneif (text.IndexOf(segmentFilename, StringComparison.OrdinalIgnoreCase) != -1){- return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob);+ if (File.Exists(segmentPath))+ {+ return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob);+ }+ break;}}}@@ -564,11 +569,11 @@ namespace MediaBrowser.Api.Playback.Hlsbuilder.AppendLine("#EXTM3U");+ var isLiveStream = (state.RunTimeTicks ?? 0) == 0;+var queryStringIndex = Request.RawUrl.IndexOf('?');var queryString = queryStringIndex == -1 ? string.Empty : Request.RawUrl.Substring(queryStringIndex);- var isLiveStream = (state.RunTimeTicks ?? 0) == 0;-// Main streamvar playlistUrl = isLiveStream ? "live.m3u8" : "main.m3u8";playlistUrl += queryString;@@ -798,7 +803,7 @@ namespace MediaBrowser.Api.Playback.Hlsvar audioTranscodeParams = new List<string>();audioTranscodeParams.Add("-acodec " + codec);-+if (state.OutputAudioBitrate.HasValue){audioTranscodeParams.Add("-ab " + state.OutputAudioBitrate.Value.ToString(UsCulture));diff --git a/MediaBrowser.Api/Social/SharingService.cs b/MediaBrowser.Api/Social/SharingService.csindex 93540f8ca0..608008455d 100644--- a/MediaBrowser.Api/Social/SharingService.cs+++ b/MediaBrowser.Api/Social/SharingService.cs@@ -1,5 +1,6 @@using MediaBrowser.Common.Extensions;using MediaBrowser.Controller.Dlna;+using MediaBrowser.Controller.Dto;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Net;using MediaBrowser.Controller.Social;@@ -53,17 +54,26 @@ namespace MediaBrowser.Api.Socialpublic string Id { get; set; }}+ [Route("/Social/Shares/Public/{Id}/Item", "GET", Summary = "Gets a share")]+ public class GetSharedLibraryItem+ {+ [ApiMember(Name = "Id", Description = "The id of the item", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]+ public string Id { get; set; }+ }+public class SharingService : BaseApiService{private readonly ISharingManager _sharingManager;private readonly ILibraryManager _libraryManager;private readonly IDlnaManager _dlnaManager;+ private readonly IDtoService _dtoService;- public SharingService(ISharingManager sharingManager, IDlnaManager dlnaManager, ILibraryManager libraryManager)+ public SharingService(ISharingManager sharingManager, IDlnaManager dlnaManager, ILibraryManager libraryManager, IDtoService dtoService){_sharingManager = sharingManager;_dlnaManager = dlnaManager;_libraryManager = libraryManager;+ _dtoService = dtoService;}public object Get(GetSocialShareInfo request)@@ -73,11 +83,27 @@ namespace MediaBrowser.Api.Socialreturn ToOptimizedResult(info);}+ public object Get(GetSharedLibraryItem request)+ {+ var info = _sharingManager.GetShareInfo(request.Id);++ if (info.ExpirationDate <= DateTime.UtcNow)+ {+ throw new ResourceNotFoundException();+ }++ var item = _libraryManager.GetItemById(info.ItemId);++ var dto = _dtoService.GetBaseItemDto(item, new DtoOptions());++ return ToOptimizedResult(dto);+ }+public object Get(GetPublicSocialShareInfo request){var info = _sharingManager.GetShareInfo(request.Id);- if (info.ExpirationDate >= DateTime.UtcNow)+ if (info.ExpirationDate <= DateTime.UtcNow){throw new ResourceNotFoundException();}@@ -106,7 +132,7 @@ namespace MediaBrowser.Api.Social{throw new ResourceNotFoundException();}- if (share.ExpirationDate >= DateTime.UtcNow)+ if (share.ExpirationDate <= DateTime.UtcNow){throw new ResourceNotFoundException();}diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.csindex 9461143a8e..80892b96c2 100644--- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs@@ -170,7 +170,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security/// <returns>Dictionary{System.StringSystem.String}.</returns>private Dictionary<string, string> GetAuthorizationDictionary(IServiceRequest httpReq){- var auth = httpReq.Headers["Authorization"];+ var auth = httpReq.Headers["X-Emby-Authorization"];++ if (string.IsNullOrWhiteSpace(auth))+ {+ auth = httpReq.Headers["Authorization"];+ }return GetAuthorization(auth);}diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csprojindex a9a4c06472..21ca33339f 100644--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj@@ -187,13 +187,16 @@<Content Include="dashboard-ui\scripts\homeupcoming.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>+ <Content Include="dashboard-ui\scripts\shared.js">+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>+ </Content><Content Include="dashboard-ui\scripts\sharingmanager.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content><Content Include="dashboard-ui\scripts\sharingwidget.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>- <Content Include="dashboard-ui\share.html">+ <Content Include="dashboard-ui\shared.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content><Content Include="dashboard-ui\themes\android.css">