update shared item page

This commit is contained in:
Luke Pulverenti 2015-07-03 07:51:45 -04:00
parent 922b477f77
commit d6aea7d9b4
4 changed files with 59 additions and 20 deletions

View File

@ -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));

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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">