mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
fixes #608 - Add manual image selection for People
This commit is contained in:
parent
0f311f48c4
commit
20845a7a7b
@ -62,6 +62,8 @@
|
|||||||
<Compile Include="Movies\BoxSetProviderFromXml.cs" />
|
<Compile Include="Movies\BoxSetProviderFromXml.cs" />
|
||||||
<Compile Include="Movies\ManualMovieDbImageProvider.cs" />
|
<Compile Include="Movies\ManualMovieDbImageProvider.cs" />
|
||||||
<Compile Include="Movies\ManualFanartMovieImageProvider.cs" />
|
<Compile Include="Movies\ManualFanartMovieImageProvider.cs" />
|
||||||
|
<Compile Include="Movies\ManualMovieDbPersonImageProvider.cs" />
|
||||||
|
<Compile Include="Movies\MovieDbPersonImageProvider.cs" />
|
||||||
<Compile Include="Movies\MovieUpdatesPrescanTask.cs" />
|
<Compile Include="Movies\MovieUpdatesPrescanTask.cs" />
|
||||||
<Compile Include="Movies\MovieXmlParser.cs" />
|
<Compile Include="Movies\MovieXmlParser.cs" />
|
||||||
<Compile Include="Movies\FanArtMovieProvider.cs" />
|
<Compile Include="Movies\FanArtMovieProvider.cs" />
|
||||||
@ -72,7 +74,7 @@
|
|||||||
<Compile Include="Movies\OpenMovieDatabaseProvider.cs" />
|
<Compile Include="Movies\OpenMovieDatabaseProvider.cs" />
|
||||||
<Compile Include="Movies\PersonProviderFromXml.cs" />
|
<Compile Include="Movies\PersonProviderFromXml.cs" />
|
||||||
<Compile Include="Movies\PersonUpdatesPreScanTask.cs" />
|
<Compile Include="Movies\PersonUpdatesPreScanTask.cs" />
|
||||||
<Compile Include="Movies\TmdbPersonProvider.cs" />
|
<Compile Include="Movies\MovieDbPersonProvider.cs" />
|
||||||
<Compile Include="Music\AlbumInfoFromSongProvider.cs" />
|
<Compile Include="Music\AlbumInfoFromSongProvider.cs" />
|
||||||
<Compile Include="Music\ArtistInfoFromSongProvider.cs" />
|
<Compile Include="Music\ArtistInfoFromSongProvider.cs" />
|
||||||
<Compile Include="Music\ArtistProviderFromXml.cs" />
|
<Compile Include="Music\ArtistProviderFromXml.cs" />
|
||||||
|
@ -86,8 +86,33 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
Type = ImageType.Backdrop,
|
Type = ImageType.Backdrop,
|
||||||
RatingType = RatingType.Score
|
RatingType = RatingType.Score
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return list;
|
var language = _config.Configuration.PreferredMetadataLanguage;
|
||||||
|
|
||||||
|
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
return list.OrderByDescending(i =>
|
||||||
|
{
|
||||||
|
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (!isLanguageEn)
|
||||||
|
{
|
||||||
|
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(i.Language))
|
||||||
|
{
|
||||||
|
return isLanguageEn ? 3 : 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
.ThenByDescending(i => i.CommunityRating ?? 0)
|
||||||
|
.ThenByDescending(i => i.VoteCount ?? 0)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -100,35 +125,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
{
|
{
|
||||||
var language = _config.Configuration.PreferredMetadataLanguage;
|
var language = _config.Configuration.PreferredMetadataLanguage;
|
||||||
|
|
||||||
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
|
return images.posters ?? new List<MovieDbProvider.Poster>();
|
||||||
|
|
||||||
var eligiblePosters = images.posters == null ?
|
|
||||||
new List<MovieDbProvider.Poster>() :
|
|
||||||
images.posters
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
return eligiblePosters.OrderByDescending(i =>
|
|
||||||
{
|
|
||||||
if (string.Equals(language, i.iso_639_1, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
if (!isLanguageEn)
|
|
||||||
{
|
|
||||||
if (string.Equals("en", i.iso_639_1, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(i.iso_639_1))
|
|
||||||
{
|
|
||||||
return isLanguageEn ? 3 : 2;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
})
|
|
||||||
.ThenByDescending(i => i.vote_average)
|
|
||||||
.ThenByDescending(i => i.vote_count)
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -0,0 +1,133 @@
|
|||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Providers;
|
||||||
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Providers.Movies
|
||||||
|
{
|
||||||
|
public class ManualMovieDbPersonImageProvider : IImageProvider
|
||||||
|
{
|
||||||
|
private readonly IServerConfigurationManager _config;
|
||||||
|
private readonly IJsonSerializer _jsonSerializer;
|
||||||
|
|
||||||
|
public ManualMovieDbPersonImageProvider(IServerConfigurationManager config, IJsonSerializer jsonSerializer)
|
||||||
|
{
|
||||||
|
_config = config;
|
||||||
|
_jsonSerializer = jsonSerializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return ProviderName; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ProviderName
|
||||||
|
{
|
||||||
|
get { return "TheMovieDb"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Supports(BaseItem item)
|
||||||
|
{
|
||||||
|
return item is Person;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, ImageType imageType, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var images = await GetAllImages(item, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return images.Where(i => i.Type == imageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RemoteImageInfo>> GetAllImages(BaseItem item, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var id = item.GetProviderId(MetadataProviders.Tmdb);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(id))
|
||||||
|
{
|
||||||
|
var dataFilePath = MovieDbPersonProvider.GetPersonDataFilePath(_config.ApplicationPaths, id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = _jsonSerializer.DeserializeFromFile<MovieDbPersonProvider.PersonResult>(dataFilePath);
|
||||||
|
|
||||||
|
var images = result.images ?? new MovieDbPersonProvider.Images();
|
||||||
|
|
||||||
|
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var tmdbImageUrl = tmdbSettings.images.base_url + "original";
|
||||||
|
|
||||||
|
return GetImages(images, tmdbImageUrl);
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new List<RemoteImageInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<RemoteImageInfo> GetImages(MovieDbPersonProvider.Images images, string baseImageUrl)
|
||||||
|
{
|
||||||
|
var list = new List<RemoteImageInfo>();
|
||||||
|
|
||||||
|
if (images.profiles != null)
|
||||||
|
{
|
||||||
|
list.AddRange(images.profiles.Select(i => new RemoteImageInfo
|
||||||
|
{
|
||||||
|
ProviderName = Name,
|
||||||
|
Type = ImageType.Primary,
|
||||||
|
Width = i.width,
|
||||||
|
Height = i.height,
|
||||||
|
Language = GetLanguage(i),
|
||||||
|
Url = baseImageUrl + i.file_path
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
var language = _config.Configuration.PreferredMetadataLanguage;
|
||||||
|
|
||||||
|
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
return list.OrderByDescending(i =>
|
||||||
|
{
|
||||||
|
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (!isLanguageEn)
|
||||||
|
{
|
||||||
|
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(i.Language))
|
||||||
|
{
|
||||||
|
return isLanguageEn ? 3 : 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
.ThenByDescending(i => i.CommunityRating ?? 0)
|
||||||
|
.ThenByDescending(i => i.VoteCount ?? 0)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetLanguage(MovieDbPersonProvider.Profile profile)
|
||||||
|
{
|
||||||
|
return profile.iso_639_1 == null ? null : profile.iso_639_1.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Priority
|
||||||
|
{
|
||||||
|
get { return 0; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -166,14 +166,9 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var id = item.GetProviderId(MetadataProviders.Tmdb);
|
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbImageProvider.ProviderName).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(id))
|
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
|
||||||
{
|
|
||||||
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbImageProvider.ProviderName).ConfigureAwait(false);
|
|
||||||
|
|
||||||
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLastRefreshed(item, DateTime.UtcNow);
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
return true;
|
return true;
|
||||||
|
209
MediaBrowser.Providers/Movies/MovieDbPersonImageProvider.cs
Normal file
209
MediaBrowser.Providers/Movies/MovieDbPersonImageProvider.cs
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
using MediaBrowser.Common.IO;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Model.Providers;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Providers.Movies
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class MovieDbPersonImageProvider.
|
||||||
|
/// </summary>
|
||||||
|
public class MovieDbPersonImageProvider : BaseMetadataProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The _provider manager
|
||||||
|
/// </summary>
|
||||||
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="MediaBrowser.Providers.Movies.MovieDbImagesProvider"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logManager">The log manager.</param>
|
||||||
|
/// <param name="configurationManager">The configuration manager.</param>
|
||||||
|
/// <param name="providerManager">The provider manager.</param>
|
||||||
|
public MovieDbPersonImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IFileSystem fileSystem)
|
||||||
|
: base(logManager, configurationManager)
|
||||||
|
{
|
||||||
|
_providerManager = providerManager;
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the priority.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The priority.</value>
|
||||||
|
public override MetadataProviderPriority Priority
|
||||||
|
{
|
||||||
|
get { return MetadataProviderPriority.Third; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Supports 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 Person;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ItemUpdateType ItemUpdateType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ItemUpdateType.ImageUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether [requires internet].
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if [requires internet]; otherwise, <c>false</c>.</value>
|
||||||
|
public override bool RequiresInternet
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether [refresh on version change].
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if [refresh on version change]; otherwise, <c>false</c>.</value>
|
||||||
|
protected override bool RefreshOnVersionChange
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the provider version.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The provider version.</value>
|
||||||
|
protected override string ProviderVersion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "3";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Needses the refresh internal.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="providerInfo">The provider info.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||||
|
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tmdb)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't refresh if we already have both poster and backdrop and we're not refreshing images
|
||||||
|
if (item.HasImage(ImageType.Primary))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.NeedsRefreshInternal(item, providerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Needses the refresh based on compare date.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="providerInfo">The provider info.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||||
|
protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
|
{
|
||||||
|
var provderId = item.GetProviderId(MetadataProviders.Tmdb);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(provderId))
|
||||||
|
{
|
||||||
|
// Process images
|
||||||
|
var path = MovieDbPersonProvider.GetPersonDataFilePath(ConfigurationManager.ApplicationPaths, provderId);
|
||||||
|
|
||||||
|
var fileInfo = new FileInfo(path);
|
||||||
|
|
||||||
|
if (fileInfo.Exists)
|
||||||
|
{
|
||||||
|
return _fileSystem.GetLastWriteTimeUtc(fileInfo) > providerInfo.LastRefreshed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token</param>
|
||||||
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
|
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbPersonImageProvider.ProviderName).ConfigureAwait(false);
|
||||||
|
|
||||||
|
await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the images.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="images">The images.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
private async Task ProcessImages(BaseItem item, List<RemoteImageInfo> images, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var eligiblePosters = images
|
||||||
|
.Where(i => i.Type == ImageType.Primary)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// poster
|
||||||
|
if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary))
|
||||||
|
{
|
||||||
|
var poster = eligiblePosters[0];
|
||||||
|
|
||||||
|
var url = poster.Url;
|
||||||
|
|
||||||
|
var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||||
|
{
|
||||||
|
Url = url,
|
||||||
|
CancellationToken = cancellationToken
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
|
await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(url), ImageType.Primary, null, url, cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,16 +23,16 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class TmdbPersonProvider
|
/// Class TmdbPersonProvider
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TmdbPersonProvider : BaseMetadataProvider
|
public class MovieDbPersonProvider : BaseMetadataProvider
|
||||||
{
|
{
|
||||||
protected readonly IProviderManager ProviderManager;
|
protected readonly IProviderManager ProviderManager;
|
||||||
|
|
||||||
internal static TmdbPersonProvider Current { get; private set; }
|
internal static MovieDbPersonProvider Current { get; private set; }
|
||||||
|
|
||||||
const string DataFileName = "info.json";
|
const string DataFileName = "info.json";
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
public TmdbPersonProvider(IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IFileSystem fileSystem)
|
public MovieDbPersonProvider(IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IFileSystem fileSystem)
|
||||||
: base(logManager, configurationManager)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
if (jsonSerializer == null)
|
if (jsonSerializer == null)
|
||||||
@ -125,6 +125,15 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
return seriesDataPath;
|
return seriesDataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string GetPersonDataFilePath(IApplicationPaths appPaths, string tmdbId)
|
||||||
|
{
|
||||||
|
var letter = tmdbId.GetMD5().ToString().Substring(0, 1);
|
||||||
|
|
||||||
|
var seriesDataPath = Path.Combine(GetPersonsDataPath(appPaths), letter, tmdbId);
|
||||||
|
|
||||||
|
return Path.Combine(seriesDataPath, DataFileName);
|
||||||
|
}
|
||||||
|
|
||||||
internal static string GetPersonsDataPath(IApplicationPaths appPaths)
|
internal static string GetPersonsDataPath(IApplicationPaths appPaths)
|
||||||
{
|
{
|
||||||
var dataPath = Path.Combine(appPaths.DataPath, "tmdb-people");
|
var dataPath = Path.Combine(appPaths.DataPath, "tmdb-people");
|
||||||
@ -231,20 +240,18 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task FetchInfo(Person person, string id, bool isForcedRefresh, CancellationToken cancellationToken)
|
private async Task FetchInfo(Person person, string id, bool isForcedRefresh, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var personDataPath = GetPersonDataPath(ConfigurationManager.ApplicationPaths, id);
|
var dataFilePath = GetPersonDataFilePath(ConfigurationManager.ApplicationPaths, id);
|
||||||
|
|
||||||
var file = Path.Combine(personDataPath, DataFileName);
|
|
||||||
|
|
||||||
// Only download if not already there
|
// Only download if not already there
|
||||||
// The prescan task will take care of updates so we don't need to re-download here
|
// The prescan task will take care of updates so we don't need to re-download here
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(dataFilePath))
|
||||||
{
|
{
|
||||||
await DownloadPersonInfo(id, cancellationToken).ConfigureAwait(false);
|
await DownloadPersonInfo(id, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isForcedRefresh || ConfigurationManager.Configuration.EnableTmdbUpdates || !HasAltMeta(person))
|
if (isForcedRefresh || ConfigurationManager.Configuration.EnableTmdbUpdates || !HasAltMeta(person))
|
||||||
{
|
{
|
||||||
var info = JsonSerializer.DeserializeFromFile<PersonResult>(Path.Combine(personDataPath, DataFileName));
|
var info = JsonSerializer.DeserializeFromFile<PersonResult>(dataFilePath);
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -398,7 +405,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class PersonSearchResult
|
/// Class PersonSearchResult
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected class PersonSearchResult
|
public class PersonSearchResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether this <see cref="PersonSearchResult" /> is adult.
|
/// Gets or sets a value indicating whether this <see cref="PersonSearchResult" /> is adult.
|
||||||
@ -425,7 +432,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class PersonSearchResults
|
/// Class PersonSearchResults
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected class PersonSearchResults
|
public class PersonSearchResults
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the page.
|
/// Gets or sets the page.
|
||||||
@ -449,7 +456,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
public int Total_Results { get; set; }
|
public int Total_Results { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Cast
|
public class Cast
|
||||||
{
|
{
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
@ -460,7 +467,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
public bool adult { get; set; }
|
public bool adult { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Crew
|
public class Crew
|
||||||
{
|
{
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
@ -472,13 +479,13 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
public bool adult { get; set; }
|
public bool adult { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Credits
|
public class Credits
|
||||||
{
|
{
|
||||||
public List<Cast> cast { get; set; }
|
public List<Cast> cast { get; set; }
|
||||||
public List<Crew> crew { get; set; }
|
public List<Crew> crew { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Profile
|
public class Profile
|
||||||
{
|
{
|
||||||
public string file_path { get; set; }
|
public string file_path { get; set; }
|
||||||
public int width { get; set; }
|
public int width { get; set; }
|
||||||
@ -487,12 +494,12 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
public double aspect_ratio { get; set; }
|
public double aspect_ratio { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Images
|
public class Images
|
||||||
{
|
{
|
||||||
public List<Profile> profiles { get; set; }
|
public List<Profile> profiles { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class PersonResult
|
public class PersonResult
|
||||||
{
|
{
|
||||||
public bool adult { get; set; }
|
public bool adult { get; set; }
|
||||||
public List<object> also_known_as { get; set; }
|
public List<object> also_known_as { get; set; }
|
@ -68,7 +68,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = TmdbPersonProvider.GetPersonsDataPath(_config.CommonApplicationPaths);
|
var path = MovieDbPersonProvider.GetPersonsDataPath(_config.CommonApplicationPaths);
|
||||||
|
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
{
|
{
|
||||||
_logger.Info("Updating person from tmdb " + id);
|
_logger.Info("Updating person from tmdb " + id);
|
||||||
|
|
||||||
return TmdbPersonProvider.Current.DownloadPersonInfo(id, cancellationToken);
|
return MovieDbPersonProvider.Current.DownloadPersonInfo(id, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Result
|
class Result
|
||||||
|
@ -186,7 +186,7 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
public int Priority
|
public int Priority
|
||||||
{
|
{
|
||||||
get { return 1; }
|
get { return 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
public override MetadataProviderPriority Priority
|
public override MetadataProviderPriority Priority
|
||||||
{
|
{
|
||||||
get { return MetadataProviderPriority.Third; }
|
get { return MetadataProviderPriority.Fourth; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user