Luke Pulverenti 10 anni fa
parent
commit
d451386f5d

+ 7 - 0
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();
+                        }
                     }
                 }
             }

+ 10 - 0
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<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
         {

+ 5 - 0
MediaBrowser.Controller/Entities/Audio/MusicGenre.cs

@@ -44,6 +44,11 @@ namespace MediaBrowser.Controller.Entities.Audio
             return false;
         }
 
+        public override bool IsSaveLocalMetadataEnabled()
+        {
+            return true;
+        }
+
         /// <summary>
         /// Gets a value indicating whether this instance is owned item.
         /// </summary>

+ 5 - 0
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;

+ 5 - 0
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;

+ 5 - 0
MediaBrowser.Controller/Entities/Movies/BoxSet.cs

@@ -79,6 +79,11 @@ namespace MediaBrowser.Controller.Entities.Movies
             return true;
         }
 
+        public override bool IsSaveLocalMetadataEnabled()
+        {
+            return true;
+        }
+
         /// <summary>
         /// Gets the trailer ids.
         /// </summary>

+ 7 - 2
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;
+        }
+
         /// <summary>
         /// Gets a value indicating whether this instance is owned item.
         /// </summary>

+ 5 - 1
MediaBrowser.Controller/Entities/Studio.cs

@@ -45,6 +45,11 @@ namespace MediaBrowser.Controller.Entities
             return false;
         }
 
+        public override bool IsSaveLocalMetadataEnabled()
+        {
+            return true;
+        }
+
         /// <summary>
         /// Gets a value indicating whether this instance is owned item.
         /// </summary>
@@ -63,7 +68,6 @@ namespace MediaBrowser.Controller.Entities
             return inputItems.Where(GetItemFilter());
         }
 
-
         public Func<BaseItem, bool> GetItemFilter()
         {
             return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase);

+ 5 - 0
MediaBrowser.Controller/Entities/Year.cs

@@ -52,6 +52,11 @@ namespace MediaBrowser.Controller.Entities
             }
         }
 
+        public override bool IsSaveLocalMetadataEnabled()
+        {
+            return true;
+        }
+
         public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
         {
             int year;

+ 0 - 1
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;

+ 6 - 0
MediaBrowser.Model/Dto/ImageOptions.cs

@@ -87,6 +87,12 @@ namespace MediaBrowser.Model.Dto
         /// <value>The percent played.</value>
         public int? PercentPlayed { get; set; }
 
+        /// <summary>
+        /// Gets or sets the un played count.
+        /// </summary>
+        /// <value>The un played count.</value>
+        public int? UnPlayedCount { get; set; }
+        
         /// <summary>
         /// Gets or sets the color of the background.
         /// </summary>

+ 46 - 7
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<string> GetOtherDuplicatePaths(string targetPath, Series series, int seasonNumber, int episodeNumber, int? endingEpisodeNumber)

+ 18 - 0
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;
+        }
+
         /// <summary>
         /// Releases the specified instance.
         /// </summary>