Merge pull request #2614 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-05-05 14:00:51 -04:00 committed by GitHub
commit b0dd8c1b75
23 changed files with 64 additions and 90 deletions

View File

@ -254,7 +254,6 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "TypedBaseItems", "SeasonName", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "SeasonName", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "SeasonId", "GUID", existingColumnNames); AddColumn(db, "TypedBaseItems", "SeasonId", "GUID", existingColumnNames);
AddColumn(db, "TypedBaseItems", "SeriesId", "GUID", existingColumnNames); AddColumn(db, "TypedBaseItems", "SeriesId", "GUID", existingColumnNames);
AddColumn(db, "TypedBaseItems", "SeriesSortName", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "ExternalSeriesId", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "ExternalSeriesId", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "Tagline", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "Tagline", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "Keywords", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "Keywords", "Text", existingColumnNames);
@ -458,7 +457,6 @@ namespace Emby.Server.Implementations.Data
"SeasonName", "SeasonName",
"SeasonId", "SeasonId",
"SeriesId", "SeriesId",
"SeriesSortName",
"PresentationUniqueKey", "PresentationUniqueKey",
"InheritedParentalRatingValue", "InheritedParentalRatingValue",
"InheritedTags", "InheritedTags",
@ -591,7 +589,6 @@ namespace Emby.Server.Implementations.Data
"SeasonName", "SeasonName",
"SeasonId", "SeasonId",
"SeriesId", "SeriesId",
"SeriesSortName",
"ExternalSeriesId", "ExternalSeriesId",
"Tagline", "Tagline",
"Keywords", "Keywords",
@ -1020,13 +1017,11 @@ namespace Emby.Server.Implementations.Data
if (hasSeries != null) if (hasSeries != null)
{ {
saveItemStatement.TryBind("@SeriesId", hasSeries.SeriesId); saveItemStatement.TryBind("@SeriesId", hasSeries.SeriesId);
saveItemStatement.TryBind("@SeriesSortName", hasSeries.SeriesSortName);
saveItemStatement.TryBind("@SeriesPresentationUniqueKey", hasSeries.SeriesPresentationUniqueKey); saveItemStatement.TryBind("@SeriesPresentationUniqueKey", hasSeries.SeriesPresentationUniqueKey);
} }
else else
{ {
saveItemStatement.TryBindNull("@SeriesId"); saveItemStatement.TryBindNull("@SeriesId");
saveItemStatement.TryBindNull("@SeriesSortName");
saveItemStatement.TryBindNull("@SeriesPresentationUniqueKey"); saveItemStatement.TryBindNull("@SeriesPresentationUniqueKey");
} }
@ -1843,15 +1838,6 @@ namespace Emby.Server.Implementations.Data
} }
index++; index++;
if (hasSeries != null)
{
if (!reader.IsDBNull(index))
{
hasSeries.SeriesSortName = reader.GetString(index);
}
}
index++;
if (!reader.IsDBNull(index)) if (!reader.IsDBNull(index))
{ {
item.PresentationUniqueKey = reader.GetString(index); item.PresentationUniqueKey = reader.GetString(index);
@ -2880,6 +2866,10 @@ namespace Emby.Server.Implementations.Data
{ {
return new Tuple<string, bool>("(Select MAX(LastPlayedDate) from TypedBaseItems B" + GetJoinUserDataText(query) + " where Played=1 and B.SeriesPresentationUniqueKey=A.PresentationUniqueKey)", false); return new Tuple<string, bool>("(Select MAX(LastPlayedDate) from TypedBaseItems B" + GetJoinUserDataText(query) + " where Played=1 and B.SeriesPresentationUniqueKey=A.PresentationUniqueKey)", false);
} }
if (string.Equals(name, ItemSortBy.SeriesSortName, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("(Select SortName from TypedBaseItems where B.Guid=A.SeriesId)", false);
}
return new Tuple<string, bool>(name, false); return new Tuple<string, bool>(name, false);
} }

View File

@ -58,6 +58,7 @@ namespace Emby.Server.Implementations.HttpServer
Headers["Content-Type"] = contentType; Headers["Content-Type"] = contentType;
TotalContentLength = fileSystem.GetFileInfo(path).Length; TotalContentLength = fileSystem.GetFileInfo(path).Length;
Headers["Accept-Ranges"] = "bytes";
if (string.IsNullOrWhiteSpace(rangeHeader)) if (string.IsNullOrWhiteSpace(rangeHeader))
{ {
@ -66,7 +67,6 @@ namespace Emby.Server.Implementations.HttpServer
} }
else else
{ {
Headers["Accept-Ranges"] = "bytes";
StatusCode = HttpStatusCode.PartialContent; StatusCode = HttpStatusCode.PartialContent;
SetRangeValues(); SetRangeValues();
} }
@ -96,8 +96,12 @@ namespace Emby.Server.Implementations.HttpServer
RangeLength = 1 + RangeEnd - RangeStart; RangeLength = 1 + RangeEnd - RangeStart;
// Content-Length is the length of what we're serving, not the original content // Content-Length is the length of what we're serving, not the original content
Headers["Content-Length"] = RangeLength.ToString(UsCulture); var lengthString = RangeLength.ToString(UsCulture);
Headers["Content-Range"] = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength); Headers["Content-Length"] = lengthString;
var rangeString = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);
Headers["Content-Range"] = rangeString;
Logger.Info("Setting range response values for {0}. RangeRequest: {1} Content-Length: {2}, Content-Range: {3}", Path, RangeHeader, lengthString, rangeString);
} }
/// <summary> /// <summary>

View File

@ -501,7 +501,7 @@ namespace Emby.Server.Implementations.HttpServer
private bool ShouldCompressResponse(IRequest requestContext, string contentType) private bool ShouldCompressResponse(IRequest requestContext, string contentType)
{ {
// It will take some work to support compression with byte range requests // It will take some work to support compression with byte range requests
if (!string.IsNullOrEmpty(requestContext.Headers.Get("Range"))) if (!string.IsNullOrWhiteSpace(requestContext.Headers.Get("Range")))
{ {
return false; return false;
} }
@ -566,7 +566,7 @@ namespace Emby.Server.Implementations.HttpServer
}; };
} }
if (!string.IsNullOrEmpty(rangeHeader)) if (!string.IsNullOrWhiteSpace(rangeHeader))
{ {
var stream = await factoryFn().ConfigureAwait(false); var stream = await factoryFn().ConfigureAwait(false);
@ -621,6 +621,7 @@ namespace Emby.Server.Implementations.HttpServer
responseHeaders["Content-Encoding"] = requestedCompressionType; responseHeaders["Content-Encoding"] = requestedCompressionType;
} }
responseHeaders["Vary"] = "Accept-Encoding";
responseHeaders["Content-Length"] = content.Length.ToString(UsCulture); responseHeaders["Content-Length"] = content.Length.ToString(UsCulture);
if (isHeadRequest) if (isHeadRequest)

View File

@ -189,10 +189,15 @@ namespace Emby.Server.Implementations.HttpServer
private async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength) private async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength)
{ {
var array = new byte[BufferSize]; var array = new byte[BufferSize];
int count; int bytesRead;
while ((count = await source.ReadAsync(array, 0, array.Length).ConfigureAwait(false)) != 0) while ((bytesRead = await source.ReadAsync(array, 0, array.Length).ConfigureAwait(false)) != 0)
{ {
var bytesToCopy = Math.Min(count, copyLength); if (bytesRead == 0)
{
break;
}
var bytesToCopy = Math.Min(bytesRead, copyLength);
await destination.WriteAsync(array, 0, Convert.ToInt32(bytesToCopy)).ConfigureAwait(false); await destination.WriteAsync(array, 0, Convert.ToInt32(bytesToCopy)).ConfigureAwait(false);

View File

@ -26,8 +26,8 @@ namespace Emby.Server.Implementations.HttpServer
public void FilterResponse(IRequest req, IResponse res, object dto) public void FilterResponse(IRequest req, IResponse res, object dto)
{ {
// Try to prevent compatibility view // Try to prevent compatibility view
res.AddHeader("X-UA-Compatible", "IE=Edge"); //res.AddHeader("X-UA-Compatible", "IE=Edge");
res.AddHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, Range, X-MediaBrowser-Token, X-Emby-Authorization"); res.AddHeader("Access-Control-Allow-Headers", "Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, Content-Type, Date, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, X-MediaBrowser-Token, X-Emby-Authorization");
res.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS"); res.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
res.AddHeader("Access-Control-Allow-Origin", "*"); res.AddHeader("Access-Control-Allow-Origin", "*");
@ -46,8 +46,6 @@ namespace Emby.Server.Implementations.HttpServer
} }
} }
var vary = "Accept-Encoding";
var hasHeaders = dto as IHasHeaders; var hasHeaders = dto as IHasHeaders;
var sharpResponse = res as WebSocketSharpResponse; var sharpResponse = res as WebSocketSharpResponse;
@ -86,23 +84,9 @@ namespace Emby.Server.Implementations.HttpServer
} }
} }
} }
string hasHeadersVary;
if (hasHeaders.Headers.TryGetValue("Vary", out hasHeadersVary))
{
vary = hasHeadersVary;
}
hasHeaders.Headers["Vary"] = vary;
} }
//res.KeepAlive = false; //res.KeepAlive = false;
// Per Google PageSpeed
// This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed.
// The correct version of the resource is delivered based on the client request header.
// This is a good choice for applications that are singly homed and depend on public proxies for user locality.
res.AddHeader("Vary", vary);
} }
/// <summary> /// <summary>

View File

@ -57,7 +57,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{ {
episode.SeriesId = series.Id; episode.SeriesId = series.Id;
episode.SeriesName = series.Name; episode.SeriesName = series.Name;
episode.SeriesSortName = series.SortName;
} }
if (season != null) if (season != null)
{ {

View File

@ -44,7 +44,6 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{ {
IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(args.Path, true, true).SeasonNumber, IndexNumber = new SeasonPathParser(namingOptions, new RegexProvider()).Parse(args.Path, true, true).SeasonNumber,
SeriesId = series.Id, SeriesId = series.Id,
SeriesSortName = series.SortName,
SeriesName = series.Name SeriesName = series.Name
}; };

View File

@ -101,6 +101,12 @@ namespace Emby.Server.Implementations.Security
/// <returns></returns> /// <returns></returns>
public async Task LoadAllRegistrationInfo() public async Task LoadAllRegistrationInfo()
{ {
var response = await _httpClient.GetResponse(new HttpRequestOptions
{
Url = "http://192.168.1.2:8096/emby/Videos/663c8a38ccfe91af6566852f78e62c26/stream.mkv?Static=true&mediaSourceId=663c8a38ccfe91af6566852f78e62c26&deviceId=hyJA92oXn4RExFTGismCnY6da91kwnTvv8YvsYf0E&Tag=bcdc02b1cdd6f1eb4a57a6812831617b"
}).ConfigureAwait(false);
var tasks = new List<Task>(); var tasks = new List<Task>();
ResetSupporterInfo(); ResetSupporterInfo();

View File

@ -129,7 +129,7 @@ namespace Emby.Server.Implementations.Session
public Task SendLibraryUpdateInfo(LibraryUpdateInfo info, CancellationToken cancellationToken) public Task SendLibraryUpdateInfo(LibraryUpdateInfo info, CancellationToken cancellationToken)
{ {
return Task.FromResult(true); return SendMessage("LibraryChanged", info, cancellationToken);
} }
public Task SendRestartRequiredNotification(SystemInfo info, CancellationToken cancellationToken) public Task SendRestartRequiredNotification(SystemInfo info, CancellationToken cancellationToken)

View File

@ -22,7 +22,7 @@ namespace Emby.Server.Implementations.Sorting
{ {
var hasSeries = item as IHasSeries; var hasSeries = item as IHasSeries;
return hasSeries != null ? hasSeries.SeriesSortName : null; return hasSeries != null ? hasSeries.FindSeriesSortName() : null;
} }
/// <summary> /// <summary>

View File

@ -675,7 +675,8 @@ namespace MediaBrowser.Api.Playback
{ {
Request = request, Request = request,
RequestedUrl = url, RequestedUrl = url,
UserAgent = Request.UserAgent UserAgent = Request.UserAgent,
EnableDlnaHeaders = !string.IsNullOrWhiteSpace(request.Params)
}; };
var auth = AuthorizationContext.GetAuthorizationInfo(Request); var auth = AuthorizationContext.GetAuthorizationInfo(Request);
@ -917,6 +918,11 @@ namespace MediaBrowser.Api.Playback
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected void AddDlnaHeaders(StreamState state, IDictionary<string, string> responseHeaders, bool isStaticallyStreamed) protected void AddDlnaHeaders(StreamState state, IDictionary<string, string> responseHeaders, bool isStaticallyStreamed)
{ {
if (!state.EnableDlnaHeaders)
{
return;
}
var profile = state.DeviceProfile; var profile = state.DeviceProfile;
var transferMode = GetHeader("transferMode.dlna.org"); var transferMode = GetHeader("transferMode.dlna.org");

View File

@ -138,6 +138,8 @@ namespace MediaBrowser.Api.Playback
return MimeTypes.GetMimeType(outputPath); return MimeTypes.GetMimeType(outputPath);
} }
public bool EnableDlnaHeaders { get; set; }
public void Dispose() public void Dispose()
{ {
DisposeTranscodingThrottler(); DisposeTranscodingThrottler();

View File

@ -31,12 +31,10 @@ namespace MediaBrowser.Controller.Entities
public string SeriesName { get; set; } public string SeriesName { get; set; }
[IgnoreDataMember] [IgnoreDataMember]
public Guid? SeriesId { get; set; } public Guid? SeriesId { get; set; }
[IgnoreDataMember]
public string SeriesSortName { get; set; }
public string FindSeriesSortName() public string FindSeriesSortName()
{ {
return SeriesSortName; return SeriesName;
} }
public string FindSeriesName() public string FindSeriesName()
{ {

View File

@ -24,12 +24,10 @@ namespace MediaBrowser.Controller.Entities
public string SeriesName { get; set; } public string SeriesName { get; set; }
[IgnoreDataMember] [IgnoreDataMember]
public Guid? SeriesId { get; set; } public Guid? SeriesId { get; set; }
[IgnoreDataMember]
public string SeriesSortName { get; set; }
public string FindSeriesSortName() public string FindSeriesSortName()
{ {
return SeriesSortName; return SeriesName;
} }
public string FindSeriesName() public string FindSeriesName()
{ {

View File

@ -11,7 +11,6 @@ namespace MediaBrowser.Controller.Entities
/// <value>The name of the series.</value> /// <value>The name of the series.</value>
string SeriesName { get; set; } string SeriesName { get; set; }
string FindSeriesName(); string FindSeriesName();
string SeriesSortName { get; set; }
string FindSeriesSortName(); string FindSeriesSortName();
Guid? SeriesId { get; set; } Guid? SeriesId { get; set; }
Guid? FindSeriesId(); Guid? FindSeriesId();

View File

@ -57,13 +57,10 @@ namespace MediaBrowser.Controller.Entities.TV
/// <value>The index number.</value> /// <value>The index number.</value>
public int? IndexNumberEnd { get; set; } public int? IndexNumberEnd { get; set; }
[IgnoreDataMember]
public string SeriesSortName { get; set; }
public string FindSeriesSortName() public string FindSeriesSortName()
{ {
var series = Series; var series = Series;
return series == null ? SeriesSortName : series.SortName; return series == null ? SeriesName : series.SortName;
} }
[IgnoreDataMember] [IgnoreDataMember]

View File

@ -51,9 +51,6 @@ namespace MediaBrowser.Controller.Entities.TV
get { return SeriesId; } get { return SeriesId; }
} }
[IgnoreDataMember]
public string SeriesSortName { get; set; }
public override double? GetDefaultPrimaryImageAspectRatio() public override double? GetDefaultPrimaryImageAspectRatio()
{ {
double value = 2; double value = 2;
@ -65,7 +62,7 @@ namespace MediaBrowser.Controller.Entities.TV
public string FindSeriesSortName() public string FindSeriesSortName()
{ {
var series = Series; var series = Series;
return series == null ? SeriesSortName : series.SortName; return series == null ? SeriesName : series.SortName;
} }
// Genre, Rating and Stuido will all be the same // Genre, Rating and Stuido will all be the same

View File

@ -125,8 +125,7 @@ namespace MediaBrowser.Providers.TV
Id = _libraryManager.GetNewItemId((series.Id + (seasonNumber ?? -1).ToString(_usCulture) + seasonName), typeof(Season)), Id = _libraryManager.GetNewItemId((series.Id + (seasonNumber ?? -1).ToString(_usCulture) + seasonName), typeof(Season)),
IsVirtualItem = isVirtualItem, IsVirtualItem = isVirtualItem,
SeriesId = series.Id, SeriesId = series.Id,
SeriesName = series.Name, SeriesName = series.Name
SeriesSortName = series.SortName
}; };
season.SetParent(series); season.SetParent(series);

View File

@ -27,13 +27,6 @@ namespace MediaBrowser.Providers.TV
updateType |= ItemUpdateType.MetadataImport; updateType |= ItemUpdateType.MetadataImport;
} }
var seriesSortName = item.FindSeriesSortName();
if (!string.Equals(item.SeriesSortName, seriesSortName, StringComparison.Ordinal))
{
item.SeriesSortName = seriesSortName;
updateType |= ItemUpdateType.MetadataImport;
}
var seasonName = item.FindSeasonName(); var seasonName = item.FindSeasonName();
if (!string.Equals(item.SeasonName, seasonName, StringComparison.Ordinal)) if (!string.Equals(item.SeasonName, seasonName, StringComparison.Ordinal))
{ {

View File

@ -44,13 +44,6 @@ namespace MediaBrowser.Providers.TV
updateType |= ItemUpdateType.MetadataImport; updateType |= ItemUpdateType.MetadataImport;
} }
var seriesSortName = item.FindSeriesSortName();
if (!string.Equals(item.SeriesSortName, seriesSortName, StringComparison.Ordinal))
{
item.SeriesSortName = seriesSortName;
updateType |= ItemUpdateType.MetadataImport;
}
var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey(); var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey();
if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal)) if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal))
{ {

View File

@ -1,3 +1,3 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("3.2.13.13")] [assembly: AssemblyVersion("3.2.13.14")]

View File

@ -480,6 +480,8 @@ namespace SocketHttpListener.Net
headers.SetInternal("Set-Cookie", cookie.ToString()); headers.SetInternal("Set-Cookie", cookie.ToString());
} }
headers.SetInternal("Status", status_code.ToString(CultureInfo.InvariantCulture));
using (StreamWriter writer = new StreamWriter(ms, encoding, 256, true)) using (StreamWriter writer = new StreamWriter(ms, encoding, 256, true))
{ {
writer.Write("HTTP/{0} {1} {2}\r\n", version, status_code, status_description); writer.Write("HTTP/{0} {1} {2}\r\n", version, status_code, status_description);

View File

@ -344,13 +344,6 @@ namespace SocketHttpListener.Net
private async Task TransmitFileManaged(string path, long offset, long count, FileShareMode fileShareMode, CancellationToken cancellationToken) private async Task TransmitFileManaged(string path, long offset, long count, FileShareMode fileShareMode, CancellationToken cancellationToken)
{ {
var chunked = response.SendChunked;
if (!chunked)
{
await WriteAsync(_emptyBuffer, 0, 0, cancellationToken).ConfigureAwait(false);
}
using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, fileShareMode, true)) using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, fileShareMode, true))
{ {
if (offset > 0) if (offset > 0)
@ -358,7 +351,7 @@ namespace SocketHttpListener.Net
fs.Position = offset; fs.Position = offset;
} }
var targetStream = chunked ? this : stream; var targetStream = this;
if (count > 0) if (count > 0)
{ {
@ -374,14 +367,23 @@ namespace SocketHttpListener.Net
private static async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength, CancellationToken cancellationToken) private static async Task CopyToInternalAsync(Stream source, Stream destination, long copyLength, CancellationToken cancellationToken)
{ {
var array = new byte[81920]; var array = new byte[81920];
int count; int bytesRead;
while ((count = await source.ReadAsync(array, 0, array.Length, cancellationToken).ConfigureAwait(false)) != 0)
while ((bytesRead = await source.ReadAsync(array, 0, array.Length, cancellationToken).ConfigureAwait(false)) != 0)
{ {
var bytesToCopy = Math.Min(count, copyLength); if (bytesRead == 0)
{
break;
}
await destination.WriteAsync(array, 0, Convert.ToInt32(bytesToCopy), cancellationToken).ConfigureAwait(false); var bytesToWrite = Math.Min(bytesRead, copyLength);
copyLength -= bytesToCopy; if (bytesToWrite > 0)
{
await destination.WriteAsync(array, 0, Convert.ToInt32(bytesToWrite), cancellationToken).ConfigureAwait(false);
}
copyLength -= bytesToWrite;
if (copyLength <= 0) if (copyLength <= 0)
{ {