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;
+ }
+
///
/// Overridable method that can be used to implement a custom hnandler
///
@@ -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> 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));
}
///
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
///
/// Modifies the HTML by adding common meta tags, css and js.
///
+ /// The path.
/// The source stream.
/// The mode.
/// The application version.
/// The localization culture.
/// if set to true [enable minification].
/// Task{Stream}.
- public async Task ModifyHtml(Stream sourceStream, string mode, string appVersion, string localizationCulture, bool enableMinification)
+ public async Task 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 + "
");
+ }
if (!string.IsNullOrWhiteSpace(localizationCulture))
{
@@ -294,9 +301,6 @@ namespace MediaBrowser.WebDashboard.Api
_logger.ErrorException("Error minifying html", ex);
}
}
-
- html = html.Replace("", "");
}
html = html.Replace("", "" + 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 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest