From f8927ceb067365d89406263ec1ca9084eb10b8e0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 1 Apr 2015 22:47:59 -0400 Subject: [PATCH] resolve reverse proxy issue --- MediaBrowser.Api/BaseApiService.cs | 11 ----------- MediaBrowser.Api/Playback/MediaInfoService.cs | 17 ++++++++--------- MediaBrowser.Model/Dlna/StreamInfo.cs | 3 +++ MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs | 1 + MediaBrowser.Model/Entities/MediaStream.cs | 7 ++++++- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 3364c3c6be..4465be97a2 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -73,17 +73,6 @@ namespace MediaBrowser.Api return ResultFactory.GetOptimizedResultUsingCache(Request, cacheKey, lastDateModified, cacheDuration, factoryFn); } - /// - /// Infers the server address from the url - /// - /// - protected string GetServerAddress() - { - var index = Request.AbsoluteUri.IndexOf(Request.PathInfo, StringComparison.OrdinalIgnoreCase); - - return Request.AbsoluteUri.Substring(0, index); - } - protected void AssertCanUpdateUser(IUserManager userManager, string userId) { var auth = AuthorizationContext.GetAuthorizationInfo(Request); diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 46a1ff7890..24c9d637ad 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -225,8 +225,6 @@ namespace MediaBrowser.Api.Playback { var streamBuilder = new StreamBuilder(); - var baseUrl = GetServerAddress(); - var options = new VideoOptions { MediaSources = new List { mediaSource }, @@ -266,7 +264,7 @@ namespace MediaBrowser.Api.Playback if (streamInfo != null) { - SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, baseUrl, auth.Token); + SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token); } } @@ -284,7 +282,7 @@ namespace MediaBrowser.Api.Playback if (streamInfo != null) { - SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, baseUrl, auth.Token); + SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token); } } @@ -298,22 +296,22 @@ namespace MediaBrowser.Api.Playback if (streamInfo != null) { streamInfo.PlaySessionId = playSessionId; - SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, baseUrl, auth.Token); + SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token); } if (streamInfo != null && streamInfo.PlayMethod == PlayMethod.Transcode) { streamInfo.StartPositionTicks = startTimeTicks; - mediaSource.TranscodingUrl = streamInfo.ToUrl(baseUrl, auth.Token); + mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-').TrimStart('-'); mediaSource.TranscodingContainer = streamInfo.Container; mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol; } } } - private void SetDeviceSpecificSubtitleInfo(StreamInfo info, MediaSourceInfo mediaSource, string baseUrl, string accessToken) + private void SetDeviceSpecificSubtitleInfo(StreamInfo info, MediaSourceInfo mediaSource, string accessToken) { - var profiles = info.GetSubtitleProfiles(false, baseUrl, accessToken); + var profiles = info.GetSubtitleProfiles(false, "-", accessToken); mediaSource.DefaultSubtitleStreamIndex = info.SubtitleStreamIndex; foreach (var profile in profiles) @@ -326,7 +324,8 @@ namespace MediaBrowser.Api.Playback if (profile.DeliveryMethod == SubtitleDeliveryMethod.External) { - stream.DeliveryUrl = profile.Url; + stream.DeliveryUrl = profile.Url.TrimStart('-').TrimStart('-'); + stream.IsExternalUrl = profile.IsExternalUrl; } } } diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index a2f5fcb104..a57bc0c0ef 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -321,10 +321,13 @@ namespace MediaBrowser.Model.Dlna StringHelper.ToStringCultureInvariant(stream.Index), StringHelper.ToStringCultureInvariant(startPositionTicks), subtitleProfile.Format); + + info.IsExternalUrl = false; } else { info.Url = stream.Path; + info.IsExternalUrl = true; } } diff --git a/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs b/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs index 602858ccc9..61b2895fc1 100644 --- a/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs +++ b/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs @@ -9,5 +9,6 @@ namespace MediaBrowser.Model.Dlna public string Format { get; set; } public int Index { get; set; } public SubtitleDeliveryMethod DeliveryMethod { get; set; } + public bool IsExternalUrl { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index dfeed7450b..0f3435174c 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -135,7 +135,7 @@ namespace MediaBrowser.Model.Entities /// /// The score. public int? Score { get; set; } - + /// /// Gets or sets a value indicating whether this instance is external. /// @@ -152,6 +152,11 @@ namespace MediaBrowser.Model.Entities /// /// The delivery URL. public string DeliveryUrl { get; set; } + /// + /// Gets or sets a value indicating whether this instance is external URL. + /// + /// null if [is external URL] contains no value, true if [is external URL]; otherwise, false. + public bool? IsExternalUrl { get; set; } public bool IsTextSubtitleStream {