aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs35
-rw-r--r--MediaBrowser.Api/Social/SharingService.cs32
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs7
-rw-r--r--MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj5
4 files changed, 59 insertions, 20 deletions
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index ab57e561f..0a432a580 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.Hls
CancellationToken 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 done
if (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.Hls
builder.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 stream
var playlistUrl = isLiveStream ? "live.m3u8" : "main.m3u8";
playlistUrl += queryString;
@@ -798,7 +803,7 @@ namespace MediaBrowser.Api.Playback.Hls
var 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.cs
index 93540f8ca..608008455 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.Social
public 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.Social
return 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.cs
index 9461143a8..80892b96c 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.csproj
index a9a4c0647..21ca33339 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">