From 6c3209e3f95cc537cc97984ba5a4d5eee0373424 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 4 Feb 2015 06:56:48 -0500 Subject: [PATCH] dlna fixes --- MediaBrowser.Dlna/DlnaManager.cs | 2 +- MediaBrowser.Dlna/Profiles/Xbox360Profile.cs | 1 + MediaBrowser.Dlna/Profiles/Xml/Default.xml | 1 + MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml | 1 + .../Profiles/Xml/DirecTV HD-DVR.xml | 1 + .../Profiles/Xml/Dish Hopper-Joey.xml | 1 + .../Profiles/Xml/LG Smart TV.xml | 1 + .../Profiles/Xml/Linksys DMA2100.xml | 1 + .../Profiles/Xml/MediaMonkey.xml | 1 + .../Profiles/Xml/Panasonic Viera.xml | 1 + .../Profiles/Xml/Popcorn Hour.xml | 1 + .../Profiles/Xml/Samsung Smart TV.xml | 1 + .../Profiles/Xml/Sony Blu-ray Player 2013.xml | 1 + .../Profiles/Xml/Sony Blu-ray Player.xml | 1 + .../Profiles/Xml/Sony Bravia (2010).xml | 1 + .../Profiles/Xml/Sony Bravia (2011).xml | 1 + .../Profiles/Xml/Sony Bravia (2012).xml | 1 + .../Profiles/Xml/Sony Bravia (2013).xml | 1 + .../Profiles/Xml/Sony PlayStation 3.xml | 1 + MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml | 1 + MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml | 1 + MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml | 1 + MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml | 1 + .../Server/DescriptionXmlBuilder.cs | 17 ++- MediaBrowser.Model/Dlna/DeviceProfile.cs | 1 + MediaBrowser.Model/Dlna/StreamBuilder.cs | 18 --- MediaBrowser.Model/Sync/SyncJobQuery.cs | 23 +++- .../Localization/JavaScript/javascript.json | 4 +- .../Sync/SyncJobProcessor.cs | 6 +- .../Sync/SyncRepository.cs | 127 +++++++++++------- .../TV/TVSeriesManager.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 35 files changed, 139 insertions(+), 95 deletions(-) diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index f0f295c831..0bce849ce4 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -515,7 +515,7 @@ namespace MediaBrowser.Dlna public void Run() { - //DumpProfiles(); + DumpProfiles(); } private void DumpProfiles() diff --git a/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs b/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs index c792eb0786..7aa924be0f 100644 --- a/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs +++ b/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs @@ -29,6 +29,7 @@ namespace MediaBrowser.Dlna.Profiles TimelineOffsetSeconds = 40; RequiresPlainFolders = true; RequiresPlainVideoItems = true; + EnableMSMediaReceiverRegistrar = true; Identification = new DeviceIdentification { diff --git a/MediaBrowser.Dlna/Profiles/Xml/Default.xml b/MediaBrowser.Dlna/Profiles/Xml/Default.xml index fd4246dec9..b70cc10c2e 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Default.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Default.xml @@ -28,6 +28,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml index b62580f69d..6250e0f0e6 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml @@ -33,6 +33,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml b/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml index 603ec554ed..0079b5f8d8 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml @@ -34,6 +34,7 @@ true false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml b/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml index c8eff5b1d1..d338b2b6d4 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml @@ -35,6 +35,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml index e625555bde..ba72f63065 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml @@ -34,6 +34,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml index 09165349e4..829ce70686 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml @@ -32,6 +32,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml b/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml index c57a368b34..78ba4aba39 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml @@ -34,6 +34,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml index 515492c7fa..88160b0ce3 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml @@ -35,6 +35,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml b/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml index 4fa4db30bb..d6acd65caf 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml @@ -28,6 +28,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml index d2b814de34..bd113b9c7d 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml @@ -34,6 +34,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml index 1d0ea66bbc..3104f5c688 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml @@ -34,6 +34,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml index 2a883ac67c..57a32607ed 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml @@ -36,6 +36,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml index d9727ecd08..b7325c53ce 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml @@ -36,6 +36,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml index 1e3b48452e..59157baddd 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml @@ -36,6 +36,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml index 509f533b97..d2d9c181ff 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml @@ -36,6 +36,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml index 35e645422d..7b3d95b9d8 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml @@ -36,6 +36,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml index 939f953b9d..454dabe5d4 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml @@ -36,6 +36,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml index 015dbbc1fa..2829bfb473 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml @@ -35,6 +35,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml index 7a183396d2..76e4a6c31f 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml @@ -35,6 +35,7 @@ true false false + true diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml index f666dfd27f..c8c0a52024 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml @@ -35,6 +35,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml index 2afdcc6f88..7a8f3a09d4 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml @@ -34,6 +34,7 @@ false false false + false diff --git a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs index f586e4fa1b..e302fe902f 100644 --- a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs +++ b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs @@ -261,14 +261,17 @@ namespace MediaBrowser.Dlna.Server EventSubUrl = "connectionmanager/events" }); - list.Add(new DeviceService + if (_profile.EnableMSMediaReceiverRegistrar) { - ServiceType = "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1", - ServiceId = "urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar", - ScpdUrl = "mediareceiverregistrar/mediareceiverregistrar.xml", - ControlUrl = "mediareceiverregistrar/control", - EventSubUrl = "mediareceiverregistrar/events" - }); + list.Add(new DeviceService + { + ServiceType = "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1", + ServiceId = "urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar", + ScpdUrl = "mediareceiverregistrar/mediareceiverregistrar.xml", + ControlUrl = "mediareceiverregistrar/control", + EventSubUrl = "mediareceiverregistrar/events" + }); + } return list; } diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs index 1fb553010e..3bbef28c57 100644 --- a/MediaBrowser.Model/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs @@ -78,6 +78,7 @@ namespace MediaBrowser.Model.Dlna public bool SupportsDirectRemoteContent { get; set; } public bool SupportsCustomHttpHeaders { get; set; } + public bool EnableMSMediaReceiverRegistrar { get; set; } public XmlAttribute[] XmlRootAttributes { get; set; } diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 117d738f31..84c0839976 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -524,11 +524,6 @@ namespace MediaBrowser.Model.Dlna { if (subtitleStream != null) { - if (!subtitleStream.IsTextSubtitleStream) - { - return false; - } - SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options); if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed) @@ -568,19 +563,6 @@ namespace MediaBrowser.Model.Dlna }; } - private SubtitleProfile GetSubtitleProfile(SubtitleProfile[] profiles, SubtitleDeliveryMethod method, string[] formats) - { - foreach (SubtitleProfile profile in profiles) - { - if (method == profile.Method && ListHelper.ContainsIgnoreCase(formats, profile.Format)) - { - return profile; - } - } - - return null; - } - private SubtitleProfile GetSubtitleProfile(SubtitleProfile[] profiles, SubtitleDeliveryMethod method) { foreach (SubtitleProfile profile in profiles) diff --git a/MediaBrowser.Model/Sync/SyncJobQuery.cs b/MediaBrowser.Model/Sync/SyncJobQuery.cs index 35f0e076df..233dc7878a 100644 --- a/MediaBrowser.Model/Sync/SyncJobQuery.cs +++ b/MediaBrowser.Model/Sync/SyncJobQuery.cs @@ -1,4 +1,5 @@ - +using System.Collections.Generic; + namespace MediaBrowser.Model.Sync { public class SyncJobQuery @@ -14,11 +15,6 @@ namespace MediaBrowser.Model.Sync /// The limit. public int? Limit { get; set; } /// - /// Gets or sets a value indicating whether this instance is completed. - /// - /// null if [is completed] contains no value, true if [is completed]; otherwise, false. - public bool? IsCompleted { get; set; } - /// /// Gets or sets the target identifier. /// /// The target identifier. @@ -28,5 +24,20 @@ namespace MediaBrowser.Model.Sync /// /// The user identifier. public string UserId { get; set; } + /// + /// Gets or sets the status. + /// + /// The status. + public List Statuses { get; set; } + /// + /// Gets or sets a value indicating whether [synchronize new content]. + /// + /// null if [synchronize new content] contains no value, true if [synchronize new content]; otherwise, false. + public bool? SyncNewContent { get; set; } + + public SyncJobQuery() + { + Statuses = new List(); + } } } diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 4b9795b82e..b494adfd89 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -89,8 +89,8 @@ "LabelFree": "Free", "HeaderSelectAudio": "Select Audio", "HeaderSelectSubtitles": "Select Subtitles", - "ButtonMarkForRemoval": "Mark for removal from device", - "ButtonUnmarkForRemoval": "Unmark for removal from device", + "ButtonMarkForRemoval": "Remove from device", + "ButtonUnmarkForRemoval": "Cancel removal from device", "LabelDefaultStream": "(Default)", "LabelForcedStream": "(Forced)", "LabelDefaultForcedStream": "(Default/Forced)", diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 3628bda2aa..328b8441a0 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -308,11 +308,11 @@ namespace MediaBrowser.Server.Implementations.Sync return new[] { item }; } - public async Task EnsureSyncJobs(CancellationToken cancellationToken) + public async Task EnsureSyncJobItems(CancellationToken cancellationToken) { var jobResult = _syncRepo.GetJobs(new SyncJobQuery { - IsCompleted = false + SyncNewContent = true }); foreach (var job in jobResult.Items) @@ -328,7 +328,7 @@ namespace MediaBrowser.Server.Implementations.Sync public async Task Sync(IProgress progress, CancellationToken cancellationToken) { - await EnsureSyncJobs(cancellationToken).ConfigureAwait(false); + await EnsureSyncJobItems(cancellationToken).ConfigureAwait(false); // If it already has a converting status then is must have been aborted during conversion var result = _syncRepo.GetJobItems(new SyncJobItemQuery diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 85317cb237..5a07a41e9c 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -30,7 +30,8 @@ namespace MediaBrowser.Server.Implementations.Sync private IDbCommand _deleteJobCommand; private IDbCommand _deleteJobItemsCommand; - private IDbCommand _saveJobItemCommand; + private IDbCommand _insertJobItemCommand; + private IDbCommand _updateJobItemCommand; private readonly IJsonSerializer _json; @@ -120,25 +121,45 @@ namespace MediaBrowser.Server.Implementations.Sync _updateJobCommand.Parameters.Add(_updateJobCommand, "@DateLastModified"); _updateJobCommand.Parameters.Add(_updateJobCommand, "@ItemCount"); - // _saveJobItemCommand - _saveJobItemCommand = _connection.CreateCommand(); - _saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource, @IsMarkedForRemoval, @JobItemIndex)"; - - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Id"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@ItemId"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@ItemName"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@MediaSourceId"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@JobId"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@TemporaryPath"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@OutputPath"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Status"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@TargetId"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@DateCreated"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Progress"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@AdditionalFiles"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@MediaSource"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@IsMarkedForRemoval"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@JobItemIndex"); + // _insertJobItemCommand + _insertJobItemCommand = _connection.CreateCommand(); + _insertJobItemCommand.CommandText = "insert into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource, @IsMarkedForRemoval, @JobItemIndex)"; + + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@Id"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@ItemId"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@ItemName"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@MediaSourceId"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@JobId"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@TemporaryPath"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@OutputPath"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@Status"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@TargetId"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@DateCreated"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@Progress"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@AdditionalFiles"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@MediaSource"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@IsMarkedForRemoval"); + _insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@JobItemIndex"); + + // _updateJobItemCommand + _updateJobItemCommand = _connection.CreateCommand(); + _updateJobItemCommand.CommandText = "update SyncJobItems set ItemId=@ItemId,ItemName=@ItemName,MediaSourceId=@MediaSourceId,JobId=@JobId,TemporaryPath=@TemporaryPath,OutputPath=@OutputPath,Status=@Status,TargetId=@TargetId,DateCreated=@DateCreated,Progress=@Progress,AdditionalFiles=@AdditionalFiles,MediaSource=@MediaSource,IsMarkedForRemoval=@IsMarkedForRemoval,JobItemIndex=@JobItemIndex where Id=@Id"; + + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@Id"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@ItemId"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@ItemName"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@MediaSourceId"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@JobId"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@TemporaryPath"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@OutputPath"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@Status"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@TargetId"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@DateCreated"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@Progress"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@AdditionalFiles"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@MediaSource"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@IsMarkedForRemoval"); + _updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@JobItemIndex"); } private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs"; @@ -392,17 +413,11 @@ namespace MediaBrowser.Server.Implementations.Sync var whereClauses = new List(); - if (query.IsCompleted.HasValue) + if (query.Statuses.Count > 0) { - if (query.IsCompleted.Value) - { - whereClauses.Add("Status=@Status"); - } - else - { - whereClauses.Add("Status<>@Status"); - } - cmd.Parameters.Add(cmd, "@Status", DbType.String).Value = SyncJobStatus.Completed.ToString(); + var statuses = string.Join(",", query.Statuses.Select(i => "'" + i.ToString() + "'").ToArray()); + + whereClauses.Add(string.Format("Status in ({0})", statuses)); } if (!string.IsNullOrWhiteSpace(query.TargetId)) { @@ -413,6 +428,11 @@ namespace MediaBrowser.Server.Implementations.Sync whereClauses.Add("UserId=@UserId"); cmd.Parameters.Add(cmd, "@UserId", DbType.String).Value = query.UserId; } + if (query.SyncNewContent.HasValue) + { + whereClauses.Add("SyncNewContent=@SyncNewContent"); + cmd.Parameters.Add(cmd, "@SyncNewContent", DbType.Boolean).Value = query.SyncNewContent.Value; + } var whereTextWithoutPaging = whereClauses.Count == 0 ? string.Empty : @@ -583,10 +603,15 @@ namespace MediaBrowser.Server.Implementations.Sync public Task Create(SyncJobItem jobItem) { - return Update(jobItem); + return InsertOrUpdate(jobItem, _insertJobItemCommand); + } + + public Task Update(SyncJobItem jobItem) + { + return InsertOrUpdate(jobItem, _updateJobItemCommand); } - public async Task Update(SyncJobItem jobItem) + private async Task InsertOrUpdate(SyncJobItem jobItem, IDbCommand cmd) { if (jobItem == null) { @@ -603,25 +628,25 @@ namespace MediaBrowser.Server.Implementations.Sync var index = 0; - _saveJobItemCommand.GetParameter(index++).Value = new Guid(jobItem.Id); - _saveJobItemCommand.GetParameter(index++).Value = jobItem.ItemId; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.ItemName; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSourceId; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.JobId; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.TemporaryPath; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.OutputPath; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.Status.ToString(); - _saveJobItemCommand.GetParameter(index++).Value = jobItem.TargetId; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.DateCreated; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.Progress; - _saveJobItemCommand.GetParameter(index++).Value = _json.SerializeToString(jobItem.AdditionalFiles); - _saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSource == null ? null : _json.SerializeToString(jobItem.MediaSource); - _saveJobItemCommand.GetParameter(index++).Value = jobItem.IsMarkedForRemoval; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.JobItemIndex; - - _saveJobItemCommand.Transaction = transaction; - - _saveJobItemCommand.ExecuteNonQuery(); + cmd.GetParameter(index++).Value = new Guid(jobItem.Id); + cmd.GetParameter(index++).Value = jobItem.ItemId; + cmd.GetParameter(index++).Value = jobItem.ItemName; + cmd.GetParameter(index++).Value = jobItem.MediaSourceId; + cmd.GetParameter(index++).Value = jobItem.JobId; + cmd.GetParameter(index++).Value = jobItem.TemporaryPath; + cmd.GetParameter(index++).Value = jobItem.OutputPath; + cmd.GetParameter(index++).Value = jobItem.Status.ToString(); + cmd.GetParameter(index++).Value = jobItem.TargetId; + cmd.GetParameter(index++).Value = jobItem.DateCreated; + cmd.GetParameter(index++).Value = jobItem.Progress; + cmd.GetParameter(index++).Value = _json.SerializeToString(jobItem.AdditionalFiles); + cmd.GetParameter(index++).Value = jobItem.MediaSource == null ? null : _json.SerializeToString(jobItem.MediaSource); + cmd.GetParameter(index++).Value = jobItem.IsMarkedForRemoval; + cmd.GetParameter(index++).Value = jobItem.JobItemIndex; + + cmd.Transaction = transaction; + + cmd.ExecuteNonQuery(); transaction.Commit(); } diff --git a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs index 6700e90543..3087842993 100644 --- a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs +++ b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs @@ -129,7 +129,7 @@ namespace MediaBrowser.Server.Implementations.TV // Get them in display order, then reverse var allEpisodes = series.GetSeasons(user, true, true) .Where(i => !i.IndexNumber.HasValue || i.IndexNumber.Value != 0) - .SelectMany(i => i.GetEpisodes(user, true, true)) + .SelectMany(i => i.GetEpisodes(user)) .Reverse() .ToList(); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index dabe7485e7..a9194c05cc 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.553 + 3.0.554 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 16559a41b8..5bbb13e192 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.553 + 3.0.554 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index 12c2a65511..1240064927 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.553 + 3.0.554 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 00f9310348..da3283c324 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.553 + 3.0.554 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +