diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-03-16 14:19:51 -0400 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-03-16 14:19:51 -0400 |
| commit | 2474fd0219fbca63145951dc10a871a6581a6079 (patch) | |
| tree | f98deecb51a2b890b93dd67d7feefe02c0ec37e8 | |
| parent | 40c1cf8310adabfec88433a21ab8c13de7c2a82a (diff) | |
| parent | fee7cbdc4adc99dc256e2c46a89931c14cdf0f43 (diff) | |
Merge pull request #1550 from MediaBrowser/dev
Dev
6 files changed, 76 insertions, 9 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 69733cefbc..9118efb35c 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -345,6 +345,11 @@ namespace MediaBrowser.Model.Dlna StringHelper.ToStringCultureInvariant(startPositionTicks), subtitleProfile.Format); + if (!string.IsNullOrEmpty(accessToken)) + { + info.Url += "?api_key=" + accessToken; + } + info.IsExternalUrl = false; } else diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index c284007f7c..93bfcbbab3 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -288,6 +288,36 @@ namespace MediaBrowser.Server.Implementations.HttpServer return Path.GetExtension(parts[0]); } + public static string RemoveQueryStringByKey(string url, string key) + { + var uri = new Uri(url); + + // this gets all the query string key value pairs as a collection + var newQueryString = MyHttpUtility.ParseQueryString(uri.Query); + + if (newQueryString.Count == 0) + { + return url; + } + + // this removes the key if exists + newQueryString.Remove(key); + + // this gets the page path from root without QueryString + string pagePathWithoutQueryString = uri.GetLeftPart(UriPartial.Path); + + return newQueryString.Count > 0 + ? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString) + : pagePathWithoutQueryString; + } + + private string GetUrlToLog(string url) + { + url = RemoveQueryStringByKey(url, "api_key"); + + return url; + } + /// <summary> /// Overridable method that can be used to implement a custom hnandler /// </summary> @@ -305,10 +335,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer var urlString = url.OriginalString; var enableLog = EnableLogging(urlString, localPath); + var urlToLog = urlString; if (enableLog) { - LoggerUtils.LogRequest(_logger, urlString, httpReq.HttpMethod, httpReq.UserAgent); + urlToLog = GetUrlToLog(urlString); + LoggerUtils.LogRequest(_logger, urlToLog, httpReq.HttpMethod, httpReq.UserAgent); } if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) || @@ -390,7 +422,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (enableLog) { - LoggerUtils.LogResponse(_logger, statusCode, urlString, remoteIp, duration); + LoggerUtils.LogResponse(_logger, statusCode, urlToLog, remoteIp, duration); } }, TaskContinuationOptions.None); diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index e00a68e32b..463e91fd4c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -498,7 +498,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV private bool IsListingProviderEnabledForTuner(ListingsProviderInfo info, string tunerHostId) { - return info.EnableAllTuners || info.EnabledTuners.Contains(tunerHostId ?? string.Empty, StringComparer.OrdinalIgnoreCase); + if (info.EnableAllTuners) + { + return true; + } + + if (string.IsNullOrWhiteSpace(tunerHostId)) + { + throw new ArgumentNullException("tunerHostId"); + } + + return info.EnabledTuners.Contains(tunerHostId, StringComparer.OrdinalIgnoreCase); } private async Task<IEnumerable<ProgramInfo>> GetProgramsAsyncInternal(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 128060bb82..a5bfebea98 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -142,7 +142,7 @@ namespace MediaBrowser.WebDashboard.Api { var page = ServerEntryPoint.Instance.PluginConfigurationPages.First(p => p.Name.Equals(request.Name, StringComparison.OrdinalIgnoreCase)); - return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml(page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false)); + return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml(null, page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false)); } /// <summary> diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 982edb5f72..55f6ca7a43 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -60,7 +60,7 @@ namespace MediaBrowser.WebDashboard.Api { if (IsCoreHtml(path)) { - resourceStream = await ModifyHtml(resourceStream, mode, appVersion, localizationCulture, enableMinification).ConfigureAwait(false); + resourceStream = await ModifyHtml(path, resourceStream, mode, appVersion, localizationCulture, enableMinification).ConfigureAwait(false); } } else if (IsFormat(path, "js")) @@ -238,13 +238,14 @@ namespace MediaBrowser.WebDashboard.Api /// <summary> /// Modifies the HTML by adding common meta tags, css and js. /// </summary> + /// <param name="path">The path.</param> /// <param name="sourceStream">The source stream.</param> /// <param name="mode">The mode.</param> /// <param name="appVersion">The application version.</param> /// <param name="localizationCulture">The localization culture.</param> /// <param name="enableMinification">if set to <c>true</c> [enable minification].</param> /// <returns>Task{Stream}.</returns> - public async Task<Stream> ModifyHtml(Stream sourceStream, string mode, string appVersion, string localizationCulture, bool enableMinification) + public async Task<Stream> ModifyHtml(string path, Stream sourceStream, string mode, string appVersion, string localizationCulture, bool enableMinification) { using (sourceStream) { @@ -260,6 +261,12 @@ namespace MediaBrowser.WebDashboard.Api { html = ModifyForCordova(html); } + else if (!string.IsNullOrWhiteSpace(path) && !string.Equals(path, "index.html", StringComparison.OrdinalIgnoreCase) && html.IndexOf("<html", StringComparison.OrdinalIgnoreCase) == -1) + { + var indexFile = File.ReadAllText(GetDashboardResourcePath("index.html")); + + html = ReplaceFirst(indexFile, "<div class=\"mainAnimatedPage hide\"></div>", "<div class=\"mainAnimatedPage hide\">" + html + "</div>"); + } if (!string.IsNullOrWhiteSpace(localizationCulture)) { @@ -294,9 +301,6 @@ namespace MediaBrowser.WebDashboard.Api _logger.ErrorException("Error minifying html", ex); } } - - html = html.Replace("<body>", "<body><paper-drawer-panel class=\"mainDrawerPanel mainDrawerPanelPreInit skinContainer\" forceNarrow><div class=\"mainDrawer\" drawer></div><div class=\"mainDrawerPanelContent\" main><!--<div class=\"pageBackground\"></div><div class=\"pageContainer\">") - .Replace("</body>", "</div>--></div></paper-drawer-panel></body>"); } html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, appVersion)); @@ -309,6 +313,16 @@ namespace MediaBrowser.WebDashboard.Api } } + public string ReplaceFirst(string text, string search, string replace) + { + int pos = text.IndexOf(search, StringComparison.OrdinalIgnoreCase); + if (pos < 0) + { + return text; + } + return text.Substring(0, pos) + replace + text.Substring(pos + search.Length); + } + private string ModifyForCordova(string html) { // Replace CORDOVA_REPLACE_SUPPORTER_SUBMIT_START diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index fb52b58b75..4d167c4375 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -140,9 +140,15 @@ <Content Include="dashboard-ui\components\remotecontrolautoplay.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\components\viewcontainer-lite.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\devices\windowsphone\wp.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\home.html">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\legacy\fnchecked.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
|
