Bläddra i källkod

update music user data key

Luke Pulverenti 9 år sedan
förälder
incheckning
d683f30619

+ 1 - 0
MediaBrowser.Api/StartupWizardService.cs

@@ -68,6 +68,7 @@ namespace MediaBrowser.Api
             _config.Configuration.EnableLocalizedGuids = true;
             _config.Configuration.EnableCustomPathSubFolders = true;
             _config.Configuration.EnableDateLastRefresh = true;
+            _config.Configuration.EnableStandaloneMusicKeys = true;
             _config.SaveConfiguration();
         }
 

+ 25 - 0
MediaBrowser.Controller/Entities/Audio/Audio.cs

@@ -153,6 +153,31 @@ namespace MediaBrowser.Controller.Entities.Audio
         /// <returns>System.String.</returns>
         protected override string CreateUserDataKey()
         {
+            if (ConfigurationManager.Configuration.EnableStandaloneMusicKeys)
+            {
+                var songKey = IndexNumber.HasValue ? IndexNumber.Value.ToString("0000") : string.Empty;
+
+
+                if (ParentIndexNumber.HasValue)
+                {
+                    songKey = ParentIndexNumber.Value.ToString("0000") + "-" + songKey;
+                }
+                songKey+= Name;
+
+                if (!string.IsNullOrWhiteSpace(Album))
+                {
+                    songKey = Album + "-" + songKey;
+                }
+
+                var albumArtist = AlbumArtists.FirstOrDefault();
+                if (!string.IsNullOrWhiteSpace(albumArtist))
+                {
+                    songKey = albumArtist + "-" + songKey;
+                }
+
+                return songKey;
+            }
+
             var parent = AlbumEntity;
 
             if (parent != null)

+ 21 - 2
MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs

@@ -34,7 +34,17 @@ namespace MediaBrowser.Controller.Entities.Audio
         {
             get
             {
-                return GetParents().OfType<MusicArtist>().FirstOrDefault();
+                var artist = GetParents().OfType<MusicArtist>().FirstOrDefault();
+
+                if (artist == null)
+                {
+                    var name = AlbumArtist;
+                    if (!string.IsNullOrWhiteSpace(name))
+                    {
+                        artist = LibraryManager.GetArtist(name);
+                    }
+                }
+                return artist;
             }
         }
 
@@ -106,6 +116,15 @@ namespace MediaBrowser.Controller.Entities.Audio
                 return "MusicAlbum-Musicbrainz-" + id;
             }
 
+            if (ConfigurationManager.Configuration.EnableStandaloneMusicKeys)
+            {
+                var albumArtist = AlbumArtist;
+                if (!string.IsNullOrWhiteSpace(albumArtist))
+                {
+                    return albumArtist + "-" + Name;
+                }
+            }
+
             return base.CreateUserDataKey();
         }
 
@@ -125,7 +144,7 @@ namespace MediaBrowser.Controller.Entities.Audio
 
             id.AlbumArtists = AlbumArtists;
 
-            var artist = GetParents().OfType<MusicArtist>().FirstOrDefault();
+            var artist = MusicArtist;
 
             if (artist != null)
             {

+ 8 - 0
MediaBrowser.Controller/Entities/Movies/Movie.cs

@@ -6,6 +6,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using System.Runtime.Serialization;
 using System.Threading;
 using System.Threading.Tasks;
 using CommonIO;
@@ -85,6 +86,13 @@ namespace MediaBrowser.Controller.Entities.Movies
         /// <value>The name of the TMDB collection.</value>
         public string TmdbCollectionName { get; set; }
 
+        [IgnoreDataMember]
+        public string CollectionName
+        {
+            get { return TmdbCollectionName; }
+            set { TmdbCollectionName = value; }
+        }
+        
         /// <summary>
         /// Gets the trailer ids.
         /// </summary>

+ 1 - 1
MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs

@@ -35,7 +35,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
 
                         if (!string.IsNullOrWhiteSpace(val) && movie != null)
                         {
-                            movie.TmdbCollectionName = val;
+                            movie.CollectionName = val;
                         }
 
                         break;

+ 2 - 1
MediaBrowser.Model/Configuration/ServerConfiguration.cs

@@ -207,7 +207,8 @@ namespace MediaBrowser.Model.Configuration
         public bool DownloadImagesInAdvance { get; set; }
 
         public bool EnableAnonymousUsageReporting { get; set; }
-        
+        public bool EnableStandaloneMusicKeys { get; set; }
+
         /// <summary>
         /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
         /// </summary>

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

@@ -206,12 +206,6 @@ namespace MediaBrowser.Model.Dto
         /// <value>The short overview.</value>
         public string ShortOverview { get; set; }
 
-        /// <summary>
-        /// Gets or sets the name of the TMDB collection.
-        /// </summary>
-        /// <value>The name of the TMDB collection.</value>
-        public string TmdbCollectionName { get; set; }
-
         /// <summary>
         /// Gets or sets the taglines.
         /// </summary>

+ 0 - 5
MediaBrowser.Model/Querying/ItemFields.cs

@@ -235,11 +235,6 @@
         /// </summary>
         VoteCount,
 
-        /// <summary>
-        /// The TMDB collection name
-        /// </summary>
-        TmdbCollectionName,
-        
         /// <summary>
         /// The trailer url of the item
         /// </summary>

+ 2 - 2
MediaBrowser.Providers/Manager/ProviderManager.cs

@@ -1022,8 +1022,8 @@ namespace MediaBrowser.Providers.Manager
                                         .ToList();
 
             var musicArtists = albums
-                .Select(i => i.GetParent())
-                .OfType<MusicArtist>()
+                .Select(i => i.MusicArtist)
+                .Where(i => i != null)
                 .ToList();
 
             var musicArtistRefreshTasks = musicArtists.Select(i => i.ValidateChildren(new Progress<double>(), cancellationToken, options, true));

+ 13 - 3
MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs

@@ -107,11 +107,21 @@ namespace MediaBrowser.Providers.MediaInfo
 
         private string GetAudioImagePath(Audio item)
         {
-            var album = item.AlbumEntity;
-
             var filename = item.Album ?? string.Empty;
             filename += string.Join(",", item.Artists.ToArray());
-            filename += album == null ? item.Id.ToString("N") + "_primary" + item.DateModified.Ticks : album.Id.ToString("N") + album.DateModified.Ticks + "_primary";
+
+            if (!string.IsNullOrWhiteSpace(item.Album))
+            {
+                filename += "_" + item.Album;
+            }
+            else if (!string.IsNullOrWhiteSpace(item.Name))
+            {
+                filename += "_" + item.Name;
+            }
+            else
+            {
+                filename += "_" + item.Id.ToString("N");
+            }
 
             filename = filename.GetMD5() + ".jpg";
 

+ 1 - 1
MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs

@@ -179,7 +179,7 @@ namespace MediaBrowser.Providers.Movies
 
                 if (movieItem != null)
                 {
-                    movieItem.TmdbCollectionName = movieData.belongs_to_collection.name;
+                    movieItem.CollectionName = movieData.belongs_to_collection.name;
                 }
             }
 

+ 2 - 2
MediaBrowser.Providers/Movies/MovieMetadataService.cs

@@ -37,9 +37,9 @@ namespace MediaBrowser.Providers.Movies
             var sourceItem = source.Item;
             var targetItem = target.Item;
 
-            if (replaceData || string.IsNullOrEmpty(targetItem.TmdbCollectionName))
+            if (replaceData || string.IsNullOrEmpty(targetItem.CollectionName))
             {
-                targetItem.TmdbCollectionName = sourceItem.TmdbCollectionName;
+                targetItem.CollectionName = sourceItem.CollectionName;
             }
         }
     }

+ 0 - 10
MediaBrowser.Server.Implementations/Dto/DtoService.cs

@@ -1378,16 +1378,6 @@ namespace MediaBrowser.Server.Implementations.Dto
                 }
             }
 
-            // Add MovieInfo
-            var movie = item as Movie;
-            if (movie != null)
-            {
-                if (fields.Contains(ItemFields.TmdbCollectionName))
-                {
-                    dto.TmdbCollectionName = movie.TmdbCollectionName;
-                }
-            }
-
             var hasSpecialFeatures = item as IHasSpecialFeatures;
             if (hasSpecialFeatures != null)
             {

+ 0 - 5
MediaBrowser.Server.Implementations/Library/LibraryManager.cs

@@ -1044,11 +1044,6 @@ namespace MediaBrowser.Server.Implementations.Library
             return names;
         }
 
-        private void SetPropertiesFromSongs(MusicArtist artist, IEnumerable<IHasMetadata> items)
-        {
-
-        }
-
         /// <summary>
         /// Validate and refresh the People sub-set of the IBN.
         /// The items are stored in the db but not loaded into memory until actually requested by an operation.

+ 3 - 2
MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs

@@ -180,7 +180,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
                     }
                     catch (XmlException)
                     {
-                        
+
                     }
                 }
             }
@@ -661,7 +661,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
                             if (!string.IsNullOrWhiteSpace(val))
                             {
                                 val = val.Replace("plugin://plugin.video.youtube/?action=play_video&videoid=", "http://www.youtube.com/watch?v=", StringComparison.OrdinalIgnoreCase);
-                                
+
                                 hasTrailer.AddTrailerUrl(val, false);
                             }
                         }
@@ -860,6 +860,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
                     break;
 
                 case "collectionnumber":
+                case "tmdbcolid":
                     var tmdbCollection = reader.ReadElementContentAsString();
                     if (!string.IsNullOrWhiteSpace(tmdbCollection))
                     {

+ 10 - 3
MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs

@@ -11,7 +11,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
 {
     class MovieNfoParser : BaseNfoParser<Video>
     {
-        public MovieNfoParser(ILogger logger, IConfigurationManager config) : base(logger, config)
+        public MovieNfoParser(ILogger logger, IConfigurationManager config)
+            : base(logger, config)
         {
         }
 
@@ -44,12 +45,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
 
                 case "set":
                     {
-                        var val = reader.ReadElementContentAsString();
                         var movie = item as Movie;
 
+                        var tmdbcolid = reader.GetAttribute("tmdbcolid");
+                        if (!string.IsNullOrWhiteSpace(tmdbcolid) && movie != null)
+                        {
+                            movie.SetProviderId(MetadataProviders.TmdbCollection, tmdbcolid);
+                        }
+
+                        var val = reader.ReadElementContentAsString();
                         if (!string.IsNullOrWhiteSpace(val) && movie != null)
                         {
-                            movie.TmdbCollectionName = val;
+                            movie.CollectionName = val;
                         }
 
                         break;

+ 2 - 2
MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs

@@ -101,9 +101,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
 
             if (movie != null)
             {
-                if (!string.IsNullOrEmpty(movie.TmdbCollectionName))
+                if (!string.IsNullOrEmpty(movie.CollectionName))
                 {
-                    writer.WriteElementString("set", movie.TmdbCollectionName);
+                    writer.WriteElementString("set", movie.CollectionName);
                 }
             }
         }