From 8051ea9b1bebcccfa1471c1a3db0e03fd7a70bcd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 Feb 2015 19:33:06 -0500 Subject: update javascript connection manager to latest feature set --- .../FileOrganization/EpisodeFileOrganizer.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs') diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index 10e50e497..7415fe092 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -210,7 +210,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization try { - _fileSystem.DeleteFile(path); + DeleteLibraryFile(path); } catch (IOException ex) { @@ -224,6 +224,15 @@ namespace MediaBrowser.Server.Implementations.FileOrganization } } + private void DeleteLibraryFile(string path) + { + var filename = Path.GetFileNameWithoutExtension(path); + + _fileSystem.DeleteFile(path); + + // Now find other files + } + private List GetOtherDuplicatePaths(string targetPath, Series series, int seasonNumber, int episodeNumber, int? endingEpisodeNumber) { var episodePaths = series.GetRecursiveChildren() @@ -281,11 +290,11 @@ namespace MediaBrowser.Server.Implementations.FileOrganization Directory.CreateDirectory(Path.GetDirectoryName(result.TargetPath)); - var copy = File.Exists(result.TargetPath); + var targetAlreadyExists = File.Exists(result.TargetPath); try { - if (copy || options.CopyOriginalFile) + if (targetAlreadyExists || options.CopyOriginalFile) { File.Copy(result.OriginalPath, result.TargetPath, true); } @@ -312,7 +321,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization _libraryMonitor.ReportFileSystemChangeComplete(result.TargetPath, true); } - if (copy && !options.CopyOriginalFile) + if (targetAlreadyExists && !options.CopyOriginalFile) { try { -- cgit v1.2.3 From d451386f5d1b2aa08d69040938be2cf9ee89e0ef Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 18 Feb 2015 23:37:44 -0500 Subject: sync updates --- MediaBrowser.Api/ItemUpdateService.cs | 7 +++ .../Entities/Audio/MusicArtist.cs | 10 ++++ .../Entities/Audio/MusicGenre.cs | 5 ++ MediaBrowser.Controller/Entities/GameGenre.cs | 5 ++ MediaBrowser.Controller/Entities/Genre.cs | 5 ++ MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 5 ++ MediaBrowser.Controller/Entities/Person.cs | 9 +++- MediaBrowser.Controller/Entities/Studio.cs | 6 ++- MediaBrowser.Controller/Entities/Year.cs | 5 ++ .../Images/InternalMetadataFolderImageProvider.cs | 1 - MediaBrowser.Model/Dto/ImageOptions.cs | 6 +++ .../FileOrganization/EpisodeFileOrganizer.cs | 53 +++++++++++++++++++--- .../HttpServer/HttpListenerHost.cs | 18 ++++++++ 13 files changed, 124 insertions(+), 11 deletions(-) (limited to 'MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs') diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index ea90afc3b..6517d738b 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -83,6 +83,13 @@ namespace MediaBrowser.Api { info.ContentTypeOptions = GetContentTypeOptions(true); info.ContentType = configuredContentType; + + if (string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) + { + info.ContentTypeOptions = info.ContentTypeOptions + .Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) + .ToList(); + } } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index e65d3c0e7..2b8145041 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -52,6 +52,16 @@ namespace MediaBrowser.Controller.Entities.Audio } } + public override bool IsSaveLocalMetadataEnabled() + { + if (IsAccessedByName) + { + return true; + } + + return base.IsSaveLocalMetadataEnabled(); + } + private readonly Task _cachedTask = Task.FromResult(true); protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index ed0956073..971c09236 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -44,6 +44,11 @@ namespace MediaBrowser.Controller.Entities.Audio return false; } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index b246b9388..c91acbe3f 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -43,6 +43,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + public override bool CanDelete() { return false; diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index e17a5c1d8..cb68e5dae 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -34,6 +34,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + public override bool CanDelete() { return false; diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index d874046ef..0778643da 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -79,6 +79,11 @@ namespace MediaBrowser.Controller.Entities.Movies return true; } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + /// /// Gets the trailer ids. /// diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index d8cb69ca1..ef24d4347 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,8 +1,8 @@ -using System.Runtime.Serialization; -using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Providers; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -50,6 +50,11 @@ namespace MediaBrowser.Controller.Entities return false; } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 31bbaf422..b8d359369 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -45,6 +45,11 @@ namespace MediaBrowser.Controller.Entities return false; } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + /// /// Gets a value indicating whether this instance is owned item. /// @@ -63,7 +68,6 @@ namespace MediaBrowser.Controller.Entities return inputItems.Where(GetItemFilter()); } - public Func GetItemFilter() { return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase); diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index cf3ad3b6a..a1a152387 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -52,6 +52,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + public IEnumerable GetTaggedItems(IEnumerable inputItems) { int year; diff --git a/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs b/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs index 7473d48e9..60533797a 100644 --- a/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.IO; -using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; diff --git a/MediaBrowser.Model/Dto/ImageOptions.cs b/MediaBrowser.Model/Dto/ImageOptions.cs index 8e35c1323..98bd0279a 100644 --- a/MediaBrowser.Model/Dto/ImageOptions.cs +++ b/MediaBrowser.Model/Dto/ImageOptions.cs @@ -87,6 +87,12 @@ namespace MediaBrowser.Model.Dto /// The percent played. public int? PercentPlayed { get; set; } + /// + /// Gets or sets the un played count. + /// + /// The un played count. + public int? UnPlayedCount { get; set; } + /// /// Gets or sets the color of the background. /// diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index 7415fe092..4f0f42f3e 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -5,10 +5,12 @@ using MediaBrowser.Controller.FileOrganization; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Extensions; using MediaBrowser.Model.FileOrganization; using MediaBrowser.Model.Logging; -using MediaBrowser.Naming.Common; using MediaBrowser.Naming.IO; +using MediaBrowser.Server.Implementations.Library; +using MediaBrowser.Server.Implementations.Logging; using System; using System.Collections.Generic; using System.Globalization; @@ -16,8 +18,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Server.Implementations.Library; -using MediaBrowser.Server.Implementations.Logging; namespace MediaBrowser.Server.Implementations.FileOrganization { @@ -202,15 +202,26 @@ namespace MediaBrowser.Server.Implementations.FileOrganization if (overwriteExisting) { + var hasRenamedFiles = false; + foreach (var path in otherDuplicatePaths) { _logger.Debug("Removing duplicate episode {0}", path); _libraryMonitor.ReportFileSystemChangeBeginning(path); + var renameRelatedFiles = false; + //var renameRelatedFiles = !hasRenamedFiles && + // string.Equals(Path.GetDirectoryName(path), Path.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase); + + if (renameRelatedFiles) + { + hasRenamedFiles = true; + } + try { - DeleteLibraryFile(path); + DeleteLibraryFile(path, renameRelatedFiles, result.TargetPath); } catch (IOException ex) { @@ -224,13 +235,41 @@ namespace MediaBrowser.Server.Implementations.FileOrganization } } - private void DeleteLibraryFile(string path) + private void DeleteLibraryFile(string path, bool renameRelatedFiles, string targetPath) { - var filename = Path.GetFileNameWithoutExtension(path); - _fileSystem.DeleteFile(path); + if (!renameRelatedFiles) + { + return; + } + // Now find other files + var originalFilenameWithoutExtension = Path.GetFileNameWithoutExtension(path); + var directory = Path.GetDirectoryName(path); + + if (!string.IsNullOrWhiteSpace(originalFilenameWithoutExtension) && !string.IsNullOrWhiteSpace(directory)) + { + // Get all related files, e.g. metadata, images, etc + var files = Directory.EnumerateFiles(directory, "*", SearchOption.TopDirectoryOnly) + .Where(i => (Path.GetFileNameWithoutExtension(i) ?? string.Empty).StartsWith(originalFilenameWithoutExtension, StringComparison.OrdinalIgnoreCase)) + .ToList(); + + var targetFilenameWithoutExtension = Path.GetFileNameWithoutExtension(targetPath); + + foreach (var file in files) + { + directory = Path.GetDirectoryName(file); + var filename = Path.GetFileName(file); + + filename = filename.Replace(originalFilenameWithoutExtension, targetFilenameWithoutExtension, + StringComparison.OrdinalIgnoreCase); + + var destination = Path.Combine(directory, filename); + + File.Move(file, destination); + } + } } private List GetOtherDuplicatePaths(string targetPath, Series series, int seasonNumber, int episodeNumber, int? endingEpisodeNumber) diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 046941e3c..6e8ba1c1d 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -380,6 +380,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer Priority = route.Priority, Summary = route.Summary }); + + // TODO: This is a hack for iOS. Remove it asap. + routes.Add(new RouteAttribute(DoubleNormalizeRoutePath(route.Path), route.Verbs) + { + Notes = route.Notes, + Priority = route.Priority, + Summary = route.Summary + }); } return routes.ToArray(); @@ -395,6 +403,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer return "mediabrowser/" + path; } + private string DoubleNormalizeRoutePath(string path) + { + if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase)) + { + return "/mediabrowser/mediabrowser" + path; + } + + return "mediabrowser//mediabrowser" + path; + } + /// /// Releases the specified instance. /// -- cgit v1.2.3 From f2c3dade77878b48a9a333d745e5d92a0f913233 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 19 Feb 2015 12:46:18 -0500 Subject: 3.0.5518.5 --- MediaBrowser.Api/Sync/SyncService.cs | 6 ++++-- MediaBrowser.Controller/Sync/ISyncManager.cs | 2 +- .../FileOrganization/EpisodeFileOrganizer.cs | 5 ++--- .../Sync/MediaSync.cs | 2 +- .../Sync/SyncJobProcessor.cs | 22 +++++++++++++++++++--- .../Sync/SyncManager.cs | 6 +++++- SharedVersion.cs | 4 ++-- 7 files changed, 34 insertions(+), 13 deletions(-) (limited to 'MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs') diff --git a/MediaBrowser.Api/Sync/SyncService.cs b/MediaBrowser.Api/Sync/SyncService.cs index 9c6d05452..3f57ca2a0 100644 --- a/MediaBrowser.Api/Sync/SyncService.cs +++ b/MediaBrowser.Api/Sync/SyncService.cs @@ -272,9 +272,11 @@ namespace MediaBrowser.Api.Sync } } - public object Get(GetReadySyncItems request) + public async Task Get(GetReadySyncItems request) { - return ToOptimizedResult(_syncManager.GetReadySyncItems(request.TargetId)); + var result = await _syncManager.GetReadySyncItems(request.TargetId).ConfigureAwait(false); + + return ToOptimizedResult(result); } public async Task Post(SyncData request) diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index 4d654575e..4b800cac9 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -123,7 +123,7 @@ namespace MediaBrowser.Controller.Sync /// /// The target identifier. /// List<SyncedItem>. - List GetReadySyncItems(string targetId); + Task> GetReadySyncItems(string targetId); /// /// Synchronizes the data. diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index 4f0f42f3e..106e3c76b 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -210,9 +210,8 @@ namespace MediaBrowser.Server.Implementations.FileOrganization _libraryMonitor.ReportFileSystemChangeBeginning(path); - var renameRelatedFiles = false; - //var renameRelatedFiles = !hasRenamedFiles && - // string.Equals(Path.GetDirectoryName(path), Path.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase); + var renameRelatedFiles = !hasRenamedFiles && + string.Equals(Path.GetDirectoryName(path), Path.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase); if (renameRelatedFiles) { diff --git a/MediaBrowser.Server.Implementations/Sync/MediaSync.cs b/MediaBrowser.Server.Implementations/Sync/MediaSync.cs index efdfbb086..099e45a6e 100644 --- a/MediaBrowser.Server.Implementations/Sync/MediaSync.cs +++ b/MediaBrowser.Server.Implementations/Sync/MediaSync.cs @@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.Sync IProgress progress, CancellationToken cancellationToken) { - var jobItems = _syncManager.GetReadySyncItems(target.Id); + var jobItems = await _syncManager.GetReadySyncItems(target.Id).ConfigureAwait(false); var numComplete = 0; double startingPercent = 0; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 139d752fa..72dc1bdb6 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -336,11 +336,12 @@ namespace MediaBrowser.Server.Implementations.Sync return new[] { item }; } - public async Task EnsureSyncJobItems(CancellationToken cancellationToken) + private async Task EnsureSyncJobItems(string targetId, CancellationToken cancellationToken) { var jobResult = _syncRepo.GetJobs(new SyncJobQuery { - SyncNewContent = true + SyncNewContent = true, + TargetId = targetId }); foreach (var job in jobResult.Items) @@ -356,7 +357,7 @@ namespace MediaBrowser.Server.Implementations.Sync public async Task Sync(IProgress progress, CancellationToken cancellationToken) { - await EnsureSyncJobItems(cancellationToken).ConfigureAwait(false); + await EnsureSyncJobItems(null, cancellationToken).ConfigureAwait(false); // If it already has a converting status then is must have been aborted during conversion var result = _syncRepo.GetJobItems(new SyncJobItemQuery @@ -375,6 +376,21 @@ namespace MediaBrowser.Server.Implementations.Sync // Clean files in sync temp folder that are not linked to any sync jobs } + public async Task SyncJobItems(string targetId, bool enableConversion, IProgress progress, + CancellationToken cancellationToken) + { + await EnsureSyncJobItems(targetId, cancellationToken).ConfigureAwait(false); + + // If it already has a converting status then is must have been aborted during conversion + var result = _syncRepo.GetJobItems(new SyncJobItemQuery + { + Statuses = new List { SyncJobItemStatus.Queued, SyncJobItemStatus.Converting }, + TargetId = targetId + }); + + await SyncJobItems(result.Items, true, progress, cancellationToken).ConfigureAwait(false); + } + public async Task SyncJobItems(SyncJobItem[] items, bool enableConversion, IProgress progress, CancellationToken cancellationToken) { if (items.Length > 0) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index fc3d54150..a2fd92bf5 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -695,8 +695,12 @@ namespace MediaBrowser.Server.Implementations.Sync return _userDataManager.SaveUserData(new Guid(action.UserId), item, userData, UserDataSaveReason.Import, CancellationToken.None); } - public List GetReadySyncItems(string targetId) + public async Task> GetReadySyncItems(string targetId) { + var processor = GetSyncJobProcessor(); + + await processor.SyncJobItems(targetId, false, new Progress(), CancellationToken.None).ConfigureAwait(false); + var jobItemResult = GetJobItems(new SyncJobItemQuery { TargetId = targetId, diff --git a/SharedVersion.cs b/SharedVersion.cs index 97fa02a8a..c4a874f64 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("3.0.*")] -//[assembly: AssemblyVersion("3.0.5518.4")] +//[assembly: AssemblyVersion("3.0.*")] +[assembly: AssemblyVersion("3.0.5518.5")] -- cgit v1.2.3