mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-27 18:10:54 +01:00
consolidate Artist & MusicArtist
This commit is contained in:
@@ -34,7 +34,7 @@ namespace MediaBrowser.Providers
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Folder && item.LocationType == LocationType.FileSystem;
|
||||
return item.IsFolder && item.LocationType == LocationType.FileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -81,11 +81,9 @@
|
||||
<Compile Include="Music\ArtistInfoFromSongProvider.cs" />
|
||||
<Compile Include="Music\ArtistProviderFromXml.cs" />
|
||||
<Compile Include="Music\FanArtAlbumProvider.cs" />
|
||||
<Compile Include="Music\FanArtArtistByNameProvider.cs" />
|
||||
<Compile Include="Music\FanArtArtistProvider.cs" />
|
||||
<Compile Include="Music\FanArtUpdatesPrescanTask.cs" />
|
||||
<Compile Include="Music\LastfmAlbumProvider.cs" />
|
||||
<Compile Include="Music\LastfmArtistByNameProvider.cs" />
|
||||
<Compile Include="Music\LastFmImageProvider.cs" />
|
||||
<Compile Include="Music\LastfmArtistProvider.cs" />
|
||||
<Compile Include="Music\LastfmBaseProvider.cs" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using MediaBrowser.Common.MediaInfo;
|
||||
using MediaBrowser.Common.MediaInfo;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.MediaInfo;
|
||||
@@ -11,6 +10,7 @@ using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
@@ -27,10 +27,15 @@ namespace MediaBrowser.Providers.Music
|
||||
|
||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||
{
|
||||
// If song metadata has changed
|
||||
if (GetComparisonData((MusicArtist)item) != providerInfo.FileStamp)
|
||||
var artist = (MusicArtist)item;
|
||||
|
||||
if (!artist.IsAccessedByName)
|
||||
{
|
||||
return true;
|
||||
// If song metadata has changed
|
||||
if (GetComparisonData(artist) != providerInfo.FileStamp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.NeedsRefreshInternal(item, providerInfo);
|
||||
@@ -47,7 +52,7 @@ namespace MediaBrowser.Providers.Music
|
||||
return GetComparisonData(songs);
|
||||
}
|
||||
|
||||
private Guid GetComparisonData(List<Audio> songs)
|
||||
private Guid GetComparisonData(IEnumerable<Audio> songs)
|
||||
{
|
||||
var genres = songs.SelectMany(i => i.Genres)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
@@ -60,24 +65,27 @@ namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
var artist = (MusicArtist)item;
|
||||
|
||||
BaseProviderInfo data;
|
||||
if (!item.ProviderData.TryGetValue(Id, out data))
|
||||
if (!artist.IsAccessedByName)
|
||||
{
|
||||
data = new BaseProviderInfo();
|
||||
item.ProviderData[Id] = data;
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace MediaBrowser.Providers.Music
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return (item is Artist || item is MusicArtist) && item.LocationType == LocationType.FileSystem;
|
||||
return (item is MusicArtist) && item.LocationType == LocationType.FileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -88,16 +88,7 @@ namespace MediaBrowser.Providers.Music
|
||||
|
||||
try
|
||||
{
|
||||
var artist = item as Artist;
|
||||
|
||||
if (artist != null)
|
||||
{
|
||||
new BaseItemXmlParser<Artist>(Logger).Fetch(artist, path, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
new BaseItemXmlParser<MusicArtist>(Logger).Fetch((MusicArtist)item, path, cancellationToken);
|
||||
}
|
||||
new BaseItemXmlParser<MusicArtist>(Logger).Fetch((MusicArtist)item, path, cancellationToken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
/// <summary>
|
||||
/// Class FanArtArtistByNameProvider
|
||||
/// </summary>
|
||||
public class FanArtArtistByNameProvider : FanArtArtistProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FanArtArtistByNameProvider" /> class.
|
||||
/// </summary>
|
||||
public FanArtArtistByNameProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IFileSystem fileSystem)
|
||||
: base(httpClient, logManager, configurationManager, providerManager, fileSystem)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supportses the specified item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Artist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [save local meta].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [save local meta]; otherwise, <c>false</c>.</value>
|
||||
protected override bool SaveLocalMeta
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace MediaBrowser.Providers.Music
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Artist || item is MusicArtist || item is MusicAlbum;
|
||||
return item is MusicArtist || item is MusicAlbum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
/// <summary>
|
||||
/// Class LastfmArtistByNameProvider
|
||||
/// </summary>
|
||||
public class LastfmArtistByNameProvider : LastfmArtistProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LastfmArtistByNameProvider" /> class.
|
||||
/// </summary>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="httpClient">The HTTP client.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
public LastfmArtistByNameProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, ILibraryManager libraryManager)
|
||||
: base(jsonSerializer, httpClient, logManager, configurationManager, libraryManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [save local meta].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [save local meta]; otherwise, <c>false</c>.</value>
|
||||
protected override bool SaveLocalMeta
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supportses the specified item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Artist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the provider version.
|
||||
/// </summary>
|
||||
/// <value>The provider version.</value>
|
||||
protected override string ProviderVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return "7";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the lastfm data.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="musicBrainzId">The music brainz id.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected override async Task FetchLastfmData(BaseItem item, string musicBrainzId, bool force, CancellationToken cancellationToken)
|
||||
{
|
||||
var artist = (Artist)item;
|
||||
|
||||
// See if we can avoid an http request by finding the matching MusicArtist entity
|
||||
var musicArtist = Artist.FindMusicArtist(artist, LibraryManager);
|
||||
|
||||
if (musicArtist != null && !force)
|
||||
{
|
||||
LastfmHelper.ProcessArtistData(musicArtist, artist);
|
||||
}
|
||||
else
|
||||
{
|
||||
await base.FetchLastfmData(item, musicBrainzId, force, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,17 +84,6 @@ namespace MediaBrowser.Providers.Music
|
||||
/// <returns>Task{System.String}.</returns>
|
||||
private async Task<string> FindId(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
if (item is Artist)
|
||||
{
|
||||
// Since MusicArtists are refreshed first, try to find it from one of them
|
||||
var id = FindIdFromMusicArtistEntity(item);
|
||||
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// If we don't get anything, go directly to music brainz
|
||||
|
||||
@@ -39,21 +39,12 @@ namespace MediaBrowser.Providers.Music
|
||||
|
||||
var musicArtist = artist as MusicArtist;
|
||||
|
||||
string imageSize;
|
||||
|
||||
if (musicArtist != null)
|
||||
{
|
||||
string imageSize;
|
||||
musicArtist.LastFmImageUrl = GetImageUrl(data, out imageSize);
|
||||
musicArtist.LastFmImageSize = imageSize;
|
||||
}
|
||||
|
||||
var artistByName = artist as Artist;
|
||||
|
||||
if (artistByName != null)
|
||||
{
|
||||
artistByName.LastFmImageUrl = GetImageUrl(data, out imageSize);
|
||||
artistByName.LastFmImageSize = imageSize;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetImageUrl(IHasLastFmImages data, out string size)
|
||||
@@ -85,15 +76,6 @@ namespace MediaBrowser.Providers.Music
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ProcessArtistData(MusicArtist source, Artist target)
|
||||
{
|
||||
target.PremiereDate = source.PremiereDate;
|
||||
target.ProductionYear = source.ProductionYear;
|
||||
target.Tags = source.Tags.ToList();
|
||||
target.Overview = source.Overview;
|
||||
target.ProductionLocations = source.ProductionLocations.ToList();
|
||||
}
|
||||
|
||||
public static void ProcessAlbumData(BaseItem item, LastfmAlbum data)
|
||||
{
|
||||
var overview = data.wiki != null ? data.wiki.content : null;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace MediaBrowser.Providers.Music
|
||||
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is MusicArtist || item is Artist;
|
||||
return item is MusicArtist;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, ImageType imageType, CancellationToken cancellationToken)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace MediaBrowser.Providers.Music
|
||||
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is MusicAlbum || item is MusicArtist || item is Artist;
|
||||
return item is MusicAlbum || item is MusicArtist;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, ImageType imageType, CancellationToken cancellationToken)
|
||||
@@ -41,13 +41,6 @@ namespace MediaBrowser.Providers.Music
|
||||
|
||||
RemoteImageInfo info = null;
|
||||
|
||||
var artist = item as Artist;
|
||||
|
||||
if (artist != null)
|
||||
{
|
||||
info = GetInfo(artist.LastFmImageUrl, artist.LastFmImageSize);
|
||||
}
|
||||
|
||||
var album = item as MusicAlbum;
|
||||
if (album != null)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace MediaBrowser.Providers.Savers
|
||||
// If new metadata has been downloaded or metadata was manually edited, proceed
|
||||
if (wasMetadataDownloaded || wasMetadataEdited)
|
||||
{
|
||||
if (item is Artist)
|
||||
var artist = item as MusicArtist;
|
||||
if (artist != null && artist.IsAccessedByName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace MediaBrowser.Providers.Savers
|
||||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
||||
{
|
||||
if (!(item is Folder))
|
||||
if (!item.IsFolder)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user