removed genre virtualization
This commit is contained in:
parent
5225e054cd
commit
d1d4bef1d1
|
@ -1,5 +1,4 @@
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
@ -54,26 +53,6 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
get { return Parent as MusicArtist ?? UnknwonArtist; }
|
get { return Parent as MusicArtist ?? UnknwonArtist; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Override to point to first child (song)
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The genres.</value>
|
|
||||||
public override List<string> Genres
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Children
|
|
||||||
.OfType<Audio>()
|
|
||||||
.SelectMany(i => i.Genres)
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
base.Genres = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the images.
|
/// Gets or sets the images.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities.Audio
|
namespace MediaBrowser.Controller.Entities.Audio
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -9,20 +6,5 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MusicArtist : Folder
|
public class MusicArtist : Folder
|
||||||
{
|
{
|
||||||
public override List<string> Genres
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Children
|
|
||||||
.OfType<MusicAlbum>()
|
|
||||||
.SelectMany(i => i.Genres)
|
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
base.Genres = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,7 +543,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// Gets or sets the genres.
|
/// Gets or sets the genres.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The genres.</value>
|
/// <value>The genres.</value>
|
||||||
public virtual List<string> Genres { get; set; }
|
public List<string> Genres { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the home page URL.
|
/// Gets or sets the home page URL.
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
<Compile Include="Movies\PersonProviderFromXml.cs" />
|
<Compile Include="Movies\PersonProviderFromXml.cs" />
|
||||||
<Compile Include="Movies\TmdbPersonProvider.cs" />
|
<Compile Include="Movies\TmdbPersonProvider.cs" />
|
||||||
<Compile Include="Music\AlbumInfoFromSongProvider.cs" />
|
<Compile Include="Music\AlbumInfoFromSongProvider.cs" />
|
||||||
|
<Compile Include="Music\ArtistInfoFromSongProvider.cs" />
|
||||||
<Compile Include="Music\ArtistProviderFromXml.cs" />
|
<Compile Include="Music\ArtistProviderFromXml.cs" />
|
||||||
<Compile Include="Music\ArtistsPostScanTask.cs" />
|
<Compile Include="Music\ArtistsPostScanTask.cs" />
|
||||||
<Compile Include="Music\FanArtAlbumProvider.cs" />
|
<Compile Include="Music\FanArtAlbumProvider.cs" />
|
||||||
|
|
90
MediaBrowser.Providers/Music/ArtistInfoFromSongProvider.cs
Normal file
90
MediaBrowser.Providers/Music/ArtistInfoFromSongProvider.cs
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Providers.Music
|
||||||
|
{
|
||||||
|
public class ArtistInfoFromSongProvider : BaseMetadataProvider
|
||||||
|
{
|
||||||
|
public ArtistInfoFromSongProvider(ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||||
|
: base(logManager, configurationManager)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Supports(BaseItem item)
|
||||||
|
{
|
||||||
|
return item is MusicArtist;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
|
{
|
||||||
|
// If song metadata has changed
|
||||||
|
if (GetComparisonData((MusicArtist)item) != providerInfo.FileStamp)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.NeedsRefreshInternal(item, providerInfo);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the data.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="artist">The artist.</param>
|
||||||
|
/// <returns>Guid.</returns>
|
||||||
|
private Guid GetComparisonData(MusicArtist artist)
|
||||||
|
{
|
||||||
|
var songs = artist.RecursiveChildren.OfType<Audio>().ToList();
|
||||||
|
|
||||||
|
return GetComparisonData(songs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Guid GetComparisonData(List<Audio> songs)
|
||||||
|
{
|
||||||
|
var genres = songs.SelectMany(i => i.Genres)
|
||||||
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return string.Join(string.Empty, genres.OrderBy(i => i).ToArray()).GetMD5();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var artist = (MusicArtist)item;
|
||||||
|
|
||||||
|
BaseProviderInfo data;
|
||||||
|
if (!item.ProviderData.TryGetValue(Id, out data))
|
||||||
|
{
|
||||||
|
data = new BaseProviderInfo();
|
||||||
|
item.ProviderData[Id] = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
var songs = artist.RecursiveChildren.OfType<Audio>().ToList();
|
||||||
|
|
||||||
|
if (!item.LockedFields.Contains(MetadataFields.Genres))
|
||||||
|
{
|
||||||
|
artist.Genres = songs.SelectMany(i => i.Genres)
|
||||||
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
data.FileStamp = GetComparisonData(songs);
|
||||||
|
|
||||||
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
|
return TrueTaskResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override MetadataProviderPriority Priority
|
||||||
|
{
|
||||||
|
get { return MetadataProviderPriority.Second; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,6 +54,15 @@ namespace MediaBrowser.Providers.Music
|
||||||
return base.NeedsRefreshInternal(item, providerInfo);
|
return base.NeedsRefreshInternal(item, providerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the priority.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The priority.</value>
|
||||||
|
public override MetadataProviderPriority Priority
|
||||||
|
{
|
||||||
|
get { return MetadataProviderPriority.Third; }
|
||||||
|
}
|
||||||
|
|
||||||
private bool HasAltMeta(BaseItem item)
|
private bool HasAltMeta(BaseItem item)
|
||||||
{
|
{
|
||||||
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName("artist.xml");
|
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName("artist.xml");
|
||||||
|
|
|
@ -79,15 +79,6 @@ namespace MediaBrowser.Providers.Music
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the priority.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The priority.</value>
|
|
||||||
public override MetadataProviderPriority Priority
|
|
||||||
{
|
|
||||||
get { return MetadataProviderPriority.Second; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether [requires internet].
|
/// Gets a value indicating whether [requires internet].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user