Skip to content

Commit

Permalink
Merge pull request #3206 from MediaBrowser/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
LukePulverenti authored Mar 18, 2018
2 parents cbb30d8 + c6a2844 commit c7c89ae
Show file tree
Hide file tree
Showing 373 changed files with 961 additions and 764 deletions.
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/ApplicationHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ public bool EnableHttps
{
get
{
return SupportsHttps && (ServerConfigurationManager.Configuration.EnableHttps || ServerConfigurationManager.Configuration.RequireHttps);
return SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public IEnumerable<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> it
var itemId = item.Id;

var currentBoxSets = allBoxsets
.Where(i => i.GetLinkedChildren().Any(j => j.Id == itemId))
.Where(i => i.ContainsLinkedChildByItemId(itemId))
.ToList();

if (currentBoxSets.Count > 0)
Expand Down
48 changes: 0 additions & 48 deletions Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ public void Initialize(ReaderWriterLockSlim writeLock, ManagedConnection managed
AddColumn(db, "userdata", "AudioStreamIndex", "int", existingColumnNames);
AddColumn(db, "userdata", "SubtitleStreamIndex", "int", existingColumnNames);
}, TransactionMode);

try
{
ImportUserDataIfNeeded(connection);
}
catch (Exception ex)
{
Logger.ErrorException("Error in ImportUserDataIfNeeded", ex);
}
}
}

Expand All @@ -98,45 +89,6 @@ protected override bool EnableTempStoreMemory
}
}

private void ImportUserDataIfNeeded(ManagedConnection connection)
{
if (!_fileSystem.FileExists(_importFile))
{
return;
}

var fileToImport = _importFile;
var isImported = connection.Query("select IsUserDataImported from DataSettings").SelectScalarBool().FirstOrDefault();

if (isImported)
{
return;
}

ImportUserData(connection, fileToImport);

connection.RunInTransaction(db =>
{
using (var statement = db.PrepareStatement("replace into DataSettings (IsUserDataImported) values (@IsUserDataImported)"))
{
statement.TryBind("@IsUserDataImported", true);
statement.MoveNext();
}
}, TransactionMode);
}

private void ImportUserData(ManagedConnection connection, string file)
{
SqliteExtensions.Attach(connection, file, "UserDataBackup");

var columns = "key, userId, rating, played, playCount, isFavorite, playbackPositionTicks, lastPlayedDate, AudioStreamIndex, SubtitleStreamIndex";

connection.RunInTransaction(db =>
{
db.Execute("REPLACE INTO userdata(" + columns + ") SELECT " + columns + " FROM UserDataBackup.userdata;");
}, TransactionMode);
}

/// <summary>
/// Saves the user data.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@
<Project>{1d74413b-e7cf-455b-b021-f52bdf881542}</Project>
<Name>SocketHttpListener</Name>
</ProjectReference>
<Reference Include="Emby.Naming">
<HintPath>..\ThirdParty\emby\Emby.Naming.dll</HintPath>
<Reference Include="Emby.Naming, Version=1.0.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MediaBrowser.Naming.1.1.0\lib\netstandard1.3\Emby.Naming.dll</HintPath>
</Reference>
<Reference Include="Emby.Server.MediaEncoding">
<HintPath>..\ThirdParty\emby\Emby.Server.MediaEncoding.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ private string GetConfigIdentifier()
values.Add(config.PublicPort.ToString(CultureInfo.InvariantCulture));
values.Add(_appHost.HttpPort.ToString(CultureInfo.InvariantCulture));
values.Add(_appHost.HttpsPort.ToString(CultureInfo.InvariantCulture));
values.Add((config.EnableHttps || config.RequireHttps).ToString());
values.Add(_appHost.EnableHttps.ToString());
values.Add((config.EnableRemoteAccess).ToString());

Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ private bool ValidateRequest(string remoteIp, bool isLocal)

private bool ValidateSsl(string remoteIp, string urlString)
{
if (_config.Configuration.RequireHttps && _appHost.EnableHttps)
if (_config.Configuration.RequireHttps && _appHost.EnableHttps && !_config.Configuration.IsBehindProxy)
{
if (urlString.IndexOf("https://", StringComparison.OrdinalIgnoreCase) == -1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private MultiItemResolverResult ResolveMultipleAudio<T>(Folder parent, IEnumerab
{
Path = firstMedia.Path,
IsInMixedFolder = isInMixedFolder,
ProductionYear = resolvedItem.Year,
//ProductionYear = resolvedItem.Year,
Name = parseName ?
resolvedItem.Name :
Path.GetFileNameWithoutExtension(firstMedia.Path),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ internal static bool IsOwnedByResolvedMedia(ILibraryManager libraryManager, Libr
"backdrop",
"poster",
"cover",
"logo"
"logo",
"default"
};

internal static bool IsImageFile(string path, IImageProcessor imageProcessor)
Expand Down
16 changes: 14 additions & 2 deletions Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static string GetRecordingName(TimerInfo info)
}
else
{
name += " " + DateTime.Now.ToString("yyyy-MM-dd");
name += " " + GetDateString(info.StartDate);
}

if (!string.IsNullOrWhiteSpace(info.EpisodeTitle))
Expand All @@ -50,10 +50,22 @@ public static string GetRecordingName(TimerInfo info)
}
else
{
name += " " + info.StartDate.ToString("yyyy-MM-dd");
name += " " + GetDateString(info.StartDate);
}

return name;
}

private static string GetDateString(DateTime date)
{
return string.Format("{0}_{1}_{2}_{3}_{4}_{5}",
date.Year.ToString("0000", CultureInfo.InvariantCulture),
date.Month.ToString("00", CultureInfo.InvariantCulture),
date.Day.ToString("00", CultureInfo.InvariantCulture),
date.Hour.ToString("00", CultureInfo.InvariantCulture),
date.Minute.ToString("00", CultureInfo.InvariantCulture),
date.Second.ToString("00", CultureInfo.InvariantCulture)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private ProgramInfo GetProgram(string channelId, ScheduleDirect.Program programI
EpisodeTitle = episodeTitle,
Audio = audioType,
//IsNew = programInfo.@new ?? false,
IsRepeat = programInfo.repeat,
IsRepeat = programInfo.@new == null,
IsSeries = string.Equals(details.entityType, "episode", StringComparison.OrdinalIgnoreCase),
ImageUrl = details.primaryImage,
ThumbImageUrl = details.thumbImage,
Expand Down
36 changes: 23 additions & 13 deletions Emby.Server.Implementations/Session/FirebaseSessionController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Serialization;
using System;
using System.Threading;
Expand Down Expand Up @@ -70,14 +71,27 @@ public async Task SendMessage<T>(string name, string messageId, T data, ISession
return;
}

string strData = _json.SerializeToString(data);
var req = new FirebaseBody
foreach (var controller in allControllers)
{
to = _token,
data = new FirebaseData
// Don't send if there's an active web socket connection
if ((controller is WebSocketController) && controller.IsSessionActive)
{
msgdata = strData
return;
}
}

var msg = new WebSocketMessage<T>
{
Data = data,
MessageType = name,
MessageId = messageId,
ServerId = _appHost.SystemId
};

var req = new FirebaseBody<T>
{
to = _token,
data = msg
};

var byteArray = Encoding.UTF8.GetBytes(_json.SerializeToString(req));
Expand Down Expand Up @@ -109,13 +123,9 @@ public async Task SendMessage<T>(string name, string messageId, T data, ISession
}
}

internal class FirebaseBody
internal class FirebaseBody<T>
{
public string to { get; set; }
public FirebaseData data { get; set; }
}
internal class FirebaseData
{
public string msgdata { get; set; }
public WebSocketMessage<T> data { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private Task SendPlaystateCommand(PlaystateRequest command, string messageId, Ca
return SendMessage(command.Command.ToString(), messageId, args, cancellationToken);
}

private string[] _supportedMessages = new string[] { "LibraryChanged", "ServerRestarting", "ServerShuttingDown", "RestartRequired" };
private string[] _supportedMessages = new string[] { };
public Task SendMessage<T>(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken)
{
if (!IsSessionActive)
Expand Down
1 change: 1 addition & 0 deletions Emby.Server.Implementations/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MediaBrowser.Naming" version="1.1.0" targetFramework="net462" />
<package id="Emby.XmlTv" version="1.0.14" targetFramework="net46" />
<package id="ServiceStack.Text" version="4.5.8" targetFramework="net46" />
<package id="SharpCompress" version="0.18.2" targetFramework="net46" />
Expand Down
11 changes: 2 additions & 9 deletions MediaBrowser.Api/Images/ImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -682,15 +682,8 @@ private ImageFormat[] GetClientSupportedFormats()
formats.Add(ImageFormat.Webp);
}

if (SupportsFormat(supportedFormats, acceptParam, "jpg", true))
{
formats.Add(ImageFormat.Jpg);
}

if (SupportsFormat(supportedFormats, acceptParam, "png", true))
{
formats.Add(ImageFormat.Png);
}
formats.Add(ImageFormat.Jpg);
formats.Add(ImageFormat.Png);

if (SupportsFormat(supportedFormats, acceptParam, "gif", true))
{
Expand Down
3 changes: 0 additions & 3 deletions MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ protected BaseItemsRequest()
[ApiMember(Name = "HasTvdbId", Description = "Optional filter by items that have a tvdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? HasTvdbId { get; set; }

[ApiMember(Name = "IsInBoxSet", Description = "Optional filter by items that are in boxsets, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? IsInBoxSet { get; set; }

public string ExcludeItemIds { get; set; }

public bool EnableTotalRecordCount { get; set; }
Expand Down
1 change: 0 additions & 1 deletion MediaBrowser.Api/UserLibrary/ItemsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ private InternalItemsQuery GetItemsQuery(GetItems request, DtoOptions dtoOptions
HasImdbId = request.HasImdbId,
IsPlaceHolder = request.IsPlaceHolder,
IsLocked = request.IsLocked,
IsInBoxSet = request.IsInBoxSet,
IsHD = request.IsHD,
Is3D = request.Is3D,
HasTvdbId = request.HasTvdbId,
Expand Down
1 change: 1 addition & 0 deletions MediaBrowser.Common/Net/HttpRequestOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public string UserAgent
public bool EnableDefaultUserAgent { get; set; }

public bool AppendCharsetToMimeType { get; set; }
public string DownloadFilePath { get; set; }

private string GetHeaderValue(string name)
{
Expand Down
31 changes: 20 additions & 11 deletions MediaBrowser.Controller/Entities/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,6 @@ private bool RequiresPostFiltering(InternalItemsQuery query)
}
}

if (query.IsInBoxSet.HasValue)
{
Logger.Debug("Query requires post-filtering due to IsInBoxSet");
return true;
}

// Filter by Video3DFormat
if (query.Is3D.HasValue)
{
Expand Down Expand Up @@ -1187,11 +1181,6 @@ private static bool AllowBoxSetCollapsing(InternalItemsQuery request)
return false;
}

if (request.IsInBoxSet.HasValue)
{
return false;
}

if (request.IsLocked.HasValue)
{
return false;
Expand Down Expand Up @@ -1458,6 +1447,26 @@ protected virtual bool FilterLinkedChildrenPerUser
}
}

public bool ContainsLinkedChildByItemId(Guid itemId)
{
var linkedChildren = LinkedChildren;
foreach (var i in linkedChildren)
{
if (i.ItemId.HasValue && i.ItemId.Value == itemId)
{
return true;
}

var child = GetLinkedChild(i);

if (child != null && child.Id == itemId)
{
return true;
}
}
return false;
}

public List<BaseItem> GetLinkedChildren(User user)
{
if (!FilterLinkedChildrenPerUser || user == null)
Expand Down
1 change: 0 additions & 1 deletion MediaBrowser.Controller/Entities/InternalItemsQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class InternalItemsQuery

public bool? Is3D { get; set; }
public bool? IsHD { get; set; }
public bool? IsInBoxSet { get; set; }
public bool? IsLocked { get; set; }
public bool? IsPlaceHolder { get; set; }

Expand Down
11 changes: 1 addition & 10 deletions MediaBrowser.Controller/Entities/UserViewBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private QueryResult<BaseItem> GetMovieFolders(Folder parent, User user, Internal

if (query.IncludeItemTypes.Length == 0)
{
query.IncludeItemTypes = new[] { typeof(Movie).Name, typeof(BoxSet).Name };
query.IncludeItemTypes = new[] { typeof(Movie).Name };
}

return parent.QueryRecursive(query);
Expand Down Expand Up @@ -563,15 +563,6 @@ public static bool Filter(BaseItem item, User user, InternalItemsQuery query, IU
}
}

if (query.IsInBoxSet.HasValue)
{
var val = query.IsInBoxSet.Value;
if (item.GetParents().OfType<BoxSet>().Any() != val)
{
return false;
}
}

// Filter by Video3DFormat
if (query.Is3D.HasValue)
{
Expand Down
13 changes: 12 additions & 1 deletion MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,18 @@ public string GetVideoQualityParam(EncodingJobInfo state, string videoEncoder, E
// h264 (h264_qsv)
else if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase))
{
param += "-preset 7 -look_ahead 0";
string[] valid_h264_qsv = new string[] { "veryslow", "slower", "slow", "medium", "fast", "faster", "veryfast" };

if (valid_h264_qsv.Contains(encodingOptions.H264Preset, StringComparer.OrdinalIgnoreCase))
{
param += "-preset " + encodingOptions.H264Preset;
}
else
{
param += "-preset 7";
}

param += " -look_ahead 0";

}

Expand Down
Loading

0 comments on commit c7c89ae

Please sign in to comment.