diff --git a/BDInfo/BDROM.cs b/BDInfo/BDROM.cs index 97dbfbf3bd..2faeb405e2 100644 --- a/BDInfo/BDROM.cs +++ b/BDInfo/BDROM.cs @@ -77,6 +77,11 @@ namespace BDInfo public BDROM( string path, IFileSystem fileSystem, ITextEncoding textEncoding) { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + _fileSystem = fileSystem; // // Locate BDMV directories. @@ -326,15 +331,28 @@ namespace BDInfo private FileSystemMetadata GetDirectoryBDMV( string path) { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + FileSystemMetadata dir = _fileSystem.GetDirectoryInfo(path); while (dir != null) { - if (dir.Name == "BDMV") + if (string.Equals(dir.Name, "BDMV", StringComparison.OrdinalIgnoreCase)) { return dir; } - dir = _fileSystem.GetDirectoryInfo(Path.GetDirectoryName(dir.FullName)); + var parentFolder = Path.GetDirectoryName(dir.FullName); + if (string.IsNullOrEmpty(parentFolder)) + { + dir = null; + } + else + { + dir = _fileSystem.GetDirectoryInfo(parentFolder); + } } return GetDirectory("BDMV", _fileSystem.GetDirectoryInfo(path), 0); @@ -350,7 +368,7 @@ namespace BDInfo FileSystemMetadata[] children = _fileSystem.GetDirectories(dir.FullName).ToArray(); foreach (FileSystemMetadata child in children) { - if (child.Name == name) + if (string.Equals(child.Name, name, StringComparison.OrdinalIgnoreCase)) { return child; } diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs index 02d7cb31fd..9c9e14ec6b 100644 --- a/Emby.Common.Implementations/BaseApplicationHost.cs +++ b/Emby.Common.Implementations/BaseApplicationHost.cs @@ -795,6 +795,8 @@ return null; /// public void NotifyPendingRestart() { + Logger.Info("App needs to be restarted."); + var changed = !HasPendingRestart; HasPendingRestart = true; diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 4329911289..5718cbd09f 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -268,7 +268,7 @@ namespace Emby.Dlna.ContentDirectory } else { - _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, item, null, null, deviceId, filter); + _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, item, user, null, null, deviceId, filter); } provided++; @@ -294,7 +294,7 @@ namespace Emby.Dlna.ContentDirectory } else { - _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, childItem, item, serverItem.StubType, deviceId, filter); + _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, childItem, user, item, serverItem.StubType, deviceId, filter); } } } @@ -390,7 +390,7 @@ namespace Emby.Dlna.ContentDirectory } else { - _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, i, item, serverItem.StubType, deviceId, filter); + _didlBuilder.WriteItemElement(_config.GetDlnaConfiguration(), writer, i, user, item, serverItem.StubType, deviceId, filter); } } diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 3dcdaf2efc..3e47362f65 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -61,7 +61,7 @@ namespace Emby.Dlna.Didl _user = user; } - public string GetItemDidl(DlnaOptions options, BaseItem item, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo) + public string GetItemDidl(DlnaOptions options, BaseItem item, User user, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo) { var settings = new XmlWriterSettings { @@ -86,7 +86,7 @@ namespace Emby.Dlna.Didl WriteXmlRootAttributes(_profile, writer); - WriteItemElement(options, writer, item, context, null, deviceId, filter, streamInfo); + WriteItemElement(options, writer, item, user, context, null, deviceId, filter, streamInfo); writer.WriteFullEndElement(); //writer.WriteEndDocument(); @@ -111,7 +111,15 @@ namespace Emby.Dlna.Didl } } - public void WriteItemElement(DlnaOptions options, XmlWriter writer, BaseItem item, BaseItem context, StubType? contextStubType, string deviceId, Filter filter, StreamInfo streamInfo = null) + public void WriteItemElement(DlnaOptions options, + XmlWriter writer, + BaseItem item, + User user, + BaseItem context, + StubType? contextStubType, + string deviceId, + Filter filter, + StreamInfo streamInfo = null) { var clientId = GetClientId(item, null); @@ -135,7 +143,7 @@ namespace Emby.Dlna.Didl AddGeneralProperties(item, null, context, writer, filter); - //AddBookmarkInfo(item, user, element); + AddSamsungBookmarkInfo(item, user, writer); // refID? // storeAttribute(itemNode, object, ClassProperties.REF_ID, false); @@ -555,17 +563,37 @@ namespace Emby.Dlna.Didl writer.WriteFullEndElement(); } - //private void AddBookmarkInfo(BaseItem item, User user, XmlElement element) - //{ - // var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey()); - - // if (userdata.PlaybackPositionTicks > 0) - // { - // var dcmInfo = element.OwnerDocument.CreateElement("sec", "dcmInfo", NS_SEC); - // dcmInfo.InnerText = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture)); - // element.AppendChild(dcmInfo); - // } - //} + private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer) + { + if (!item.SupportsPositionTicksResume || item is Folder) + { + return; + } + + XmlAttribute secAttribute = null; + foreach (var attribute in _profile.XmlRootAttributes) + { + if (string.Equals(attribute.Name, "xmlns:sec", StringComparison.OrdinalIgnoreCase)) + { + secAttribute = attribute; + break; + } + } + + // Not a samsung device + if (secAttribute == null) + { + return; + } + + var userdata = _userDataManager.GetUserData(user.Id, item); + + if (userdata.PlaybackPositionTicks > 0) + { + var elementValue = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture)); + AddValue(writer, "sec", "dcmInfo", elementValue, secAttribute.Value); + } + } /// /// Adds fields used by both items and folders diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index 7dff8bda13..4ad62216e4 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -493,7 +493,7 @@ namespace Emby.Dlna.PlayTo playlistItem.StreamUrl = playlistItem.StreamInfo.ToDlnaUrl(_serverAddress, _accessToken); var itemXml = new DidlBuilder(profile, user, _imageProcessor, _serverAddress, _accessToken, _userDataManager, _localization, _mediaSourceManager, _logger, _libraryManager, _mediaEncoder) - .GetItemDidl(_config.GetDlnaConfiguration(), item, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo); + .GetItemDidl(_config.GetDlnaConfiguration(), item, user, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo); playlistItem.Didl = itemXml; diff --git a/Emby.Dlna/Profiles/DishHopperJoeyProfile.cs b/Emby.Dlna/Profiles/DishHopperJoeyProfile.cs index 9f31377101..d494a7bfca 100644 --- a/Emby.Dlna/Profiles/DishHopperJoeyProfile.cs +++ b/Emby.Dlna/Profiles/DishHopperJoeyProfile.cs @@ -201,6 +201,21 @@ namespace Emby.Dlna.Profiles IsRequired = true } } + }, + + new CodecProfile + { + Type = CodecType.VideoAudio, + Conditions = new [] + { + // The device does not have any audio switching capabilities + new ProfileCondition + { + Condition = ProfileConditionType.Equals, + Property = ProfileConditionValue.IsSecondaryAudio, + Value = "false" + } + } } }; diff --git a/Emby.Dlna/Profiles/LgTvProfile.cs b/Emby.Dlna/Profiles/LgTvProfile.cs index faaf63b314..f7cf7b9a19 100644 --- a/Emby.Dlna/Profiles/LgTvProfile.cs +++ b/Emby.Dlna/Profiles/LgTvProfile.cs @@ -55,27 +55,26 @@ namespace Emby.Dlna.Profiles { Container = "ts", VideoCodec = "h264", - AudioCodec = "aac,ac3,mp3", + AudioCodec = "aac,ac3,mp3,dca,dts", Type = DlnaProfileType.Video }, new DirectPlayProfile { Container = "mkv", VideoCodec = "h264", - AudioCodec = "aac,ac3,mp3", + AudioCodec = "aac,ac3,mp3,dca,dts", Type = DlnaProfileType.Video }, new DirectPlayProfile { Container = "mp4", VideoCodec = "h264,mpeg4", - AudioCodec = "aac,ac3,mp3", + AudioCodec = "aac,ac3,mp3,dca,dts", Type = DlnaProfileType.Video }, new DirectPlayProfile { Container = "mp3", - AudioCodec = "mp3", Type = DlnaProfileType.Audio }, new DirectPlayProfile diff --git a/Emby.Dlna/Profiles/Xml/Dish Hopper-Joey.xml b/Emby.Dlna/Profiles/Xml/Dish Hopper-Joey.xml index 3ad2a01295..3b790986a2 100644 --- a/Emby.Dlna/Profiles/Xml/Dish Hopper-Joey.xml +++ b/Emby.Dlna/Profiles/Xml/Dish Hopper-Joey.xml @@ -80,6 +80,12 @@ + + + + + + diff --git a/Emby.Dlna/Profiles/Xml/LG Smart TV.xml b/Emby.Dlna/Profiles/Xml/LG Smart TV.xml index 3a185e7331..cc8bf947cc 100644 --- a/Emby.Dlna/Profiles/Xml/LG Smart TV.xml +++ b/Emby.Dlna/Profiles/Xml/LG Smart TV.xml @@ -35,10 +35,10 @@ false - - - - + + + + diff --git a/Emby.Server.Core/ApplicationHost.cs b/Emby.Server.Core/ApplicationHost.cs index 3590ade401..215ac84924 100644 --- a/Emby.Server.Core/ApplicationHost.cs +++ b/Emby.Server.Core/ApplicationHost.cs @@ -1083,6 +1083,8 @@ namespace Emby.Server.Core if (requiresRestart) { + Logger.Info("App needs to be restarted due to configuration change."); + NotifyPendingRestart(); } } @@ -1204,7 +1206,8 @@ namespace Emby.Server.Core var exclude = new[] { "mbplus.dll", - "mbintros.dll" + "mbintros.dll", + "embytv.dll" }; return !exclude.Contains(filename ?? string.Empty, StringComparer.OrdinalIgnoreCase); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 0df916ded3..f7dc930097 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -79,21 +79,6 @@ namespace Emby.Server.Implementations.Channels _channels = channels.ToArray(); } - public string ChannelDownloadPath - { - get - { - var options = _config.GetChannelsConfiguration(); - - if (!string.IsNullOrWhiteSpace(options.DownloadPath)) - { - return options.DownloadPath; - } - - return Path.Combine(_config.ApplicationPaths.ProgramDataPath, "channels"); - } - } - private IEnumerable GetAllChannels() { return _channels @@ -288,7 +273,7 @@ namespace Emby.Server.Implementations.Channels _jsonSerializer.SerializeToFile(mediaSources, path); } - public async Task> GetStaticMediaSources(BaseItem item, bool includeCachedVersions, CancellationToken cancellationToken) + public async Task> GetStaticMediaSources(BaseItem item, CancellationToken cancellationToken) { IEnumerable results = new List(); var video = item as Video; @@ -302,17 +287,9 @@ namespace Emby.Server.Implementations.Channels results = audio.ChannelMediaSources ?? GetSavedMediaSources(audio); } - var sources = SortMediaInfoResults(results) + return SortMediaInfoResults(results) .Select(i => GetMediaSource(item, i)) .ToList(); - - if (includeCachedVersions) - { - var cachedVersions = GetCachedChannelItemMediaSources(item); - sources.InsertRange(0, cachedVersions); - } - - return sources; } public async Task> GetDynamicMediaSources(BaseItem item, CancellationToken cancellationToken) @@ -334,14 +311,9 @@ namespace Emby.Server.Implementations.Channels results = new List(); } - var list = SortMediaInfoResults(results) + return SortMediaInfoResults(results) .Select(i => GetMediaSource(item, i)) .ToList(); - - var cachedVersions = GetCachedChannelItemMediaSources(item); - list.InsertRange(0, cachedVersions); - - return list; } private readonly ConcurrentDictionary>> _channelItemMediaInfo = @@ -369,55 +341,6 @@ namespace Emby.Server.Implementations.Channels return list; } - private IEnumerable GetCachedChannelItemMediaSources(BaseItem item) - { - var filenamePrefix = item.Id.ToString("N"); - var parentPath = Path.Combine(ChannelDownloadPath, item.ChannelId); - - try - { - var files = _fileSystem.GetFiles(parentPath); - - if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) - { - files = files.Where(i => _libraryManager.IsVideoFile(i.FullName)); - } - else - { - files = files.Where(i => _libraryManager.IsAudioFile(i.FullName)); - } - - var file = files - .FirstOrDefault(i => i.Name.StartsWith(filenamePrefix, StringComparison.OrdinalIgnoreCase)); - - if (file != null) - { - var cachedItem = _libraryManager.ResolvePath(file); - - if (cachedItem != null) - { - var hasMediaSources = _libraryManager.GetItemById(cachedItem.Id) as IHasMediaSources; - - if (hasMediaSources != null) - { - var source = hasMediaSources.GetMediaSources(true).FirstOrDefault(); - - if (source != null) - { - return new[] { source }; - } - } - } - } - } - catch (IOException) - { - - } - - return new List(); - } - private MediaSourceInfo GetMediaSource(BaseItem item, ChannelMediaInfo info) { var source = info.ToMediaSource(); diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs index d6ad0ba8ab..783258a138 100644 --- a/Emby.Server.Implementations/Data/SqliteExtensions.cs +++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs @@ -346,6 +346,18 @@ namespace Emby.Server.Implementations.Data } } + public static void TryBind(this IStatement statement, string name, double? value) + { + if (value.HasValue) + { + TryBind(statement, name, value.Value); + } + else + { + TryBindNull(statement, name); + } + } + public static void TryBind(this IStatement statement, string name, int? value) { if (value.HasValue) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 8e6a277a47..8c16216b95 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -5267,11 +5267,19 @@ namespace Emby.Server.Implementations.Data { foreach (var pair in values) { + var itemValue = pair.Item2; + + // Don't save if invalid + if (string.IsNullOrWhiteSpace(itemValue)) + { + continue; + } + statement.Reset(); statement.TryBind("@ItemId", itemId.ToGuidParamValue()); statement.TryBind("@Type", pair.Item1); - statement.TryBind("@Value", pair.Item2); + statement.TryBind("@Value", itemValue); if (pair.Item2 == null) { diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index d773fbbf73..ae21651918 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -312,8 +312,8 @@ ..\packages\Emby.XmlTv.1.0.3\lib\portable-net45+win8\Emby.XmlTv.dll True - - ..\packages\MediaBrowser.Naming.1.0.3\lib\portable-net45+win8\MediaBrowser.Naming.dll + + ..\packages\MediaBrowser.Naming.1.0.4\lib\portable-net45+win8\MediaBrowser.Naming.dll True diff --git a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs index 38708648fe..561f5ee12e 100644 --- a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs @@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.EntryPoints if (_appHost.HasPendingRestart) { - _timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10)); + _timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(15)); } } @@ -65,6 +65,8 @@ namespace Emby.Server.Implementations.EntryPoints { DisposeTimer(); + _logger.Info("Automatically restarting the system because it is idle and a restart is required."); + try { _appHost.Restart(); diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 0e1f5a5517..83885ee2ee 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -228,11 +228,14 @@ namespace Emby.Server.Implementations.HttpServer } } - private void ErrorHandler(Exception ex, IRequest httpReq) + private void ErrorHandler(Exception ex, IRequest httpReq, bool logException = true) { try { - _logger.ErrorException("Error processing request", ex); + if (logException) + { + _logger.ErrorException("Error processing request", ex); + } var httpRes = httpReq.Response; @@ -529,6 +532,10 @@ namespace Emby.Server.Implementations.HttpServer ErrorHandler(new FileNotFoundException(), httpReq); } } + catch (OperationCanceledException ex) + { + ErrorHandler(ex, httpReq, false); + } catch (Exception ex) { ErrorHandler(ex, httpReq); diff --git a/Emby.Server.Implementations/HttpServer/IHttpListener.cs b/Emby.Server.Implementations/HttpServer/IHttpListener.cs index 9f96a8e49d..18df5682d7 100644 --- a/Emby.Server.Implementations/HttpServer/IHttpListener.cs +++ b/Emby.Server.Implementations/HttpServer/IHttpListener.cs @@ -12,7 +12,7 @@ namespace Emby.Server.Implementations.HttpServer /// Gets or sets the error handler. /// /// The error handler. - Action ErrorHandler { get; set; } + Action ErrorHandler { get; set; } /// /// Gets or sets the request handler. diff --git a/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 4606d0e316..652fc4f837 100644 --- a/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp _httpRequestFactory = httpRequestFactory; } - public Action ErrorHandler { get; set; } + public Action ErrorHandler { get; set; } public Func RequestHandler { get; set; } public Action WebSocketConnecting { get; set; } @@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp _logger.ErrorException("Error processing request", ex); httpReq = httpReq ?? GetRequest(context); - ErrorHandler(ex, httpReq); + ErrorHandler(ex, httpReq, true); return Task.FromResult(true); } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 5bf53fcb43..4c788a2abe 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -3084,7 +3084,11 @@ namespace Emby.Server.Implementations.Library foreach (var contentType in ConfigurationManager.Configuration.ContentTypes) { - if (string.Equals(path, contentType.Name, StringComparison.OrdinalIgnoreCase) + if (string.IsNullOrWhiteSpace(contentType.Name)) + { + removeList.Add(contentType); + } + else if (string.Equals(path, contentType.Name, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(path, contentType.Name)) { removeList.Add(contentType); diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index d758158479..5f37025e2a 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.ScheduledTasks new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerDaily, - TimeOfDayTicks = TimeSpan.FromHours(1).Ticks, + TimeOfDayTicks = TimeSpan.FromHours(2).Ticks, MaxRuntimeMs = Convert.ToInt32(TimeSpan.FromHours(4).TotalMilliseconds) } }; diff --git a/Emby.Server.Implementations/Sync/CloudSyncProfile.cs b/Emby.Server.Implementations/Sync/CloudSyncProfile.cs index 1a78c8ae66..c0675df817 100644 --- a/Emby.Server.Implementations/Sync/CloudSyncProfile.cs +++ b/Emby.Server.Implementations/Sync/CloudSyncProfile.cs @@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.Sync }, new ProfileCondition { - Condition = ProfileConditionType.EqualsAny, + Condition = ProfileConditionType.Equals, Property = ProfileConditionValue.NumVideoStreams, Value = "1", IsRequired = false @@ -230,20 +230,6 @@ namespace Emby.Server.Implementations.Sync Codec = "aac,mp3", Conditions = new[] { - new ProfileCondition - { - Condition = ProfileConditionType.LessThanEqual, - Property = ProfileConditionValue.AudioChannels, - Value = "2", - IsRequired = true - }, - new ProfileCondition - { - Condition = ProfileConditionType.LessThanEqual, - Property = ProfileConditionValue.AudioBitrate, - Value = "320000", - IsRequired = true - }, new ProfileCondition { Condition = ProfileConditionType.Equals, diff --git a/Emby.Server.Implementations/Sync/SyncRepository.cs b/Emby.Server.Implementations/Sync/SyncRepository.cs index 885f8e64a6..6d4fce3997 100644 --- a/Emby.Server.Implementations/Sync/SyncRepository.cs +++ b/Emby.Server.Implementations/Sync/SyncRepository.cs @@ -221,48 +221,77 @@ namespace Emby.Server.Implementations.Sync using (var connection = CreateConnection()) { string commandText; - var paramList = new List(); if (insert) { - commandText = "insert into SyncJobs (Id, TargetId, Name, Profile, Quality, Bitrate, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + commandText = "insert into SyncJobs (Id, TargetId, Name, Profile, Quality, Bitrate, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Profile, @Quality, @Bitrate, @Status, @Progress, @UserId, @ItemIds, @Category, @ParentId, @UnwatchedOnly, @ItemLimit, @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)"; } else { - commandText = "update SyncJobs set TargetId=?,Name=?,Profile=?,Quality=?,Bitrate=?,Status=?,Progress=?,UserId=?,ItemIds=?,Category=?,ParentId=?,UnwatchedOnly=?,ItemLimit=?,SyncNewContent=?,DateCreated=?,DateLastModified=?,ItemCount=? where Id=?"; + commandText = "update SyncJobs set TargetId=@TargetId,Name=@Name,Profile=@Profile,Quality=@Quality,Bitrate=@Bitrate,Status=@Status,Progress=@Progress,UserId=@UserId,ItemIds=@ItemIds,Category=@Category,ParentId=@ParentId,UnwatchedOnly=@UnwatchedOnly,ItemLimit=@ItemLimit,SyncNewContent=@SyncNewContent,DateCreated=@DateCreated,DateLastModified=@DateLastModified,ItemCount=@ItemCount where Id=@Id"; } - paramList.Add(job.TargetId); - paramList.Add(job.Name); - paramList.Add(job.Profile); - paramList.Add(job.Quality); - paramList.Add(job.Bitrate); - paramList.Add(job.Status.ToString()); - paramList.Add(job.Progress); - paramList.Add(job.UserId); + connection.RunInTransaction(conn => + { + using (var statement = PrepareStatementSafe(connection, commandText)) + { + statement.TryBind("@TargetId", job.TargetId); + statement.TryBind("@Name", job.Name); + statement.TryBind("@Profile", job.Profile); + statement.TryBind("@Quality", job.Quality); + statement.TryBind("@Bitrate", job.Bitrate); + statement.TryBind("@Status", job.Status.ToString()); + statement.TryBind("@Progress", job.Progress); + statement.TryBind("@UserId", job.UserId); + + if (job.RequestedItemIds.Count > 0) + { + statement.TryBind("@ItemIds", string.Join(",", job.RequestedItemIds.ToArray())); + } + else + { + statement.TryBindNull("@ItemIds"); + } - paramList.Add(string.Join(",", job.RequestedItemIds.ToArray())); - paramList.Add(job.Category); - paramList.Add(job.ParentId); - paramList.Add(job.UnwatchedOnly); - paramList.Add(job.ItemLimit); - paramList.Add(job.SyncNewContent); - paramList.Add(job.DateCreated.ToDateTimeParamValue()); - paramList.Add(job.DateLastModified.ToDateTimeParamValue()); - paramList.Add(job.ItemCount); + if (job.Category.HasValue) + { + statement.TryBind("@Category", job.Category.Value.ToString()); + } + else + { + statement.TryBindNull("@Category"); + } - if (insert) - { - paramList.Insert(0, job.Id.ToGuidParamValue()); - } - else - { - paramList.Add(job.Id.ToGuidParamValue()); - } + if (!string.IsNullOrWhiteSpace(job.ParentId)) + { + statement.TryBind("@ParentId", job.ParentId); + } + else + { + statement.TryBindNull("@ParentId"); + } - connection.RunInTransaction(conn => - { - conn.Execute(commandText, paramList.ToArray()); + statement.TryBind("@UnwatchedOnly", job.UnwatchedOnly); + + if (job.ItemLimit.HasValue) + { + statement.TryBind("@ItemLimit", job.ItemLimit); + } + else + { + statement.TryBindNull("@ItemLimit"); + } + + statement.TryBind("@SyncNewContent", job.SyncNewContent); + + statement.TryBind("@DateCreated", job.DateCreated.ToDateTimeParamValue()); + statement.TryBind("@DateLastModified", job.DateLastModified.ToDateTimeParamValue()); + + statement.TryBind("@ItemCount", job.ItemCount); + statement.TryBind("@Id", job.Id.ToGuidParamValue()); + + statement.MoveNext(); + } }, TransactionMode); } } diff --git a/Emby.Server.Implementations/packages.config b/Emby.Server.Implementations/packages.config index 09b0af8981..fcce67b330 100644 --- a/Emby.Server.Implementations/packages.config +++ b/Emby.Server.Implementations/packages.config @@ -1,7 +1,7 @@  - + diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index b0a0e79aee..5c99d98c25 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -99,6 +99,7 @@ namespace MediaBrowser.Api var path = item.ContainingFolderPath; var types = _config.Configuration.ContentTypes + .Where(i => !string.IsNullOrWhiteSpace(i.Name)) .Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase)) .ToList(); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6545d995c9..5e450567a7 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1467,7 +1467,7 @@ namespace MediaBrowser.Api.Playback } // h264 - return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", + return string.Format(" -maxrate {0} -bufsize {1}", bitrate.Value.ToString(UsCulture), (bitrate.Value * 2).ToString(UsCulture)); } diff --git a/MediaBrowser.Controller/Channels/IChannelManager.cs b/MediaBrowser.Controller/Channels/IChannelManager.cs index 9177e2d813..7927446289 100644 --- a/MediaBrowser.Controller/Channels/IChannelManager.cs +++ b/MediaBrowser.Controller/Channels/IChannelManager.cs @@ -15,15 +15,8 @@ namespace MediaBrowser.Controller.Channels /// Adds the parts. /// /// The channels. - /// The factories. void AddParts(IEnumerable channels); - /// - /// Gets the channel download path. - /// - /// The channel download path. - string ChannelDownloadPath { get; } - /// /// Gets the channel features. /// @@ -115,10 +108,9 @@ namespace MediaBrowser.Controller.Channels /// Gets the channel item media sources. /// /// The item. - /// if set to true [include cached versions]. /// The cancellation token. /// Task{IEnumerable{MediaSourceInfo}}. - Task> GetStaticMediaSources(BaseItem item, bool includeCachedVersions, CancellationToken cancellationToken); + Task> GetStaticMediaSources(BaseItem item, CancellationToken cancellationToken); /// /// Gets the channel folder. diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index e4f638cb6f..3a6a7765b1 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -206,7 +206,7 @@ namespace MediaBrowser.Controller.Entities.Audio { if (SourceType == SourceType.Channel) { - var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None) + var sources = ChannelManager.GetStaticMediaSources(this, CancellationToken.None) .Result.ToList(); if (sources.Count > 0) diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 7ba59df4f3..47df12e1b6 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -549,7 +549,7 @@ namespace MediaBrowser.Controller.Entities { if (SourceType == SourceType.Channel) { - var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None) + var sources = ChannelManager.GetStaticMediaSources(this, CancellationToken.None) .Result.ToList(); if (sources.Count > 0) diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs index bf7343f3d2..219b1f3c5d 100644 --- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs +++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs @@ -30,6 +30,11 @@ namespace MediaBrowser.MediaEncoding.BdInfo /// BlurayDiscInfo. public BlurayDiscInfo GetDiscInfo(string path) { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + var bdrom = new BDROM(path, _fileSystem, _textEncoding); bdrom.Scan(); diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index b8087fded2..d7789a5fd2 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -816,7 +816,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } // h264 - return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", + return string.Format(" -maxrate {0} -bufsize {1}", bitrate.Value.ToString(UsCulture), (bitrate.Value * 2).ToString(UsCulture)); } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 116a6a7cf5..89730a11fd 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -287,6 +287,8 @@ namespace MediaBrowser.MediaEncoding.Encoder return; } + _logger.Info("Attempting to update encoder path to {0}. pathType: {1}", path ?? string.Empty, pathType ?? string.Empty); + Tuple newPaths; if (string.Equals(pathType, "system", StringComparison.OrdinalIgnoreCase)) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 493fe1bd24..22713b94fe 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -462,11 +462,9 @@ namespace MediaBrowser.Model.Configuration Type = ImageType.Art }, - // Don't download this by default - // Generally not used new ImageOption { - Limit = 0, + Limit = 1, Type = ImageType.Logo } }, @@ -556,7 +554,7 @@ namespace MediaBrowser.Model.Configuration Type = ImageType.Thumb } }, - DisabledMetadataFetchers = new []{ "The Open Movie Database", "TheMovieDb" } + DisabledMetadataFetchers = new []{ "TheMovieDb" } }, new MetadataOptions(0, 1280) @@ -577,8 +575,8 @@ namespace MediaBrowser.Model.Configuration Type = ImageType.Primary } }, - DisabledMetadataFetchers = new []{ "The Open Movie Database" }, - DisabledImageFetchers = new []{ "TheMovieDb" } + DisabledMetadataFetchers = new []{ "The Open Movie Database", "TheMovieDb" }, + DisabledImageFetchers = new []{ "The Open Movie Database", "TheMovieDb" } } }; } diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs index e9e76a993e..1c11e6a3ca 100644 --- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs +++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs @@ -124,6 +124,7 @@ namespace MediaBrowser.Model.Dlna switch (condition.Condition) { case ProfileConditionType.Equals: + case ProfileConditionType.EqualsAny: return currentValue.Value.Equals(expected); case ProfileConditionType.GreaterThanEqual: return currentValue.Value >= expected; @@ -132,7 +133,7 @@ namespace MediaBrowser.Model.Dlna case ProfileConditionType.NotEquals: return !currentValue.Value.Equals(expected); default: - throw new InvalidOperationException("Unexpected ProfileConditionType"); + throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition); } } @@ -160,7 +161,7 @@ namespace MediaBrowser.Model.Dlna case ProfileConditionType.NotEquals: return !StringHelper.EqualsIgnoreCase(currentValue, expected); default: - throw new InvalidOperationException("Unexpected ProfileConditionType"); + throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition); } } @@ -182,7 +183,7 @@ namespace MediaBrowser.Model.Dlna case ProfileConditionType.NotEquals: return currentValue.Value != expected; default: - throw new InvalidOperationException("Unexpected ProfileConditionType"); + throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition); } } @@ -211,7 +212,7 @@ namespace MediaBrowser.Model.Dlna case ProfileConditionType.NotEquals: return !currentValue.Value.Equals(expected); default: - throw new InvalidOperationException("Unexpected ProfileConditionType"); + throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition); } } @@ -240,7 +241,7 @@ namespace MediaBrowser.Model.Dlna case ProfileConditionType.NotEquals: return !currentValue.Value.Equals(expected); default: - throw new InvalidOperationException("Unexpected ProfileConditionType"); + throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition); } } @@ -264,7 +265,7 @@ namespace MediaBrowser.Model.Dlna case ProfileConditionType.NotEquals: return timestamp != expected; default: - throw new InvalidOperationException("Unexpected ProfileConditionType"); + throw new InvalidOperationException("Unexpected ProfileConditionType: " + condition.Condition); } } } diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 6d68831ff7..cbbf434ff1 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -410,8 +410,6 @@ namespace MediaBrowser.Model.Dlna audioStreamIndex = audioStream.Index; } - var allMediaStreams = item.MediaStreams; - MediaStream videoStream = item.VideoStream; // TODO: This doesn't accout for situation of device being able to handle media bitrate, but wifi connection not fast enough @@ -427,7 +425,7 @@ namespace MediaBrowser.Model.Dlna if (isEligibleForDirectPlay || isEligibleForDirectStream) { // See if it can be direct played - PlayMethod? directPlay = GetVideoDirectPlayProfile(options, item, videoStream, audioStream, isEligibleForDirectPlay, isEligibleForDirectStream, allMediaStreams); + PlayMethod? directPlay = GetVideoDirectPlayProfile(options, item, videoStream, audioStream, isEligibleForDirectPlay, isEligibleForDirectStream); if (directPlay != null) { @@ -656,8 +654,7 @@ namespace MediaBrowser.Model.Dlna MediaStream videoStream, MediaStream audioStream, bool isEligibleForDirectPlay, - bool isEligibleForDirectStream, - List allMediaStreams) + bool isEligibleForDirectStream) { DeviceProfile profile = options.Profile; diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 0a070d3487..c1bae4b3cb 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -328,6 +328,11 @@ namespace MediaBrowser.Providers.MediaInfo /// VideoStream. private BlurayDiscInfo GetBDInfo(string path) { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + try { return _blurayExaminer.GetDiscInfo(path); diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index 721e31b07e..c1668c4cc3 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Omdb T item = itemResult.Item; - var result = await GetRootObject(imdbId, cancellationToken); + var result = await GetRootObject(imdbId, cancellationToken).ConfigureAwait(false); // Only take the name and rating if the user's language is set to english, since Omdb has no localization if (string.Equals(language, "en", StringComparison.OrdinalIgnoreCase)) @@ -221,7 +221,7 @@ namespace MediaBrowser.Providers.Omdb internal async Task GetRootObject(string imdbId, CancellationToken cancellationToken) { - var path = await EnsureItemInfo(imdbId, cancellationToken); + var path = await EnsureItemInfo(imdbId, cancellationToken).ConfigureAwait(false); string resultString; @@ -240,7 +240,7 @@ namespace MediaBrowser.Providers.Omdb internal async Task GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken) { - var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken); + var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken).ConfigureAwait(false); string resultString; diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 5385125577..22e7e753ca 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -87,6 +87,12 @@ namespace MediaBrowser.Providers.TV var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); + // Doesn't have required provider id's + if (string.IsNullOrWhiteSpace(seriesDataPath)) + { + return; + } + var episodeFiles = _fileSystem.GetFilePaths(seriesDataPath) .Where(i => string.Equals(Path.GetExtension(i), ".xml", StringComparison.OrdinalIgnoreCase)) .Select(Path.GetFileNameWithoutExtension) diff --git a/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs index 21e327a8f2..56aa3967c5 100644 --- a/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/Omdb/OmdbEpisodeProvider.cs @@ -55,11 +55,15 @@ namespace MediaBrowser.Providers.TV return result; } - if (OmdbProvider.IsValidSeries(info.SeriesProviderIds) && info.IndexNumber.HasValue && info.ParentIndexNumber.HasValue) + string seriesImdbId; + if (info.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesImdbId) && !string.IsNullOrEmpty(seriesImdbId)) { - var seriesImdbId = info.GetProviderId(MetadataProviders.Imdb); - - result.HasMetadata = await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager).FetchEpisodeData(result, info.IndexNumber.Value, info.ParentIndexNumber.Value, seriesImdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false); + if (info.IndexNumber.HasValue && + info.ParentIndexNumber.HasValue) + { + result.HasMetadata = await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager) + .FetchEpisodeData(result, info.IndexNumber.Value, info.ParentIndexNumber.Value, seriesImdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false); + } } return result; diff --git a/MediaBrowser.ServerApplication/WindowsAppHost.cs b/MediaBrowser.ServerApplication/WindowsAppHost.cs index 398d21f329..ec66923aaa 100644 --- a/MediaBrowser.ServerApplication/WindowsAppHost.cs +++ b/MediaBrowser.ServerApplication/WindowsAppHost.cs @@ -112,7 +112,7 @@ namespace MediaBrowser.ServerApplication // save it IPersistFile file = (IPersistFile)link; - file.Save(targetPath, false); + file.Save(targetPath, true); } else { diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 8678925675..0a67cbdb06 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -162,9 +162,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -507,9 +504,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -534,9 +528,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest