mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-02 22:08:27 +01:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
This commit is contained in:
@@ -361,7 +361,33 @@ namespace MediaBrowser.Server.Implementations.IO
|
||||
if (e.ChangeType == WatcherChangeTypes.Changed)
|
||||
{
|
||||
// If the parent of an ignored path has a change event, ignore that too
|
||||
if (tempIgnorePaths.Any(i => string.Equals(Path.GetDirectoryName(i), e.FullPath, StringComparison.OrdinalIgnoreCase) || string.Equals(i, e.FullPath, StringComparison.OrdinalIgnoreCase)))
|
||||
if (tempIgnorePaths.Any(i =>
|
||||
{
|
||||
if (string.Equals(i, e.FullPath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Go up a level
|
||||
var parent = Path.GetDirectoryName(i);
|
||||
if (string.Equals(parent, e.FullPath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Go up another level
|
||||
if (!string.IsNullOrEmpty(parent))
|
||||
{
|
||||
parent = Path.GetDirectoryName(i);
|
||||
if (string.Equals(parent, e.FullPath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.MediaInfo;
|
||||
using MediaBrowser.Controller.IO;
|
||||
@@ -602,6 +602,8 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||
return "-sub_charenc windows-1251";
|
||||
case "vie":
|
||||
return "-sub_charenc windows-1258";
|
||||
case "kor":
|
||||
return "-sub_charenc cp949";
|
||||
default:
|
||||
return "-sub_charenc windows-1252";
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -128,15 +128,18 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
/// Connects to db.
|
||||
/// </summary>
|
||||
/// <param name="dbPath">The db path.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <returns>Task{IDbConnection}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">dbPath</exception>
|
||||
public static async Task<IDbConnection> ConnectToDb(string dbPath)
|
||||
public static async Task<IDbConnection> ConnectToDb(string dbPath, ILogger logger)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dbPath))
|
||||
{
|
||||
throw new ArgumentNullException("dbPath");
|
||||
}
|
||||
|
||||
logger.Info("Opening {0}", dbPath);
|
||||
|
||||
#if __MonoCS__
|
||||
var connectionstr = new SqliteConnectionStringBuilder
|
||||
{
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
|
||||
var chapterDbFile = Path.Combine(_appPaths.DataPath, "chapters.db");
|
||||
|
||||
var chapterConnection = SqliteExtensions.ConnectToDb(chapterDbFile).Result;
|
||||
var chapterConnection = SqliteExtensions.ConnectToDb(chapterDbFile, _logger).Result;
|
||||
|
||||
_chapterRepository = new SqliteChapterRepository(chapterConnection, logManager);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "library.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "notifications.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "userdata_v2.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
{
|
||||
var dbFile = Path.Combine(_appPaths.DataPath, "users.db");
|
||||
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
|
||||
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -69,11 +70,11 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
throw new ArgumentNullException("mimeType");
|
||||
}
|
||||
|
||||
var saveLocally = _config.Configuration.SaveLocalMeta || item is IItemByName || item is User;
|
||||
var saveLocally = _config.Configuration.SaveLocalMeta && item.Parent != null && !(item is Audio);
|
||||
|
||||
if (item is Audio || item.Parent == null)
|
||||
if (item is IItemByName || item is User)
|
||||
{
|
||||
saveLocally = false;
|
||||
saveLocally = true;
|
||||
}
|
||||
|
||||
if (type != ImageType.Primary && item is Episode)
|
||||
@@ -268,7 +269,7 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
{
|
||||
item.ScreenshotImagePaths[imageIndex.Value] = path;
|
||||
}
|
||||
else
|
||||
else if (!item.ScreenshotImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
item.ScreenshotImagePaths.Add(path);
|
||||
}
|
||||
@@ -282,7 +283,7 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
{
|
||||
item.BackdropImagePaths[imageIndex.Value] = path;
|
||||
}
|
||||
else
|
||||
else if (!item.BackdropImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
item.BackdropImagePaths.Add(path);
|
||||
}
|
||||
@@ -333,14 +334,14 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
{
|
||||
throw new ArgumentNullException("imageIndex");
|
||||
}
|
||||
filename = imageIndex.Value == 0 ? "backdrop" : "backdrop" + imageIndex.Value.ToString(UsCulture);
|
||||
filename = GetBackdropSaveFilename(item.BackdropImagePaths, "backdrop", "backdrop", imageIndex.Value);
|
||||
break;
|
||||
case ImageType.Screenshot:
|
||||
if (!imageIndex.HasValue)
|
||||
{
|
||||
throw new ArgumentNullException("imageIndex");
|
||||
}
|
||||
filename = imageIndex.Value == 0 ? "screenshot" : "screenshot" + imageIndex.Value.ToString(UsCulture);
|
||||
filename = GetBackdropSaveFilename(item.ScreenshotImagePaths, "screenshot", "screenshot", imageIndex.Value);
|
||||
break;
|
||||
default:
|
||||
filename = type.ToString().ToLower();
|
||||
@@ -380,6 +381,24 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
return path;
|
||||
}
|
||||
|
||||
private string GetBackdropSaveFilename(List<string> images, string zeroIndexFilename, string numberedIndexPrefix, int index)
|
||||
{
|
||||
var filesnames = images.Select(Path.GetFileNameWithoutExtension).ToList();
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
return zeroIndexFilename;
|
||||
}
|
||||
|
||||
var current = index;
|
||||
while (filesnames.Contains(numberedIndexPrefix + current.ToString(UsCulture), StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
|
||||
return numberedIndexPrefix + current.ToString(UsCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the compatible save paths.
|
||||
/// </summary>
|
||||
|
||||
@@ -7,13 +7,13 @@ 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;
|
||||
using MediaBrowser.Model.Providers;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Providers
|
||||
{
|
||||
@@ -77,7 +77,7 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
{
|
||||
MetadataProviders = providers.OrderBy(e => e.Priority).ToArray();
|
||||
|
||||
ImageProviders = imageProviders.ToArray();
|
||||
ImageProviders = imageProviders.OrderByDescending(i => i.Priority).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -356,52 +356,79 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
/// Gets the available remote images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="providerName">Name of the provider.</param>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(BaseItem item, ImageType type, CancellationToken cancellationToken)
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(BaseItem item, CancellationToken cancellationToken, string providerName = null, ImageType? type = null)
|
||||
{
|
||||
var providers = GetSupportedImageProviders(item, type);
|
||||
var providers = GetImageProviders(item);
|
||||
|
||||
if (!string.IsNullOrEmpty(providerName))
|
||||
{
|
||||
providers = providers.Where(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
var preferredLanguage = ConfigurationManager.Configuration.PreferredMetadataLanguage;
|
||||
|
||||
var tasks = providers.Select(i => Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await i.GetAvailableImages(item, type, cancellationToken).ConfigureAwait(false);
|
||||
return result.ToList();
|
||||
if (type.HasValue)
|
||||
{
|
||||
var result = await i.GetImages(item, type.Value, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return FilterImages(result, preferredLanguage);
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await i.GetAllImages(item, cancellationToken).ConfigureAwait(false);
|
||||
return FilterImages(result, preferredLanguage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("{0} failed in GetAvailableImages for type {1}", ex, i.GetType().Name, item.GetType().Name);
|
||||
_logger.ErrorException("{0} failed in GetImages for type {1}", ex, i.GetType().Name, item.GetType().Name);
|
||||
return new List<RemoteImageInfo>();
|
||||
}
|
||||
}));
|
||||
|
||||
}, cancellationToken));
|
||||
|
||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
return results.SelectMany(i => i);
|
||||
}
|
||||
|
||||
private IEnumerable<RemoteImageInfo> FilterImages(IEnumerable<RemoteImageInfo> images, string preferredLanguage)
|
||||
{
|
||||
if (string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
images = images.Where(i => string.IsNullOrEmpty(i.Language) ||
|
||||
string.Equals(i.Language, "en", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the supported image providers.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>IEnumerable{IImageProvider}.</returns>
|
||||
private IEnumerable<IImageProvider> GetSupportedImageProviders(BaseItem item, ImageType type)
|
||||
public IEnumerable<IImageProvider> GetImageProviders(BaseItem item)
|
||||
{
|
||||
return ImageProviders.Where(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return i.Supports(item, type);
|
||||
return i.Supports(item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("{0} failed in Supports for type {1}", ex, i.GetType().Name, item.GetType().Name);
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,14 @@ namespace MediaBrowser.Server.Implementations.Sorting
|
||||
|
||||
if (x.ProductionYear.HasValue)
|
||||
{
|
||||
return new DateTime(x.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
try
|
||||
{
|
||||
return new DateTime(x.ProductionYear.Value, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
// Don't blow up if the item has a bad ProductionYear, just return MinValue
|
||||
}
|
||||
}
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user