mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
commit
2474fd0219
@ -345,6 +345,11 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
StringHelper.ToStringCultureInvariant(startPositionTicks),
|
StringHelper.ToStringCultureInvariant(startPositionTicks),
|
||||||
subtitleProfile.Format);
|
subtitleProfile.Format);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(accessToken))
|
||||||
|
{
|
||||||
|
info.Url += "?api_key=" + accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
info.IsExternalUrl = false;
|
info.IsExternalUrl = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -288,6 +288,36 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
return Path.GetExtension(parts[0]);
|
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>
|
/// <summary>
|
||||||
/// Overridable method that can be used to implement a custom hnandler
|
/// Overridable method that can be used to implement a custom hnandler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -305,10 +335,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
var urlString = url.OriginalString;
|
var urlString = url.OriginalString;
|
||||||
var enableLog = EnableLogging(urlString, localPath);
|
var enableLog = EnableLogging(urlString, localPath);
|
||||||
|
var urlToLog = urlString;
|
||||||
|
|
||||||
if (enableLog)
|
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) ||
|
if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) ||
|
||||||
@ -390,7 +422,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
if (enableLog)
|
if (enableLog)
|
||||||
{
|
{
|
||||||
LoggerUtils.LogResponse(_logger, statusCode, urlString, remoteIp, duration);
|
LoggerUtils.LogResponse(_logger, statusCode, urlToLog, remoteIp, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, TaskContinuationOptions.None);
|
}, TaskContinuationOptions.None);
|
||||||
|
@ -498,7 +498,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
private bool IsListingProviderEnabledForTuner(ListingsProviderInfo info, string tunerHostId)
|
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)
|
private async Task<IEnumerable<ProgramInfo>> GetProgramsAsyncInternal(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
|
||||||
|
@ -142,7 +142,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
{
|
{
|
||||||
var page = ServerEntryPoint.Instance.PluginConfigurationPages.First(p => p.Name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
|
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>
|
/// <summary>
|
||||||
|
@ -60,7 +60,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
{
|
{
|
||||||
if (IsCoreHtml(path))
|
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"))
|
else if (IsFormat(path, "js"))
|
||||||
@ -238,13 +238,14 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modifies the HTML by adding common meta tags, css and js.
|
/// Modifies the HTML by adding common meta tags, css and js.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
/// <param name="sourceStream">The source stream.</param>
|
/// <param name="sourceStream">The source stream.</param>
|
||||||
/// <param name="mode">The mode.</param>
|
/// <param name="mode">The mode.</param>
|
||||||
/// <param name="appVersion">The application version.</param>
|
/// <param name="appVersion">The application version.</param>
|
||||||
/// <param name="localizationCulture">The localization culture.</param>
|
/// <param name="localizationCulture">The localization culture.</param>
|
||||||
/// <param name="enableMinification">if set to <c>true</c> [enable minification].</param>
|
/// <param name="enableMinification">if set to <c>true</c> [enable minification].</param>
|
||||||
/// <returns>Task{Stream}.</returns>
|
/// <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)
|
using (sourceStream)
|
||||||
{
|
{
|
||||||
@ -260,6 +261,12 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
{
|
{
|
||||||
html = ModifyForCordova(html);
|
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))
|
if (!string.IsNullOrWhiteSpace(localizationCulture))
|
||||||
{
|
{
|
||||||
@ -294,9 +301,6 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
_logger.ErrorException("Error minifying html", ex);
|
_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));
|
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)
|
private string ModifyForCordova(string html)
|
||||||
{
|
{
|
||||||
// Replace CORDOVA_REPLACE_SUPPORTER_SUBMIT_START
|
// Replace CORDOVA_REPLACE_SUPPORTER_SUBMIT_START
|
||||||
|
@ -140,9 +140,15 @@
|
|||||||
<Content Include="dashboard-ui\components\remotecontrolautoplay.js">
|
<Content Include="dashboard-ui\components\remotecontrolautoplay.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\components\viewcontainer-lite.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\devices\windowsphone\wp.css">
|
<Content Include="dashboard-ui\devices\windowsphone\wp.css">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\home.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\legacy\fnchecked.js">
|
<Content Include="dashboard-ui\legacy\fnchecked.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user