update music user data key

This commit is contained in:
Luke Pulverenti 2016-03-13 21:34:24 -04:00
parent 749037eb4a
commit d683f30619
17 changed files with 91 additions and 45 deletions

View File

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

View File

@ -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)

View File

@ -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)
{

View File

@ -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>

View File

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

View File

@ -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>

View File

@ -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>

View File

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

View File

@ -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));

View File

@ -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";

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -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)
{

View File

@ -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.

View File

@ -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))
{

View File

@ -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;

View File

@ -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);
}
}
}