mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
fix images saving with incorrect paths.
This commit is contained in:
parent
c997effcb1
commit
77cff18dce
@ -145,6 +145,11 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
|
protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tmdb)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var path = MovieDbProvider.Current.GetDataFilePath(item, "default");
|
var path = MovieDbProvider.Current.GetDataFilePath(item, "default");
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
@ -169,14 +174,19 @@ 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 images = FetchImages(item, item.GetProviderId(MetadataProviders.Tmdb), cancellationToken);
|
var id = item.GetProviderId(MetadataProviders.Tmdb);
|
||||||
|
|
||||||
var status = ProviderRefreshStatus.Success;
|
var status = ProviderRefreshStatus.Success;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(id))
|
||||||
|
{
|
||||||
|
var images = FetchImages(item);
|
||||||
|
|
||||||
if (images != null)
|
if (images != null)
|
||||||
{
|
{
|
||||||
status = await ProcessImages(item, images, cancellationToken).ConfigureAwait(false);
|
status = await ProcessImages(item, images, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetLastRefreshed(item, DateTime.UtcNow, status);
|
SetLastRefreshed(item, DateTime.UtcNow, status);
|
||||||
return true;
|
return true;
|
||||||
@ -186,10 +196,8 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// Fetches the images.
|
/// Fetches the images.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="id">The id.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task{MovieImages}.</returns>
|
/// <returns>Task{MovieImages}.</returns>
|
||||||
private MovieDbProvider.Images FetchImages(BaseItem item, string id, CancellationToken cancellationToken)
|
private MovieDbProvider.Images FetchImages(BaseItem item)
|
||||||
{
|
{
|
||||||
var path = MovieDbProvider.Current.GetDataFilePath(item, "default");
|
var path = MovieDbProvider.Current.GetDataFilePath(item, "default");
|
||||||
|
|
||||||
|
@ -194,9 +194,6 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
{
|
{
|
||||||
if (HasAltMeta(item) && !ConfigurationManager.Configuration.EnableTmdbUpdates)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Boxsets require two passes because we need the children to be refreshed
|
// Boxsets require two passes because we need the children to be refreshed
|
||||||
if (item is BoxSet && string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tmdb)))
|
if (item is BoxSet && string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tmdb)))
|
||||||
{
|
{
|
||||||
@ -220,6 +217,8 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
{
|
{
|
||||||
return fileInfo.LastWriteTimeUtc > providerInfo.LastRefreshed;
|
return fileInfo.LastWriteTimeUtc > providerInfo.LastRefreshed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.NeedsRefreshBasedOnCompareDate(item, providerInfo);
|
return base.NeedsRefreshBasedOnCompareDate(item, providerInfo);
|
||||||
@ -507,8 +506,6 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
var dataFilePath = GetDataFilePath(item, language);
|
var dataFilePath = GetDataFilePath(item, language);
|
||||||
|
|
||||||
var hasAltMeta = HasAltMeta(item);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(dataFilePath) || !File.Exists(dataFilePath))
|
if (string.IsNullOrEmpty(dataFilePath) || !File.Exists(dataFilePath))
|
||||||
{
|
{
|
||||||
var isBoxSet = item is BoxSet;
|
var isBoxSet = item is BoxSet;
|
||||||
@ -535,7 +532,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
JsonSerializer.SerializeToFile(mainResult, dataFilePath);
|
JsonSerializer.SerializeToFile(mainResult, dataFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isForcedRefresh || ConfigurationManager.Configuration.EnableTmdbUpdates || !hasAltMeta)
|
if (isForcedRefresh || ConfigurationManager.Configuration.EnableTmdbUpdates || !HasAltMeta(item))
|
||||||
{
|
{
|
||||||
dataFilePath = GetDataFilePath(item, language);
|
dataFilePath = GetDataFilePath(item, language);
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Net;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -83,7 +82,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
// Find out the last time we queried tvdb for updates
|
// Find out the last time we queried tvdb for updates
|
||||||
var lastUpdateTime = timestampFileInfo.Exists ? File.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty;
|
var lastUpdateTime = timestampFileInfo.Exists ? File.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty;
|
||||||
|
|
||||||
var existingDirectories = Directory.EnumerateDirectories(path).Select(Path.GetFileName).ToList();
|
var existingDirectories = GetExistingIds(path).ToList();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(lastUpdateTime))
|
if (!string.IsNullOrEmpty(lastUpdateTime))
|
||||||
{
|
{
|
||||||
@ -105,7 +104,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
var idsToUpdate = updatedIds.Where(i => !string.IsNullOrWhiteSpace(i) && existingDictionary.ContainsKey(i));
|
var idsToUpdate = updatedIds.Where(i => !string.IsNullOrWhiteSpace(i) && existingDictionary.ContainsKey(i));
|
||||||
|
|
||||||
await UpdatePeople(idsToUpdate, path, progress, cancellationToken).ConfigureAwait(false);
|
await UpdatePeople(idsToUpdate, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +112,18 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the existing ids.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <returns>IEnumerable{System.String}.</returns>
|
||||||
|
private IEnumerable<string> GetExistingIds(string path)
|
||||||
|
{
|
||||||
|
return Directory.EnumerateDirectories(path)
|
||||||
|
.SelectMany(Directory.EnumerateDirectories)
|
||||||
|
.Select(Path.GetFileNameWithoutExtension);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the ids to update.
|
/// Gets the ids to update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -159,11 +170,10 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// Updates the people.
|
/// Updates the people.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ids">The ids.</param>
|
/// <param name="ids">The ids.</param>
|
||||||
/// <param name="peopleDataPath">The people data path.</param>
|
|
||||||
/// <param name="progress">The progress.</param>
|
/// <param name="progress">The progress.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task UpdatePeople(IEnumerable<string> ids, string peopleDataPath, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task UpdatePeople(IEnumerable<string> ids, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var list = ids.ToList();
|
var list = ids.ToList();
|
||||||
var numComplete = 0;
|
var numComplete = 0;
|
||||||
@ -172,7 +182,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await UpdatePerson(id, peopleDataPath, cancellationToken).ConfigureAwait(false);
|
await UpdatePerson(id, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -192,18 +202,13 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
/// Updates the person.
|
/// Updates the person.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The id.</param>
|
/// <param name="id">The id.</param>
|
||||||
/// <param name="peopleDataPath">The people data path.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private Task UpdatePerson(string id, string peopleDataPath, CancellationToken cancellationToken)
|
private Task UpdatePerson(string id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_logger.Info("Updating person from tmdb " + id);
|
_logger.Info("Updating person from tmdb " + id);
|
||||||
|
|
||||||
var personDataPath = Path.Combine(peopleDataPath, id);
|
return TmdbPersonProvider.Current.DownloadPersonInfo(id, cancellationToken);
|
||||||
|
|
||||||
Directory.CreateDirectory(peopleDataPath);
|
|
||||||
|
|
||||||
return TmdbPersonProvider.Current.DownloadPersonInfo(id, personDataPath, cancellationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Result
|
class Result
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
@ -28,6 +29,8 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
internal static TmdbPersonProvider Current { get; private set; }
|
internal static TmdbPersonProvider Current { get; private set; }
|
||||||
|
|
||||||
|
const string DataFileName = "info.json";
|
||||||
|
|
||||||
public TmdbPersonProvider(IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
public TmdbPersonProvider(IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
|
||||||
: base(logManager, configurationManager)
|
: base(logManager, configurationManager)
|
||||||
{
|
{
|
||||||
@ -68,7 +71,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "2";
|
return "3";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,31 +100,25 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
// Process images
|
// Process images
|
||||||
var path = GetPersonDataPath(ConfigurationManager.ApplicationPaths, provderId);
|
var path = GetPersonDataPath(ConfigurationManager.ApplicationPaths, provderId);
|
||||||
|
|
||||||
try
|
var file = Path.Combine(path, DataFileName);
|
||||||
{
|
var fileInfo = new FileInfo(file);
|
||||||
var files = new DirectoryInfo(path)
|
|
||||||
.EnumerateFiles("*.json", SearchOption.TopDirectoryOnly)
|
|
||||||
.Select(i => i.LastWriteTimeUtc)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (files.Count > 0)
|
if (fileInfo.Exists)
|
||||||
{
|
{
|
||||||
return files.Max() > providerInfo.LastRefreshed;
|
return fileInfo.LastWriteTimeUtc > providerInfo.LastRefreshed;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (DirectoryNotFoundException)
|
|
||||||
{
|
|
||||||
// Don't blow up
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return base.NeedsRefreshBasedOnCompareDate(item, providerInfo);
|
return base.NeedsRefreshBasedOnCompareDate(item, providerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetPersonDataPath(IApplicationPaths appPaths, string tmdbId)
|
internal static string GetPersonDataPath(IApplicationPaths appPaths, string tmdbId)
|
||||||
{
|
{
|
||||||
var seriesDataPath = Path.Combine(GetPersonsDataPath(appPaths), tmdbId);
|
var letter = tmdbId.GetMD5().ToString().Substring(0, 1);
|
||||||
|
|
||||||
|
var seriesDataPath = Path.Combine(GetPersonsDataPath(appPaths), letter, tmdbId);
|
||||||
|
|
||||||
return seriesDataPath;
|
return seriesDataPath;
|
||||||
}
|
}
|
||||||
@ -240,18 +237,16 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
.Select(Path.GetFileName)
|
.Select(Path.GetFileName)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
const string dataFileName = "info.json";
|
|
||||||
|
|
||||||
// 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 (!files.Contains(dataFileName, StringComparer.OrdinalIgnoreCase))
|
if (!files.Contains(DataFileName, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
await DownloadPersonInfo(id, personDataPath, 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>(Path.Combine(personDataPath, DataFileName));
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -263,8 +258,10 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task DownloadPersonInfo(string id, string personDataPath, CancellationToken cancellationToken)
|
internal async Task DownloadPersonInfo(string id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
var personDataPath = GetPersonDataPath(ConfigurationManager.ApplicationPaths, id);
|
||||||
|
|
||||||
var url = string.Format(@"http://api.themoviedb.org/3/person/{1}?api_key={0}&append_to_response=credits,images", MovieDbProvider.ApiKey, id);
|
var url = string.Format(@"http://api.themoviedb.org/3/person/{1}?api_key={0}&append_to_response=credits,images", MovieDbProvider.ApiKey, id);
|
||||||
|
|
||||||
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||||
@ -275,7 +272,9 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
}).ConfigureAwait(false))
|
}).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
using (var fs = new FileStream(Path.Combine(personDataPath, "info.json"), FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, true))
|
Directory.CreateDirectory(personDataPath);
|
||||||
|
|
||||||
|
using (var fs = new FileStream(Path.Combine(personDataPath, DataFileName), FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, true))
|
||||||
{
|
{
|
||||||
await json.CopyToAsync(fs).ConfigureAwait(false);
|
await json.CopyToAsync(fs).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -362,6 +362,8 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||||||
extension = "jpg";
|
extension = "jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension = "." + extension.ToLower();
|
||||||
|
|
||||||
string path = null;
|
string path = null;
|
||||||
|
|
||||||
if (saveLocally)
|
if (saveLocally)
|
||||||
@ -373,16 +375,14 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(item.MetaLocation))
|
if (string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(item.MetaLocation))
|
||||||
{
|
{
|
||||||
path = Path.Combine(item.MetaLocation, filename + extension.ToLower());
|
path = Path.Combine(item.MetaLocation, filename + extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filename += "." + extension.ToLower();
|
|
||||||
|
|
||||||
// None of the save local conditions passed, so store it in our internal folders
|
// None of the save local conditions passed, so store it in our internal folders
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
path = _remoteImageCache.GetResourcePath(item.GetType().FullName + item.Id, filename);
|
path = _remoteImageCache.GetResourcePath(item.GetType().FullName + item.Id, filename + extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
Loading…
Reference in New Issue
Block a user