mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-18 20:24:20 +01:00
merge master into api-migration
This commit is contained in:
@@ -4,11 +4,10 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Entities;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Controller.Authentication;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Session;
|
||||
@@ -30,7 +29,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
/// </summary>
|
||||
public sealed class ActivityLogEntryPoint : IServerEntryPoint
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<ActivityLogEntryPoint> _logger;
|
||||
private readonly IInstallationManager _installationManager;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly ITaskManager _taskManager;
|
||||
@@ -38,14 +37,12 @@ namespace Emby.Server.Implementations.Activity
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly ISubtitleManager _subManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDeviceManager _deviceManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ActivityLogEntryPoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="sessionManager">The session manager.</param>
|
||||
/// <param name="deviceManager">The device manager.</param>
|
||||
/// <param name="taskManager">The task manager.</param>
|
||||
/// <param name="activityManager">The activity manager.</param>
|
||||
/// <param name="localization">The localization manager.</param>
|
||||
@@ -55,7 +52,6 @@ namespace Emby.Server.Implementations.Activity
|
||||
public ActivityLogEntryPoint(
|
||||
ILogger<ActivityLogEntryPoint> logger,
|
||||
ISessionManager sessionManager,
|
||||
IDeviceManager deviceManager,
|
||||
ITaskManager taskManager,
|
||||
IActivityManager activityManager,
|
||||
ILocalizationManager localization,
|
||||
@@ -65,7 +61,6 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
_logger = logger;
|
||||
_sessionManager = sessionManager;
|
||||
_deviceManager = deviceManager;
|
||||
_taskManager = taskManager;
|
||||
_activityManager = activityManager;
|
||||
_localization = localization;
|
||||
@@ -99,52 +94,38 @@ namespace Emby.Server.Implementations.Activity
|
||||
_userManager.UserPolicyUpdated += OnUserPolicyUpdated;
|
||||
_userManager.UserLockedOut += OnUserLockedOut;
|
||||
|
||||
_deviceManager.CameraImageUploaded += OnCameraImageUploaded;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnCameraImageUploaded(object sender, GenericEventArgs<CameraImageUploadInfo> e)
|
||||
private async void OnUserLockedOut(object sender, GenericEventArgs<MediaBrowser.Controller.Entities.User> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("CameraImageUploadedFrom"),
|
||||
e.Argument.Device.Name),
|
||||
Type = NotificationType.CameraImageUploaded.ToString()
|
||||
});
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserLockedOutWithName"),
|
||||
e.Argument.Name),
|
||||
NotificationType.UserLockedOut.ToString(),
|
||||
e.Argument.Id))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnUserLockedOut(object sender, GenericEventArgs<User> e)
|
||||
private async void OnSubtitleDownloadFailure(object sender, SubtitleDownloadFailureEventArgs e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserLockedOutWithName"),
|
||||
e.Argument.Name),
|
||||
Type = NotificationType.UserLockedOut.ToString(),
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
}
|
||||
|
||||
private void OnSubtitleDownloadFailure(object sender, SubtitleDownloadFailureEventArgs e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"),
|
||||
e.Provider,
|
||||
Emby.Notifications.NotificationEntryPoint.GetItemName(e.Item)),
|
||||
Type = "SubtitleDownloadFailure",
|
||||
Notifications.NotificationEntryPoint.GetItemName(e.Item)),
|
||||
"SubtitleDownloadFailure",
|
||||
Guid.Empty)
|
||||
{
|
||||
ItemId = e.Item.Id.ToString("N", CultureInfo.InvariantCulture),
|
||||
ShortOverview = e.Exception.Message
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPlaybackStopped(object sender, PlaybackStopEventArgs e)
|
||||
private async void OnPlaybackStopped(object sender, PlaybackStopEventArgs e)
|
||||
{
|
||||
var item = e.MediaInfo;
|
||||
|
||||
@@ -167,20 +148,19 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
var user = e.Users[0];
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserStoppedPlayingItemWithValues"),
|
||||
user.Name,
|
||||
GetItemName(item),
|
||||
e.DeviceName),
|
||||
Type = GetPlaybackStoppedNotificationType(item.MediaType),
|
||||
UserId = user.Id
|
||||
});
|
||||
GetPlaybackStoppedNotificationType(item.MediaType),
|
||||
user.Id))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPlaybackStart(object sender, PlaybackProgressEventArgs e)
|
||||
private async void OnPlaybackStart(object sender, PlaybackProgressEventArgs e)
|
||||
{
|
||||
var item = e.MediaInfo;
|
||||
|
||||
@@ -203,17 +183,16 @@ namespace Emby.Server.Implementations.Activity
|
||||
|
||||
var user = e.Users.First();
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserStartedPlayingItemWithValues"),
|
||||
user.Name,
|
||||
GetItemName(item),
|
||||
e.DeviceName),
|
||||
Type = GetPlaybackNotificationType(item.MediaType),
|
||||
UserId = user.Id
|
||||
});
|
||||
GetPlaybackNotificationType(item.MediaType),
|
||||
user.Id))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static string GetItemName(BaseItemDto item)
|
||||
@@ -263,230 +242,209 @@ namespace Emby.Server.Implementations.Activity
|
||||
return null;
|
||||
}
|
||||
|
||||
private void OnSessionEnded(object sender, SessionEventArgs e)
|
||||
private async void OnSessionEnded(object sender, SessionEventArgs e)
|
||||
{
|
||||
string name;
|
||||
var session = e.SessionInfo;
|
||||
|
||||
if (string.IsNullOrEmpty(session.UserName))
|
||||
{
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("DeviceOfflineWithName"),
|
||||
session.DeviceName);
|
||||
|
||||
// Causing too much spam for now
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = string.Format(
|
||||
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserOfflineFromDevice"),
|
||||
session.UserName,
|
||||
session.DeviceName);
|
||||
}
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
session.DeviceName),
|
||||
"SessionEnded",
|
||||
session.UserId)
|
||||
{
|
||||
Name = name,
|
||||
Type = "SessionEnded",
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
session.RemoteEndPoint),
|
||||
UserId = session.UserId
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnAuthenticationSucceeded(object sender, GenericEventArgs<AuthenticationResult> e)
|
||||
private async void OnAuthenticationSucceeded(object sender, GenericEventArgs<AuthenticationResult> e)
|
||||
{
|
||||
var user = e.Argument.User;
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("AuthenticationSucceededWithUserName"),
|
||||
user.Name),
|
||||
Type = "AuthenticationSucceeded",
|
||||
"AuthenticationSucceeded",
|
||||
user.Id)
|
||||
{
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
e.Argument.SessionInfo.RemoteEndPoint),
|
||||
UserId = user.Id
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnAuthenticationFailed(object sender, GenericEventArgs<AuthenticationRequest> e)
|
||||
private async void OnAuthenticationFailed(object sender, GenericEventArgs<AuthenticationRequest> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("FailedLoginAttemptWithUserName"),
|
||||
e.Argument.Username),
|
||||
Type = "AuthenticationFailed",
|
||||
"AuthenticationFailed",
|
||||
Guid.Empty)
|
||||
{
|
||||
LogSeverity = LogLevel.Error,
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
e.Argument.RemoteEndPoint),
|
||||
Severity = LogLevel.Error
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnUserPolicyUpdated(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserPolicyUpdated(object sender, GenericEventArgs<MediaBrowser.Controller.Entities.User> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserPolicyUpdatedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserPolicyUpdated",
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
"UserPolicyUpdated",
|
||||
e.Argument.Id))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnUserDeleted(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserDeleted(object sender, GenericEventArgs<MediaBrowser.Controller.Entities.User> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserDeletedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserDeleted"
|
||||
});
|
||||
"UserDeleted",
|
||||
Guid.Empty))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnUserPasswordChanged(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserPasswordChanged(object sender, GenericEventArgs<MediaBrowser.Controller.Entities.User> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserPasswordChangedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserPasswordChanged",
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
"UserPasswordChanged",
|
||||
e.Argument.Id))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnUserCreated(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserCreated(object sender, GenericEventArgs<MediaBrowser.Controller.Entities.User> e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserCreatedWithName"),
|
||||
e.Argument.Name),
|
||||
Type = "UserCreated",
|
||||
UserId = e.Argument.Id
|
||||
});
|
||||
"UserCreated",
|
||||
e.Argument.Id))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnSessionStarted(object sender, SessionEventArgs e)
|
||||
private async void OnSessionStarted(object sender, SessionEventArgs e)
|
||||
{
|
||||
string name;
|
||||
var session = e.SessionInfo;
|
||||
|
||||
if (string.IsNullOrEmpty(session.UserName))
|
||||
{
|
||||
name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("DeviceOnlineWithName"),
|
||||
session.DeviceName);
|
||||
|
||||
// Causing too much spam for now
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = string.Format(
|
||||
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("UserOnlineFromDevice"),
|
||||
session.UserName,
|
||||
session.DeviceName);
|
||||
}
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
session.DeviceName),
|
||||
"SessionStarted",
|
||||
session.UserId)
|
||||
{
|
||||
Name = name,
|
||||
Type = "SessionStarted",
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("LabelIpAddressValue"),
|
||||
session.RemoteEndPoint),
|
||||
UserId = session.UserId
|
||||
});
|
||||
session.RemoteEndPoint)
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPluginUpdated(object sender, GenericEventArgs<(IPlugin, VersionInfo)> e)
|
||||
private async void OnPluginUpdated(object sender, InstallationInfo e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("PluginUpdatedWithName"),
|
||||
e.Argument.Item1.Name),
|
||||
Type = NotificationType.PluginUpdateInstalled.ToString(),
|
||||
e.Name),
|
||||
NotificationType.PluginUpdateInstalled.ToString(),
|
||||
Guid.Empty)
|
||||
{
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("VersionNumber"),
|
||||
e.Argument.Item2.version),
|
||||
Overview = e.Argument.Item2.changelog
|
||||
});
|
||||
e.Version),
|
||||
Overview = e.Changelog
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPluginUninstalled(object sender, GenericEventArgs<IPlugin> e)
|
||||
private async void OnPluginUninstalled(object sender, IPlugin e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("PluginUninstalledWithName"),
|
||||
e.Argument.Name),
|
||||
Type = NotificationType.PluginUninstalled.ToString()
|
||||
});
|
||||
e.Name),
|
||||
NotificationType.PluginUninstalled.ToString(),
|
||||
Guid.Empty))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPluginInstalled(object sender, GenericEventArgs<VersionInfo> e)
|
||||
private async void OnPluginInstalled(object sender, InstallationInfo e)
|
||||
{
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("PluginInstalledWithName"),
|
||||
e.Argument.name),
|
||||
Type = NotificationType.PluginInstalled.ToString(),
|
||||
e.Name),
|
||||
NotificationType.PluginInstalled.ToString(),
|
||||
Guid.Empty)
|
||||
{
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("VersionNumber"),
|
||||
e.Argument.version)
|
||||
});
|
||||
e.Version)
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
|
||||
private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
|
||||
{
|
||||
var installationInfo = e.InstallationInfo;
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
{
|
||||
Name = string.Format(
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("NameInstallFailed"),
|
||||
installationInfo.Name),
|
||||
Type = NotificationType.InstallationFailed.ToString(),
|
||||
NotificationType.InstallationFailed.ToString(),
|
||||
Guid.Empty)
|
||||
{
|
||||
ShortOverview = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("VersionNumber"),
|
||||
installationInfo.Version),
|
||||
Overview = e.Exception.Message
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnTaskCompleted(object sender, TaskCompletionEventArgs e)
|
||||
private async void OnTaskCompleted(object sender, TaskCompletionEventArgs e)
|
||||
{
|
||||
var result = e.Result;
|
||||
var task = e.Task;
|
||||
@@ -517,22 +475,20 @@ namespace Emby.Server.Implementations.Activity
|
||||
vals.Add(e.Result.LongErrorMessage);
|
||||
}
|
||||
|
||||
CreateLogEntry(new ActivityLogEntry
|
||||
await CreateLogEntry(new ActivityLog(
|
||||
string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name),
|
||||
NotificationType.TaskFailed.ToString(),
|
||||
Guid.Empty)
|
||||
{
|
||||
Name = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
_localization.GetLocalizedString("ScheduledTaskFailedWithName"),
|
||||
task.Name),
|
||||
Type = NotificationType.TaskFailed.ToString(),
|
||||
LogSeverity = LogLevel.Error,
|
||||
Overview = string.Join(Environment.NewLine, vals),
|
||||
ShortOverview = runningTime,
|
||||
Severity = LogLevel.Error
|
||||
});
|
||||
ShortOverview = runningTime
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateLogEntry(ActivityLogEntry entry)
|
||||
=> _activityManager.Create(entry);
|
||||
private async Task CreateLogEntry(ActivityLog entry)
|
||||
=> await _activityManager.CreateAsync(entry).ConfigureAwait(false);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
@@ -559,8 +515,6 @@ namespace Emby.Server.Implementations.Activity
|
||||
_userManager.UserDeleted -= OnUserDeleted;
|
||||
_userManager.UserPolicyUpdated -= OnUserPolicyUpdated;
|
||||
_userManager.UserLockedOut -= OnUserLockedOut;
|
||||
|
||||
_deviceManager.CameraImageUploaded -= OnCameraImageUploaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -580,7 +534,7 @@ namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
int years = days / DaysInYear;
|
||||
values.Add(CreateValueString(years, "year"));
|
||||
days = days % DaysInYear;
|
||||
days %= DaysInYear;
|
||||
}
|
||||
|
||||
// Number of months
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
public class ActivityManager : IActivityManager
|
||||
{
|
||||
private readonly IActivityRepository _repo;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public ActivityManager(IActivityRepository repo, IUserManager userManager)
|
||||
{
|
||||
_repo = repo;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
|
||||
|
||||
public void Create(ActivityLogEntry entry)
|
||||
{
|
||||
entry.Date = DateTime.UtcNow;
|
||||
|
||||
_repo.Create(entry);
|
||||
|
||||
EntryCreated?.Invoke(this, new GenericEventArgs<ActivityLogEntry>(entry));
|
||||
}
|
||||
|
||||
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, bool? hasUserId, int? startIndex, int? limit)
|
||||
{
|
||||
var result = _repo.GetActivityLogEntries(minDate, hasUserId, startIndex, limit);
|
||||
|
||||
foreach (var item in result.Items)
|
||||
{
|
||||
if (item.UserId == Guid.Empty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var user = _userManager.GetUserById(item.UserId);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
var dto = _userManager.GetUserDto(user);
|
||||
item.UserPrimaryImageTag = dto.PrimaryImageTag;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit)
|
||||
{
|
||||
return GetActivityLogEntries(minDate, null, startIndex, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,317 +0,0 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Emby.Server.Implementations.Data;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SQLitePCL.pretty;
|
||||
|
||||
namespace Emby.Server.Implementations.Activity
|
||||
{
|
||||
public class ActivityRepository : BaseSqliteRepository, IActivityRepository
|
||||
{
|
||||
private const string BaseActivitySelectText = "select Id, Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity from ActivityLog";
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public ActivityRepository(ILogger<ActivityRepository> logger, IServerApplicationPaths appPaths, IFileSystem fileSystem)
|
||||
: base(logger)
|
||||
{
|
||||
DbFilePath = Path.Combine(appPaths.DataPath, "activitylog.db");
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeInternal();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error loading database file. Will reset and retry.");
|
||||
|
||||
_fileSystem.DeleteFile(DbFilePath);
|
||||
|
||||
InitializeInternal();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeInternal()
|
||||
{
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
connection.RunQueries(new[]
|
||||
{
|
||||
"create table if not exists ActivityLog (Id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Overview TEXT, ShortOverview TEXT, Type TEXT NOT NULL, ItemId TEXT, UserId TEXT, DateCreated DATETIME NOT NULL, LogSeverity TEXT NOT NULL)",
|
||||
"drop index if exists idx_ActivityLogEntries"
|
||||
});
|
||||
|
||||
TryMigrate(connection);
|
||||
}
|
||||
}
|
||||
|
||||
private void TryMigrate(ManagedConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TableExists(connection, "ActivityLogEntries"))
|
||||
{
|
||||
connection.RunQueries(new[]
|
||||
{
|
||||
"INSERT INTO ActivityLog (Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity) SELECT Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity FROM ActivityLogEntries",
|
||||
"drop table if exists ActivityLogEntries"
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error migrating activity log database");
|
||||
}
|
||||
}
|
||||
|
||||
public void Create(ActivityLogEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entry));
|
||||
}
|
||||
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
connection.RunInTransaction(
|
||||
db =>
|
||||
{
|
||||
using (var statement = db.PrepareStatement("insert into ActivityLog (Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity) values (@Name, @Overview, @ShortOverview, @Type, @ItemId, @UserId, @DateCreated, @LogSeverity)"))
|
||||
{
|
||||
statement.TryBind("@Name", entry.Name);
|
||||
|
||||
statement.TryBind("@Overview", entry.Overview);
|
||||
statement.TryBind("@ShortOverview", entry.ShortOverview);
|
||||
statement.TryBind("@Type", entry.Type);
|
||||
statement.TryBind("@ItemId", entry.ItemId);
|
||||
|
||||
if (entry.UserId.Equals(Guid.Empty))
|
||||
{
|
||||
statement.TryBindNull("@UserId");
|
||||
}
|
||||
else
|
||||
{
|
||||
statement.TryBind("@UserId", entry.UserId.ToString("N", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue());
|
||||
statement.TryBind("@LogSeverity", entry.Severity.ToString());
|
||||
|
||||
statement.MoveNext();
|
||||
}
|
||||
},
|
||||
TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(ActivityLogEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(entry));
|
||||
}
|
||||
|
||||
using (var connection = GetConnection())
|
||||
{
|
||||
connection.RunInTransaction(
|
||||
db =>
|
||||
{
|
||||
using (var statement = db.PrepareStatement("Update ActivityLog set Name=@Name,Overview=@Overview,ShortOverview=@ShortOverview,Type=@Type,ItemId=@ItemId,UserId=@UserId,DateCreated=@DateCreated,LogSeverity=@LogSeverity where Id=@Id"))
|
||||
{
|
||||
statement.TryBind("@Id", entry.Id);
|
||||
|
||||
statement.TryBind("@Name", entry.Name);
|
||||
statement.TryBind("@Overview", entry.Overview);
|
||||
statement.TryBind("@ShortOverview", entry.ShortOverview);
|
||||
statement.TryBind("@Type", entry.Type);
|
||||
statement.TryBind("@ItemId", entry.ItemId);
|
||||
|
||||
if (entry.UserId.Equals(Guid.Empty))
|
||||
{
|
||||
statement.TryBindNull("@UserId");
|
||||
}
|
||||
else
|
||||
{
|
||||
statement.TryBind("@UserId", entry.UserId.ToString("N", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue());
|
||||
statement.TryBind("@LogSeverity", entry.Severity.ToString());
|
||||
|
||||
statement.MoveNext();
|
||||
}
|
||||
},
|
||||
TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, bool? hasUserId, int? startIndex, int? limit)
|
||||
{
|
||||
var commandText = BaseActivitySelectText;
|
||||
var whereClauses = new List<string>();
|
||||
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
whereClauses.Add("DateCreated>=@DateCreated");
|
||||
}
|
||||
|
||||
if (hasUserId.HasValue)
|
||||
{
|
||||
if (hasUserId.Value)
|
||||
{
|
||||
whereClauses.Add("UserId not null");
|
||||
}
|
||||
else
|
||||
{
|
||||
whereClauses.Add("UserId is null");
|
||||
}
|
||||
}
|
||||
|
||||
var whereTextWithoutPaging = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
|
||||
if (startIndex.HasValue && startIndex.Value > 0)
|
||||
{
|
||||
var pagingWhereText = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
|
||||
whereClauses.Add(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Id NOT IN (SELECT Id FROM ActivityLog {0} ORDER BY DateCreated DESC LIMIT {1})",
|
||||
pagingWhereText,
|
||||
startIndex.Value));
|
||||
}
|
||||
|
||||
var whereText = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
" where " + string.Join(" AND ", whereClauses.ToArray());
|
||||
|
||||
commandText += whereText;
|
||||
|
||||
commandText += " ORDER BY DateCreated DESC";
|
||||
|
||||
if (limit.HasValue)
|
||||
{
|
||||
commandText += " LIMIT " + limit.Value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
var statementTexts = new[]
|
||||
{
|
||||
commandText,
|
||||
"select count (Id) from ActivityLog" + whereTextWithoutPaging
|
||||
};
|
||||
|
||||
var list = new List<ActivityLogEntry>();
|
||||
var result = new QueryResult<ActivityLogEntry>();
|
||||
|
||||
using (var connection = GetConnection(true))
|
||||
{
|
||||
connection.RunInTransaction(
|
||||
db =>
|
||||
{
|
||||
var statements = PrepareAll(db, statementTexts).ToList();
|
||||
|
||||
using (var statement = statements[0])
|
||||
{
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
|
||||
}
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
list.Add(GetEntry(row));
|
||||
}
|
||||
}
|
||||
|
||||
using (var statement = statements[1])
|
||||
{
|
||||
if (minDate.HasValue)
|
||||
{
|
||||
statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue());
|
||||
}
|
||||
|
||||
result.TotalRecordCount = statement.ExecuteQuery().SelectScalarInt().First();
|
||||
}
|
||||
},
|
||||
ReadTransactionMode);
|
||||
}
|
||||
|
||||
result.Items = list;
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ActivityLogEntry GetEntry(IReadOnlyList<IResultSetValue> reader)
|
||||
{
|
||||
var index = 0;
|
||||
|
||||
var info = new ActivityLogEntry
|
||||
{
|
||||
Id = reader[index].ToInt64()
|
||||
};
|
||||
|
||||
index++;
|
||||
if (reader[index].SQLiteType != SQLiteType.Null)
|
||||
{
|
||||
info.Name = reader[index].ToString();
|
||||
}
|
||||
|
||||
index++;
|
||||
if (reader[index].SQLiteType != SQLiteType.Null)
|
||||
{
|
||||
info.Overview = reader[index].ToString();
|
||||
}
|
||||
|
||||
index++;
|
||||
if (reader[index].SQLiteType != SQLiteType.Null)
|
||||
{
|
||||
info.ShortOverview = reader[index].ToString();
|
||||
}
|
||||
|
||||
index++;
|
||||
if (reader[index].SQLiteType != SQLiteType.Null)
|
||||
{
|
||||
info.Type = reader[index].ToString();
|
||||
}
|
||||
|
||||
index++;
|
||||
if (reader[index].SQLiteType != SQLiteType.Null)
|
||||
{
|
||||
info.ItemId = reader[index].ToString();
|
||||
}
|
||||
|
||||
index++;
|
||||
if (reader[index].SQLiteType != SQLiteType.Null)
|
||||
{
|
||||
info.UserId = new Guid(reader[index].ToString());
|
||||
}
|
||||
|
||||
index++;
|
||||
info.Date = reader[index].ReadDateTime();
|
||||
|
||||
index++;
|
||||
if (reader[index].SQLiteType != SQLiteType.Null)
|
||||
{
|
||||
info.Severity = Enum.Parse<LogLevel>(reader[index].ToString(), true);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,11 @@ namespace Emby.Server.Implementations.AppBase
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
|
||||
/// </summary>
|
||||
/// <param name="programDataPath">The program data path.</param>
|
||||
/// <param name="logDirectoryPath">The log directory path.</param>
|
||||
/// <param name="configurationDirectoryPath">The configuration directory path.</param>
|
||||
/// <param name="cacheDirectoryPath">The cache directory path.</param>
|
||||
/// <param name="webDirectoryPath">The web directory path.</param>
|
||||
protected BaseApplicationPaths(
|
||||
string programDataPath,
|
||||
string logDirectoryPath,
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||
CommonApplicationPaths = applicationPaths;
|
||||
XmlSerializer = xmlSerializer;
|
||||
_fileSystem = fileSystem;
|
||||
Logger = loggerFactory.CreateLogger(GetType().Name);
|
||||
Logger = loggerFactory.CreateLogger<BaseConfigurationManager>();
|
||||
|
||||
UpdateCachePath();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
protected ILogger Logger { get; private set; }
|
||||
protected ILogger<BaseConfigurationManager> Logger { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML serializer.
|
||||
|
||||
@@ -36,24 +36,22 @@ namespace Emby.Server.Implementations.AppBase
|
||||
configuration = Activator.CreateInstance(type);
|
||||
}
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
using var stream = new MemoryStream();
|
||||
xmlSerializer.SerializeToStream(configuration, stream);
|
||||
|
||||
// Take the object we just got and serialize it back to bytes
|
||||
var newBytes = stream.ToArray();
|
||||
|
||||
// If the file didn't exist before, or if something has changed, re-save
|
||||
if (buffer == null || !buffer.SequenceEqual(newBytes))
|
||||
{
|
||||
xmlSerializer.SerializeToStream(configuration, stream);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
// Take the object we just got and serialize it back to bytes
|
||||
var newBytes = stream.ToArray();
|
||||
|
||||
// If the file didn't exist before, or if something has changed, re-save
|
||||
if (buffer == null || !buffer.SequenceEqual(newBytes))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
// Save it after load in case we got new items
|
||||
File.WriteAllBytes(path, newBytes);
|
||||
}
|
||||
|
||||
return configuration;
|
||||
// Save it after load in case we got new items
|
||||
File.WriteAllBytes(path, newBytes);
|
||||
}
|
||||
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,10 +22,8 @@ namespace Emby.Server.Implementations.Archiving
|
||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||
public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var fileStream = File.OpenRead(sourceFile))
|
||||
{
|
||||
ExtractAll(fileStream, targetPath, overwriteExistingFiles);
|
||||
}
|
||||
using var fileStream = File.OpenRead(sourceFile);
|
||||
ExtractAll(fileStream, targetPath, overwriteExistingFiles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,70 +34,61 @@ namespace Emby.Server.Implementations.Archiving
|
||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||
public void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var reader = ReaderFactory.Open(source))
|
||||
using var reader = ReaderFactory.Open(source);
|
||||
var options = new ExtractionOptions
|
||||
{
|
||||
var options = new ExtractionOptions();
|
||||
options.ExtractFullPath = true;
|
||||
ExtractFullPath = true
|
||||
};
|
||||
|
||||
if (overwriteExistingFiles)
|
||||
{
|
||||
options.Overwrite = true;
|
||||
}
|
||||
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
if (overwriteExistingFiles)
|
||||
{
|
||||
options.Overwrite = true;
|
||||
}
|
||||
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var reader = ZipReader.Open(source))
|
||||
using var reader = ZipReader.Open(source);
|
||||
var options = new ExtractionOptions
|
||||
{
|
||||
var options = new ExtractionOptions();
|
||||
options.ExtractFullPath = true;
|
||||
ExtractFullPath = true,
|
||||
Overwrite = overwriteExistingFiles
|
||||
};
|
||||
|
||||
if (overwriteExistingFiles)
|
||||
{
|
||||
options.Overwrite = true;
|
||||
}
|
||||
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExtractAllFromGz(Stream source, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var reader = GZipReader.Open(source))
|
||||
using var reader = GZipReader.Open(source);
|
||||
var options = new ExtractionOptions
|
||||
{
|
||||
var options = new ExtractionOptions();
|
||||
options.ExtractFullPath = true;
|
||||
ExtractFullPath = true,
|
||||
Overwrite = overwriteExistingFiles
|
||||
};
|
||||
|
||||
if (overwriteExistingFiles)
|
||||
{
|
||||
options.Overwrite = true;
|
||||
}
|
||||
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExtractFirstFileFromGz(Stream source, string targetPath, string defaultFileName)
|
||||
{
|
||||
using (var reader = GZipReader.Open(source))
|
||||
using var reader = GZipReader.Open(source);
|
||||
if (reader.MoveToNextEntry())
|
||||
{
|
||||
if (reader.MoveToNextEntry())
|
||||
{
|
||||
var entry = reader.Entry;
|
||||
var entry = reader.Entry;
|
||||
|
||||
var filename = entry.Key;
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
filename = defaultFileName;
|
||||
}
|
||||
reader.WriteEntryToFile(Path.Combine(targetPath, filename));
|
||||
var filename = entry.Key;
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
filename = defaultFileName;
|
||||
}
|
||||
|
||||
reader.WriteEntryToFile(Path.Combine(targetPath, filename));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,10 +100,8 @@ namespace Emby.Server.Implementations.Archiving
|
||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||
public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var fileStream = File.OpenRead(sourceFile))
|
||||
{
|
||||
ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles);
|
||||
}
|
||||
using var fileStream = File.OpenRead(sourceFile);
|
||||
ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,21 +112,15 @@ namespace Emby.Server.Implementations.Archiving
|
||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||
public void ExtractAllFrom7z(Stream source, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var archive = SevenZipArchive.Open(source))
|
||||
using var archive = SevenZipArchive.Open(source);
|
||||
using var reader = archive.ExtractAllEntries();
|
||||
var options = new ExtractionOptions
|
||||
{
|
||||
using (var reader = archive.ExtractAllEntries())
|
||||
{
|
||||
var options = new ExtractionOptions();
|
||||
options.ExtractFullPath = true;
|
||||
ExtractFullPath = true,
|
||||
Overwrite = overwriteExistingFiles
|
||||
};
|
||||
|
||||
if (overwriteExistingFiles)
|
||||
{
|
||||
options.Overwrite = true;
|
||||
}
|
||||
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
}
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -150,10 +131,8 @@ namespace Emby.Server.Implementations.Archiving
|
||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||
public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var fileStream = File.OpenRead(sourceFile))
|
||||
{
|
||||
ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles);
|
||||
}
|
||||
using var fileStream = File.OpenRead(sourceFile);
|
||||
ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -164,21 +143,15 @@ namespace Emby.Server.Implementations.Archiving
|
||||
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
|
||||
public void ExtractAllFromTar(Stream source, string targetPath, bool overwriteExistingFiles)
|
||||
{
|
||||
using (var archive = TarArchive.Open(source))
|
||||
using var archive = TarArchive.Open(source);
|
||||
using var reader = archive.ExtractAllEntries();
|
||||
var options = new ExtractionOptions
|
||||
{
|
||||
using (var reader = archive.ExtractAllEntries())
|
||||
{
|
||||
var options = new ExtractionOptions();
|
||||
options.ExtractFullPath = true;
|
||||
ExtractFullPath = true,
|
||||
Overwrite = overwriteExistingFiles
|
||||
};
|
||||
|
||||
if (overwriteExistingFiles)
|
||||
{
|
||||
options.Overwrite = true;
|
||||
}
|
||||
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
}
|
||||
reader.WriteAllToDirectory(targetPath, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Branding;
|
||||
|
||||
namespace Emby.Server.Implementations.Branding
|
||||
{
|
||||
/// <summary>
|
||||
/// A configuration factory for <see cref="BrandingOptions"/>.
|
||||
/// </summary>
|
||||
public class BrandingConfigurationFactory : IConfigurationFactory
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||
{
|
||||
return new[]
|
||||
|
||||
@@ -33,18 +33,18 @@ namespace Emby.Server.Implementations.Browser
|
||||
/// Opens the specified URL in an external browser window. Any exceptions will be logged, but ignored.
|
||||
/// </summary>
|
||||
/// <param name="appHost">The application host.</param>
|
||||
/// <param name="url">The URL.</param>
|
||||
private static void TryOpenUrl(IServerApplicationHost appHost, string url)
|
||||
/// <param name="relativeUrl">The URL to open, relative to the server base URL.</param>
|
||||
private static void TryOpenUrl(IServerApplicationHost appHost, string relativeUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
string baseUrl = appHost.GetLocalApiUrl("localhost");
|
||||
appHost.LaunchUrl(baseUrl + url);
|
||||
appHost.LaunchUrl(baseUrl + relativeUrl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = appHost.Resolve<ILogger>();
|
||||
logger?.LogError(ex, "Failed to open browser window with URL {URL}", url);
|
||||
var logger = appHost.Resolve<ILogger<IServerApplicationHost>>();
|
||||
logger?.LogError(ex, "Failed to open browser window with URL {URL}", relativeUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
@@ -11,6 +10,9 @@ using MediaBrowser.Model.Dto;
|
||||
|
||||
namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
/// <summary>
|
||||
/// A media source provider for channels.
|
||||
/// </summary>
|
||||
public class ChannelDynamicMediaSourceProvider : IMediaSourceProvider
|
||||
{
|
||||
private readonly ChannelManager _channelManager;
|
||||
@@ -27,12 +29,9 @@ namespace Emby.Server.Implementations.Channels
|
||||
/// <inheritdoc />
|
||||
public Task<IEnumerable<MediaSourceInfo>> GetMediaSources(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
if (item.SourceType == SourceType.Channel)
|
||||
{
|
||||
return _channelManager.GetDynamicMediaSources(item, cancellationToken);
|
||||
}
|
||||
|
||||
return Task.FromResult<IEnumerable<MediaSourceInfo>>(new List<MediaSourceInfo>());
|
||||
return item.SourceType == SourceType.Channel
|
||||
? _channelManager.GetDynamicMediaSources(item, cancellationToken)
|
||||
: Task.FromResult(Enumerable.Empty<MediaSourceInfo>());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -11,22 +9,32 @@ using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
/// <summary>
|
||||
/// An image provider for channels.
|
||||
/// </summary>
|
||||
public class ChannelImageProvider : IDynamicImageProvider, IHasItemChangeMonitor
|
||||
{
|
||||
private readonly IChannelManager _channelManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="channelManager">The channel manager.</param>
|
||||
public ChannelImageProvider(IChannelManager channelManager)
|
||||
{
|
||||
_channelManager = channelManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Channel Image Provider";
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return GetChannel(item).GetSupportedChannelImages();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<DynamicImageResponse> GetImage(BaseItem item, ImageType type, CancellationToken cancellationToken)
|
||||
{
|
||||
var channel = GetChannel(item);
|
||||
@@ -34,6 +42,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return channel.GetChannelImage(type, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Channel;
|
||||
@@ -46,6 +55,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return ((ChannelManager)_channelManager).GetChannelProvider(channel);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
|
||||
{
|
||||
return GetSupportedImages(item).Any(i => !item.HasImage(i));
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -29,13 +27,16 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
/// <summary>
|
||||
/// The LiveTV channel manager.
|
||||
/// </summary>
|
||||
public class ChannelManager : IChannelManager
|
||||
{
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<ChannelManager> _logger;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
@@ -46,6 +47,18 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelManager"/> class.
|
||||
/// </summary>
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
/// <param name="dtoService">The dto service.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="config">The server configuration manager.</param>
|
||||
/// <param name="fileSystem">The filesystem.</param>
|
||||
/// <param name="userDataManager">The user data manager.</param>
|
||||
/// <param name="jsonSerializer">The JSON serializer.</param>
|
||||
/// <param name="providerManager">The provider manager.</param>
|
||||
public ChannelManager(
|
||||
IUserManager userManager,
|
||||
IDtoService dtoService,
|
||||
@@ -72,11 +85,13 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
private static TimeSpan CacheLength => TimeSpan.FromHours(3);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddParts(IEnumerable<IChannel> channels)
|
||||
{
|
||||
Channels = channels.ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool EnableMediaSourceDisplay(BaseItem item)
|
||||
{
|
||||
var internalChannel = _libraryManager.GetItemById(item.ChannelId);
|
||||
@@ -85,6 +100,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return !(channel is IDisableMediaSourceDisplay);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool CanDelete(BaseItem item)
|
||||
{
|
||||
var internalChannel = _libraryManager.GetItemById(item.ChannelId);
|
||||
@@ -93,6 +109,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return channel is ISupportsDelete supportsDelete && supportsDelete.CanDelete(item);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool EnableMediaProbe(BaseItem item)
|
||||
{
|
||||
var internalChannel = _libraryManager.GetItemById(item.ChannelId);
|
||||
@@ -101,6 +118,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return channel is ISupportsMediaProbe;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task DeleteItem(BaseItem item)
|
||||
{
|
||||
var internalChannel = _libraryManager.GetItemById(item.ChannelId);
|
||||
@@ -127,11 +145,16 @@ namespace Emby.Server.Implementations.Channels
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the installed channel IDs.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> containing installed channel IDs.</returns>
|
||||
public IEnumerable<Guid> GetInstalledChannelIds()
|
||||
{
|
||||
return GetAllChannels().Select(i => GetInternalChannelId(i.Name));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public QueryResult<Channel> GetChannelsInternal(ChannelQuery query)
|
||||
{
|
||||
var user = query.UserId.Equals(Guid.Empty)
|
||||
@@ -249,6 +272,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public QueryResult<BaseItemDto> GetChannels(ChannelQuery query)
|
||||
{
|
||||
var user = query.UserId.Equals(Guid.Empty)
|
||||
@@ -271,6 +295,12 @@ namespace Emby.Server.Implementations.Channels
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the associated channels.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
|
||||
/// <returns>The completed task.</returns>
|
||||
public async Task RefreshChannels(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var allChannelsList = GetAllChannels().ToList();
|
||||
@@ -304,14 +334,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
private Channel GetChannelEntity(IChannel channel)
|
||||
{
|
||||
var item = GetChannel(GetInternalChannelId(channel.Name));
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
item = GetChannel(channel, CancellationToken.None).Result;
|
||||
}
|
||||
|
||||
return item;
|
||||
return GetChannel(GetInternalChannelId(channel.Name)) ?? GetChannel(channel, CancellationToken.None).Result;
|
||||
}
|
||||
|
||||
private List<MediaSourceInfo> GetSavedMediaSources(BaseItem item)
|
||||
@@ -350,6 +373,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
_jsonSerializer.SerializeToFile(mediaSources, path);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<MediaSourceInfo> GetStaticMediaSources(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<MediaSourceInfo> results = GetSavedMediaSources(item);
|
||||
@@ -359,6 +383,12 @@ namespace Emby.Server.Implementations.Channels
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dynamic media sources based on the provided item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
|
||||
/// <returns>The task representing the operation to get the media sources.</returns>
|
||||
public async Task<IEnumerable<MediaSourceInfo>> GetDynamicMediaSources(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var channel = GetChannel(item.ChannelId);
|
||||
@@ -403,7 +433,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
private static MediaSourceInfo NormalizeMediaSource(BaseItem item, MediaSourceInfo info)
|
||||
{
|
||||
info.RunTimeTicks = info.RunTimeTicks ?? item.RunTimeTicks;
|
||||
info.RunTimeTicks ??= item.RunTimeTicks;
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -481,31 +511,33 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
private static string GetOfficialRating(ChannelParentalRating rating)
|
||||
{
|
||||
switch (rating)
|
||||
return rating switch
|
||||
{
|
||||
case ChannelParentalRating.Adult:
|
||||
return "XXX";
|
||||
case ChannelParentalRating.UsR:
|
||||
return "R";
|
||||
case ChannelParentalRating.UsPG13:
|
||||
return "PG-13";
|
||||
case ChannelParentalRating.UsPG:
|
||||
return "PG";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
ChannelParentalRating.Adult => "XXX",
|
||||
ChannelParentalRating.UsR => "R",
|
||||
ChannelParentalRating.UsPG13 => "PG-13",
|
||||
ChannelParentalRating.UsPG => "PG",
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a channel with the provided Guid.
|
||||
/// </summary>
|
||||
/// <param name="id">The Guid.</param>
|
||||
/// <returns>The corresponding channel.</returns>
|
||||
public Channel GetChannel(Guid id)
|
||||
{
|
||||
return _libraryManager.GetItemById(id) as Channel;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Channel GetChannel(string id)
|
||||
{
|
||||
return _libraryManager.GetItemById(id) as Channel;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ChannelFeatures[] GetAllChannelFeatures()
|
||||
{
|
||||
return _libraryManager.GetItemIds(
|
||||
@@ -516,6 +548,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
}).Select(i => GetChannelFeatures(i.ToString("N", CultureInfo.InvariantCulture))).ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ChannelFeatures GetChannelFeatures(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
@@ -529,6 +562,11 @@ namespace Emby.Server.Implementations.Channels
|
||||
return GetChannelFeaturesDto(channel, channelProvider, channelProvider.GetChannelFeatures());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the provided Guid supports external transfer.
|
||||
/// </summary>
|
||||
/// <param name="channelId">The Guid.</param>
|
||||
/// <returns>Whether or not the provided Guid supports external transfer.</returns>
|
||||
public bool SupportsExternalTransfer(Guid channelId)
|
||||
{
|
||||
var channelProvider = GetChannelProvider(channelId);
|
||||
@@ -536,6 +574,13 @@ namespace Emby.Server.Implementations.Channels
|
||||
return channelProvider.GetChannelFeatures().SupportsContentDownloading;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the provided channel's supported features.
|
||||
/// </summary>
|
||||
/// <param name="channel">The channel.</param>
|
||||
/// <param name="provider">The provider.</param>
|
||||
/// <param name="features">The features.</param>
|
||||
/// <returns>The supported features.</returns>
|
||||
public ChannelFeatures GetChannelFeaturesDto(
|
||||
Channel channel,
|
||||
IChannel provider,
|
||||
@@ -570,6 +615,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return _libraryManager.GetNewItemId("Channel " + name, typeof(Channel));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryResult<BaseItemDto>> GetLatestChannelItems(InternalItemsQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var internalResult = await GetLatestChannelItemsInternal(query, cancellationToken).ConfigureAwait(false);
|
||||
@@ -588,6 +634,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryResult<BaseItem>> GetLatestChannelItemsInternal(InternalItemsQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var channels = GetAllChannels().Where(i => i is ISupportsLatestMedia).ToArray();
|
||||
@@ -666,6 +713,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryResult<BaseItem>> GetChannelItemsInternal(InternalItemsQuery query, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
// Get the internal channel entity
|
||||
@@ -727,6 +775,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
return _libraryManager.GetItemsResult(query);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<QueryResult<BaseItemDto>> GetChannelItems(InternalItemsQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var internalResult = await GetChannelItemsInternal(query, new SimpleProgress<double>(), cancellationToken).ConfigureAwait(false);
|
||||
@@ -796,7 +845,7 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
var query = new InternalChannelItemQuery
|
||||
{
|
||||
UserId = user == null ? Guid.Empty : user.Id,
|
||||
UserId = user?.Id ?? Guid.Empty,
|
||||
SortBy = sortField,
|
||||
SortDescending = sortDescending,
|
||||
FolderId = externalFolderId
|
||||
@@ -923,60 +972,32 @@ namespace Emby.Server.Implementations.Channels
|
||||
|
||||
if (info.Type == ChannelItemType.Folder)
|
||||
{
|
||||
if (info.FolderType == ChannelFolderType.MusicAlbum)
|
||||
item = info.FolderType switch
|
||||
{
|
||||
item = GetItemById<MusicAlbum>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else if (info.FolderType == ChannelFolderType.MusicArtist)
|
||||
{
|
||||
item = GetItemById<MusicArtist>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else if (info.FolderType == ChannelFolderType.PhotoAlbum)
|
||||
{
|
||||
item = GetItemById<PhotoAlbum>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else if (info.FolderType == ChannelFolderType.Series)
|
||||
{
|
||||
item = GetItemById<Series>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else if (info.FolderType == ChannelFolderType.Season)
|
||||
{
|
||||
item = GetItemById<Season>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = GetItemById<Folder>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
ChannelFolderType.MusicAlbum => GetItemById<MusicAlbum>(info.Id, channelProvider.Name, out isNew),
|
||||
ChannelFolderType.MusicArtist => GetItemById<MusicArtist>(info.Id, channelProvider.Name, out isNew),
|
||||
ChannelFolderType.PhotoAlbum => GetItemById<PhotoAlbum>(info.Id, channelProvider.Name, out isNew),
|
||||
ChannelFolderType.Series => GetItemById<Series>(info.Id, channelProvider.Name, out isNew),
|
||||
ChannelFolderType.Season => GetItemById<Season>(info.Id, channelProvider.Name, out isNew),
|
||||
_ => GetItemById<Folder>(info.Id, channelProvider.Name, out isNew)
|
||||
};
|
||||
}
|
||||
else if (info.MediaType == ChannelMediaType.Audio)
|
||||
{
|
||||
if (info.ContentType == ChannelMediaContentType.Podcast)
|
||||
{
|
||||
item = GetItemById<AudioBook>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = GetItemById<Audio>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
item = info.ContentType == ChannelMediaContentType.Podcast
|
||||
? GetItemById<AudioBook>(info.Id, channelProvider.Name, out isNew)
|
||||
: GetItemById<Audio>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.ContentType == ChannelMediaContentType.Episode)
|
||||
item = info.ContentType switch
|
||||
{
|
||||
item = GetItemById<Episode>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else if (info.ContentType == ChannelMediaContentType.Movie)
|
||||
{
|
||||
item = GetItemById<Movie>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else if (info.ContentType == ChannelMediaContentType.Trailer || info.ExtraType == ExtraType.Trailer)
|
||||
{
|
||||
item = GetItemById<Trailer>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = GetItemById<Video>(info.Id, channelProvider.Name, out isNew);
|
||||
}
|
||||
ChannelMediaContentType.Episode => GetItemById<Episode>(info.Id, channelProvider.Name, out isNew),
|
||||
ChannelMediaContentType.Movie => GetItemById<Movie>(info.Id, channelProvider.Name, out isNew),
|
||||
var x when x == ChannelMediaContentType.Trailer || info.ExtraType == ExtraType.Trailer
|
||||
=> GetItemById<Trailer>(info.Id, channelProvider.Name, out isNew),
|
||||
_ => GetItemById<Video>(info.Id, channelProvider.Name, out isNew)
|
||||
};
|
||||
}
|
||||
|
||||
var enableMediaProbe = channelProvider is ISupportsMediaProbe;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -11,12 +9,21 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
/// <summary>
|
||||
/// A task to remove all non-installed channels from the database.
|
||||
/// </summary>
|
||||
public class ChannelPostScanTask
|
||||
{
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChannelPostScanTask"/> class.
|
||||
/// </summary>
|
||||
/// <param name="channelManager">The channel manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
public ChannelPostScanTask(IChannelManager channelManager, ILogger logger, ILibraryManager libraryManager)
|
||||
{
|
||||
_channelManager = channelManager;
|
||||
@@ -24,6 +31,12 @@ namespace Emby.Server.Implementations.Channels
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs this task.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The completed task.</returns>
|
||||
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
CleanDatabase(cancellationToken);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -13,13 +11,23 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
/// <summary>
|
||||
/// The "Refresh Channels" scheduled task.
|
||||
/// </summary>
|
||||
public class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
|
||||
{
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<RefreshChannelsScheduledTask> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RefreshChannelsScheduledTask"/> class.
|
||||
/// </summary>
|
||||
/// <param name="channelManager">The channel manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="localization">The localization manager.</param>
|
||||
public RefreshChannelsScheduledTask(
|
||||
IChannelManager channelManager,
|
||||
ILogger<RefreshChannelsScheduledTask> logger,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Emby.Server.Implementations.Images;
|
||||
@@ -15,8 +13,18 @@ using MediaBrowser.Model.IO;
|
||||
|
||||
namespace Emby.Server.Implementations.Collections
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection image provider.
|
||||
/// </summary>
|
||||
public class CollectionImageProvider : BaseDynamicImageProvider<BoxSet>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CollectionImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">The filesystem.</param>
|
||||
/// <param name="providerManager">The provider manager.</param>
|
||||
/// <param name="applicationPaths">The application paths.</param>
|
||||
/// <param name="imageProcessor">The image processor.</param>
|
||||
public CollectionImageProvider(
|
||||
IFileSystem fileSystem,
|
||||
IProviderManager providerManager,
|
||||
@@ -26,6 +34,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Supports(BaseItem item)
|
||||
{
|
||||
// Right now this is the only way to prevent this image from getting created ahead of internet image providers
|
||||
@@ -37,6 +46,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
return base.Supports(item);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
var playlist = (BoxSet)item;
|
||||
@@ -46,13 +56,12 @@ namespace Emby.Server.Implementations.Collections
|
||||
{
|
||||
var subItem = i;
|
||||
|
||||
if (subItem is Episode episode)
|
||||
var episode = subItem as Episode;
|
||||
|
||||
var series = episode?.Series;
|
||||
if (series != null && series.HasImage(ImageType.Primary))
|
||||
{
|
||||
var series = episode.Series;
|
||||
if (series != null && series.HasImage(ImageType.Primary))
|
||||
{
|
||||
return series;
|
||||
}
|
||||
return series;
|
||||
}
|
||||
|
||||
if (subItem.HasImage(ImageType.Primary))
|
||||
@@ -78,6 +87,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
{
|
||||
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -23,16 +21,29 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Collections
|
||||
{
|
||||
/// <summary>
|
||||
/// The collection manager.
|
||||
/// </summary>
|
||||
public class CollectionManager : ICollectionManager
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryMonitor _iLibraryMonitor;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<CollectionManager> _logger;
|
||||
private readonly IProviderManager _providerManager;
|
||||
private readonly ILocalizationManager _localizationManager;
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CollectionManager"/> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="appPaths">The application paths.</param>
|
||||
/// <param name="localizationManager">The localization manager.</param>
|
||||
/// <param name="fileSystem">The filesystem.</param>
|
||||
/// <param name="iLibraryMonitor">The library monitor.</param>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="providerManager">The provider manager.</param>
|
||||
public CollectionManager(
|
||||
ILibraryManager libraryManager,
|
||||
IApplicationPaths appPaths,
|
||||
@@ -45,16 +56,19 @@ namespace Emby.Server.Implementations.Collections
|
||||
_libraryManager = libraryManager;
|
||||
_fileSystem = fileSystem;
|
||||
_iLibraryMonitor = iLibraryMonitor;
|
||||
_logger = loggerFactory.CreateLogger(nameof(CollectionManager));
|
||||
_logger = loggerFactory.CreateLogger<CollectionManager>();
|
||||
_providerManager = providerManager;
|
||||
_localizationManager = localizationManager;
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<CollectionCreatedEventArgs> CollectionCreated;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<CollectionModifiedEventArgs> ItemsAddedToCollection;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<CollectionModifiedEventArgs> ItemsRemovedFromCollection;
|
||||
|
||||
private IEnumerable<Folder> FindFolders(string path)
|
||||
@@ -116,6 +130,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
: folder.GetChildren(user, true).OfType<BoxSet>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public BoxSet CreateCollection(CollectionCreationOptions options)
|
||||
{
|
||||
var name = options.Name;
|
||||
@@ -180,11 +195,13 @@ namespace Emby.Server.Implementations.Collections
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddToCollection(Guid collectionId, IEnumerable<string> ids)
|
||||
{
|
||||
AddToCollection(collectionId, ids, true, new MetadataRefreshOptions(new DirectoryService(_fileSystem)));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddToCollection(Guid collectionId, IEnumerable<Guid> ids)
|
||||
{
|
||||
AddToCollection(collectionId, ids.Select(i => i.ToString("N", CultureInfo.InvariantCulture)), true, new MetadataRefreshOptions(new DirectoryService(_fileSystem)));
|
||||
@@ -247,11 +264,13 @@ namespace Emby.Server.Implementations.Collections
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveFromCollection(Guid collectionId, IEnumerable<string> itemIds)
|
||||
{
|
||||
RemoveFromCollection(collectionId, itemIds.Select(i => new Guid(i)));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveFromCollection(Guid collectionId, IEnumerable<Guid> itemIds)
|
||||
{
|
||||
var collection = _libraryManager.GetItemById(collectionId) as BoxSet;
|
||||
@@ -305,6 +324,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> items, User user)
|
||||
{
|
||||
var results = new Dictionary<Guid, BaseItem>();
|
||||
@@ -313,9 +333,7 @@ namespace Emby.Server.Implementations.Collections
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var grouping = item as ISupportsBoxSetGrouping;
|
||||
|
||||
if (grouping == null)
|
||||
if (!(item is ISupportsBoxSetGrouping))
|
||||
{
|
||||
results[item.Id] = item;
|
||||
}
|
||||
@@ -345,12 +363,21 @@ namespace Emby.Server.Implementations.Collections
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The collection manager entry point.
|
||||
/// </summary>
|
||||
public sealed class CollectionManagerEntryPoint : IServerEntryPoint
|
||||
{
|
||||
private readonly CollectionManager _collectionManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<CollectionManagerEntryPoint> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CollectionManagerEntryPoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="collectionManager">The collection manager.</param>
|
||||
/// <param name="config">The server configuration manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public CollectionManagerEntryPoint(
|
||||
ICollectionManager collectionManager,
|
||||
IServerConfigurationManager config,
|
||||
|
||||
@@ -67,23 +67,22 @@ namespace Emby.Server.Implementations.Configuration
|
||||
/// <summary>
|
||||
/// Updates the metadata path.
|
||||
/// </summary>
|
||||
/// <exception cref="UnauthorizedAccessException">If the directory does not exist, and the caller does not have the required permission to create it.</exception>
|
||||
/// <exception cref="NotSupportedException">If there is a custom path transcoding path specified, but it is invalid.</exception>
|
||||
/// <exception cref="IOException">If the directory does not exist, and it also could not be created.</exception>
|
||||
private void UpdateMetadataPath()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Configuration.MetadataPath))
|
||||
{
|
||||
((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = Path.Combine(ApplicationPaths.ProgramDataPath, "metadata");
|
||||
}
|
||||
else
|
||||
{
|
||||
((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = Configuration.MetadataPath;
|
||||
}
|
||||
((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = string.IsNullOrWhiteSpace(Configuration.MetadataPath)
|
||||
? ApplicationPaths.DefaultInternalMetadataPath
|
||||
: Configuration.MetadataPath;
|
||||
Directory.CreateDirectory(ApplicationPaths.InternalMetadataPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the configuration.
|
||||
/// </summary>
|
||||
/// <param name="newConfiguration">The new configuration.</param>
|
||||
/// <exception cref="DirectoryNotFoundException"></exception>
|
||||
/// <exception cref="DirectoryNotFoundException">If the configuration path doesn't exist.</exception>
|
||||
public override void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration)
|
||||
{
|
||||
var newConfig = (ServerConfiguration)newConfiguration;
|
||||
@@ -91,7 +90,7 @@ namespace Emby.Server.Implementations.Configuration
|
||||
ValidateMetadataPath(newConfig);
|
||||
ValidateSslCertificate(newConfig);
|
||||
|
||||
ConfigurationUpdating?.Invoke(this, new GenericEventArgs<ServerConfiguration> { Argument = newConfig });
|
||||
ConfigurationUpdating?.Invoke(this, new GenericEventArgs<ServerConfiguration>(newConfig));
|
||||
|
||||
base.ReplaceConfiguration(newConfiguration);
|
||||
}
|
||||
@@ -194,12 +193,6 @@ namespace Emby.Server.Implementations.Configuration
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!config.CameraUploadUpgraded)
|
||||
{
|
||||
config.CameraUploadUpgraded = true;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!config.CollectionsUpgraded)
|
||||
{
|
||||
config.CollectionsUpgraded = true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Emby.Server.Implementations.HttpServer;
|
||||
using Emby.Server.Implementations.Updates;
|
||||
using MediaBrowser.Providers.Music;
|
||||
using static MediaBrowser.Controller.Extensions.ConfigurationExtensions;
|
||||
|
||||
namespace Emby.Server.Implementations
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
@@ -31,7 +33,7 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
|
||||
private RandomNumberGenerator _randomNumberGenerator;
|
||||
|
||||
private bool _disposed = false;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CryptographyProvider"/> class.
|
||||
@@ -56,15 +58,13 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
{
|
||||
// downgrading for now as we need this library to be dotnetstandard compliant
|
||||
// with this downgrade we'll add a check to make sure we're on the downgrade method at the moment
|
||||
if (method == DefaultHashMethod)
|
||||
if (method != DefaultHashMethod)
|
||||
{
|
||||
using (var r = new Rfc2898DeriveBytes(bytes, salt, iterations))
|
||||
{
|
||||
return r.GetBytes(32);
|
||||
}
|
||||
throw new CryptographicException($"Cannot currently use PBKDF2 with requested hash method: {method}");
|
||||
}
|
||||
|
||||
throw new CryptographicException($"Cannot currently use PBKDF2 with requested hash method: {method}");
|
||||
using var r = new Rfc2898DeriveBytes(bytes, salt, iterations);
|
||||
return r.GetBytes(32);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -74,25 +74,22 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
{
|
||||
return PBKDF2(hashMethod, bytes, salt, DefaultIterations);
|
||||
}
|
||||
else if (_supportedHashMethods.Contains(hashMethod))
|
||||
|
||||
if (!_supportedHashMethods.Contains(hashMethod))
|
||||
{
|
||||
using (var h = HashAlgorithm.Create(hashMethod))
|
||||
{
|
||||
if (salt.Length == 0)
|
||||
{
|
||||
return h.ComputeHash(bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] salted = new byte[bytes.Length + salt.Length];
|
||||
Array.Copy(bytes, salted, bytes.Length);
|
||||
Array.Copy(salt, 0, salted, bytes.Length, salt.Length);
|
||||
return h.ComputeHash(salted);
|
||||
}
|
||||
}
|
||||
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
|
||||
}
|
||||
|
||||
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
|
||||
using var h = HashAlgorithm.Create(hashMethod);
|
||||
if (salt.Length == 0)
|
||||
{
|
||||
return h.ComputeHash(bytes);
|
||||
}
|
||||
|
||||
byte[] salted = new byte[bytes.Length + salt.Length];
|
||||
Array.Copy(bytes, salted, bytes.Length);
|
||||
Array.Copy(salt, 0, salted, bytes.Length, salt.Length);
|
||||
return h.ComputeHash(salted);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -134,8 +131,6 @@ namespace Emby.Server.Implementations.Cryptography
|
||||
_randomNumberGenerator.Dispose();
|
||||
}
|
||||
|
||||
_randomNumberGenerator = null;
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Emby.Server.Implementations.Data
|
||||
/// Initializes a new instance of the <see cref="BaseSqliteRepository"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
protected BaseSqliteRepository(ILogger logger)
|
||||
protected BaseSqliteRepository(ILogger<BaseSqliteRepository> logger)
|
||||
{
|
||||
Logger = logger;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Data
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
protected ILogger Logger { get; }
|
||||
protected ILogger<BaseSqliteRepository> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default connection flags.
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Emby.Server.Implementations.Data
|
||||
public class CleanDatabaseScheduledTask : ILibraryPostScanTask
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<CleanDatabaseScheduledTask> _logger;
|
||||
|
||||
public CleanDatabaseScheduledTask(ILibraryManager libraryManager, ILogger<CleanDatabaseScheduledTask> logger)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -33,18 +35,17 @@ using SQLitePCL.pretty;
|
||||
namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SQLiteItemRepository
|
||||
/// Class SQLiteItemRepository.
|
||||
/// </summary>
|
||||
public class SqliteItemRepository : BaseSqliteRepository, IItemRepository
|
||||
{
|
||||
private const string ChaptersTableName = "Chapters2";
|
||||
|
||||
/// <summary>
|
||||
/// The _app paths
|
||||
/// </summary>
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly ILocalizationManager _localization;
|
||||
// TODO: Remove this dependency. GetImageCacheTag() is the only method used and it can be converted to a static helper method
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
|
||||
private readonly TypeMapper _typeMapper;
|
||||
private readonly JsonSerializerOptions _jsonOptions;
|
||||
@@ -71,7 +72,8 @@ namespace Emby.Server.Implementations.Data
|
||||
IServerConfigurationManager config,
|
||||
IServerApplicationHost appHost,
|
||||
ILogger<SqliteItemRepository> logger,
|
||||
ILocalizationManager localization)
|
||||
ILocalizationManager localization,
|
||||
IImageProcessor imageProcessor)
|
||||
: base(logger)
|
||||
{
|
||||
if (config == null)
|
||||
@@ -82,6 +84,7 @@ namespace Emby.Server.Implementations.Data
|
||||
_config = config;
|
||||
_appHost = appHost;
|
||||
_localization = localization;
|
||||
_imageProcessor = imageProcessor;
|
||||
|
||||
_typeMapper = new TypeMapper();
|
||||
_jsonOptions = JsonDefaults.GetOptions();
|
||||
@@ -98,8 +101,6 @@ namespace Emby.Server.Implementations.Data
|
||||
/// <inheritdoc />
|
||||
protected override TempStoreMode TempStore => TempStoreMode.Memory;
|
||||
|
||||
public IImageProcessor ImageProcessor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Opens the connection to the database
|
||||
/// </summary>
|
||||
@@ -1142,24 +1143,24 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
public string ToValueString(ItemImageInfo image)
|
||||
{
|
||||
var delimeter = "*";
|
||||
const string Delimeter = "*";
|
||||
|
||||
var path = image.Path;
|
||||
|
||||
if (path == null)
|
||||
{
|
||||
path = string.Empty;
|
||||
}
|
||||
var path = image.Path ?? string.Empty;
|
||||
var hash = image.BlurHash ?? string.Empty;
|
||||
|
||||
return GetPathToSave(path) +
|
||||
delimeter +
|
||||
Delimeter +
|
||||
image.DateModified.Ticks.ToString(CultureInfo.InvariantCulture) +
|
||||
delimeter +
|
||||
Delimeter +
|
||||
image.Type +
|
||||
delimeter +
|
||||
Delimeter +
|
||||
image.Width.ToString(CultureInfo.InvariantCulture) +
|
||||
delimeter +
|
||||
image.Height.ToString(CultureInfo.InvariantCulture);
|
||||
Delimeter +
|
||||
image.Height.ToString(CultureInfo.InvariantCulture) +
|
||||
Delimeter +
|
||||
// Replace delimiters with other characters.
|
||||
// This can be removed when we migrate to a proper DB.
|
||||
hash.Replace('*', '/').Replace('|', '\\');
|
||||
}
|
||||
|
||||
public ItemImageInfo ItemImageInfoFromValueString(string value)
|
||||
@@ -1193,6 +1194,11 @@ namespace Emby.Server.Implementations.Data
|
||||
image.Width = width;
|
||||
image.Height = height;
|
||||
}
|
||||
|
||||
if (parts.Length >= 6)
|
||||
{
|
||||
image.BlurHash = parts[5].Replace('/', '*').Replace('\\', '|');
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
@@ -1620,11 +1626,11 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
if (!reader.IsDBNull(index))
|
||||
{
|
||||
IEnumerable<MetadataFields> GetLockedFields(string s)
|
||||
IEnumerable<MetadataField> GetLockedFields(string s)
|
||||
{
|
||||
foreach (var i in s.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (Enum.TryParse(i, true, out MetadataFields parsedValue))
|
||||
if (Enum.TryParse(i, true, out MetadataField parsedValue))
|
||||
{
|
||||
yield return parsedValue;
|
||||
}
|
||||
@@ -1972,6 +1978,7 @@ namespace Emby.Server.Implementations.Data
|
||||
/// Gets the chapter.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>ChapterInfo.</returns>
|
||||
private ChapterInfo GetChapter(IReadOnlyList<IResultSetValue> reader, BaseItem item)
|
||||
{
|
||||
@@ -1991,7 +1998,14 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
if (!string.IsNullOrEmpty(chapter.ImagePath))
|
||||
{
|
||||
chapter.ImageTag = ImageProcessor.GetImageCacheTag(item, chapter);
|
||||
try
|
||||
{
|
||||
chapter.ImageTag = _imageProcessor.GetImageCacheTag(item, chapter);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Failed to create image cache tag.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2720,7 +2734,7 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
foreach (var providerId in newItem.ProviderIds)
|
||||
{
|
||||
if (providerId.Key == MetadataProviders.TmdbCollection.ToString())
|
||||
if (providerId.Key == MetadataProvider.TmdbCollection.ToString())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -4310,7 +4324,7 @@ namespace Emby.Server.Implementations.Data
|
||||
var index = 0;
|
||||
foreach (var pair in query.ExcludeProviderIds)
|
||||
{
|
||||
if (string.Equals(pair.Key, MetadataProviders.TmdbCollection.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(pair.Key, MetadataProvider.TmdbCollection.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -4339,7 +4353,7 @@ namespace Emby.Server.Implementations.Data
|
||||
var index = 0;
|
||||
foreach (var pair in query.HasAnyProviderId)
|
||||
{
|
||||
if (string.Equals(pair.Key, MetadataProviders.TmdbCollection.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(pair.Key, MetadataProvider.TmdbCollection.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -375,5 +375,15 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
return userData;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <remarks>
|
||||
/// There is nothing to dispose here since <see cref="BaseSqliteRepository.WriteLock"/> and
|
||||
/// <see cref="BaseSqliteRepository.WriteConnection"/> are managed by <see cref="SqliteItemRepository"/>.
|
||||
/// See <see cref="Initialize(IUserManager, SemaphoreSlim, SQLiteDatabaseConnection)"/>.
|
||||
/// </remarks>
|
||||
protected override void Dispose(bool dispose)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Emby.Server.Implementations.Devices
|
||||
public class DeviceId
|
||||
{
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<DeviceId> _logger;
|
||||
|
||||
private readonly object _syncLock = new object();
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.Devices
|
||||
public DeviceId(IApplicationPaths appPaths, ILoggerFactory loggerFactory)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
_logger = loggerFactory.CreateLogger("SystemId");
|
||||
_logger = loggerFactory.CreateLogger<DeviceId>();
|
||||
}
|
||||
|
||||
public string Value => _id ?? (_id = GetDeviceId());
|
||||
|
||||
@@ -5,27 +5,18 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Security;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Devices;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Session;
|
||||
using MediaBrowser.Model.Users;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Devices
|
||||
{
|
||||
@@ -33,42 +24,27 @@ namespace Emby.Server.Implementations.Devices
|
||||
{
|
||||
private readonly IJsonSerializer _json;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryMonitor _libraryMonitor;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILocalizationManager _localizationManager;
|
||||
|
||||
private readonly IAuthenticationRepository _authRepo;
|
||||
private readonly Dictionary<string, ClientCapabilities> _capabilitiesCache;
|
||||
|
||||
public event EventHandler<GenericEventArgs<Tuple<string, DeviceOptions>>> DeviceOptionsUpdated;
|
||||
public event EventHandler<GenericEventArgs<CameraImageUploadInfo>> CameraImageUploaded;
|
||||
|
||||
private readonly object _cameraUploadSyncLock = new object();
|
||||
private readonly object _capabilitiesSyncLock = new object();
|
||||
|
||||
public DeviceManager(
|
||||
IAuthenticationRepository authRepo,
|
||||
IJsonSerializer json,
|
||||
ILibraryManager libraryManager,
|
||||
ILocalizationManager localizationManager,
|
||||
IUserManager userManager,
|
||||
IFileSystem fileSystem,
|
||||
ILibraryMonitor libraryMonitor,
|
||||
IServerConfigurationManager config)
|
||||
{
|
||||
_json = json;
|
||||
_userManager = userManager;
|
||||
_fileSystem = fileSystem;
|
||||
_libraryMonitor = libraryMonitor;
|
||||
_config = config;
|
||||
_libraryManager = libraryManager;
|
||||
_localizationManager = localizationManager;
|
||||
_authRepo = authRepo;
|
||||
_capabilitiesCache = new Dictionary<string, ClientCapabilities>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
|
||||
private Dictionary<string, ClientCapabilities> _capabilitiesCache = new Dictionary<string, ClientCapabilities>(StringComparer.OrdinalIgnoreCase);
|
||||
public void SaveCapabilities(string deviceId, ClientCapabilities capabilities)
|
||||
{
|
||||
var path = Path.Combine(GetDevicePath(deviceId), "capabilities.json");
|
||||
@@ -86,13 +62,7 @@ namespace Emby.Server.Implementations.Devices
|
||||
{
|
||||
_authRepo.UpdateDeviceOptions(deviceId, options);
|
||||
|
||||
if (DeviceOptionsUpdated != null)
|
||||
{
|
||||
DeviceOptionsUpdated(this, new GenericEventArgs<Tuple<string, DeviceOptions>>()
|
||||
{
|
||||
Argument = new Tuple<string, DeviceOptions>(deviceId, options)
|
||||
});
|
||||
}
|
||||
DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, options)));
|
||||
}
|
||||
|
||||
public DeviceOptions GetDeviceOptions(string deviceId)
|
||||
@@ -194,172 +164,6 @@ namespace Emby.Server.Implementations.Devices
|
||||
return Path.Combine(GetDevicesPath(), id.GetMD5().ToString("N", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
public ContentUploadHistory GetCameraUploadHistory(string deviceId)
|
||||
{
|
||||
var path = Path.Combine(GetDevicePath(deviceId), "camerauploads.json");
|
||||
|
||||
lock (_cameraUploadSyncLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _json.DeserializeFromFile<ContentUploadHistory>(path);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return new ContentUploadHistory
|
||||
{
|
||||
DeviceId = deviceId
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file)
|
||||
{
|
||||
var device = GetDevice(deviceId, false);
|
||||
var uploadPathInfo = GetUploadPath(device);
|
||||
|
||||
var path = uploadPathInfo.Item1;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(file.Album))
|
||||
{
|
||||
path = Path.Combine(path, _fileSystem.GetValidFilename(file.Album));
|
||||
}
|
||||
|
||||
path = Path.Combine(path, file.Name);
|
||||
path = Path.ChangeExtension(path, MimeTypes.ToExtension(file.MimeType) ?? "jpg");
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
await EnsureLibraryFolder(uploadPathInfo.Item2, uploadPathInfo.Item3).ConfigureAwait(false);
|
||||
|
||||
_libraryMonitor.ReportFileSystemChangeBeginning(path);
|
||||
|
||||
try
|
||||
{
|
||||
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
{
|
||||
await stream.CopyToAsync(fs).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
AddCameraUpload(deviceId, file);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_libraryMonitor.ReportFileSystemChangeComplete(path, true);
|
||||
}
|
||||
|
||||
if (CameraImageUploaded != null)
|
||||
{
|
||||
CameraImageUploaded?.Invoke(this, new GenericEventArgs<CameraImageUploadInfo>
|
||||
{
|
||||
Argument = new CameraImageUploadInfo
|
||||
{
|
||||
Device = device,
|
||||
FileInfo = file
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCameraUpload(string deviceId, LocalFileInfo file)
|
||||
{
|
||||
var path = Path.Combine(GetDevicePath(deviceId), "camerauploads.json");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
lock (_cameraUploadSyncLock)
|
||||
{
|
||||
ContentUploadHistory history;
|
||||
|
||||
try
|
||||
{
|
||||
history = _json.DeserializeFromFile<ContentUploadHistory>(path);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
history = new ContentUploadHistory
|
||||
{
|
||||
DeviceId = deviceId
|
||||
};
|
||||
}
|
||||
|
||||
history.DeviceId = deviceId;
|
||||
|
||||
var list = history.FilesUploaded.ToList();
|
||||
list.Add(file);
|
||||
history.FilesUploaded = list.ToArray();
|
||||
|
||||
_json.SerializeToFile(history, path);
|
||||
}
|
||||
}
|
||||
|
||||
internal Task EnsureLibraryFolder(string path, string name)
|
||||
{
|
||||
var existingFolders = _libraryManager
|
||||
.RootFolder
|
||||
.Children
|
||||
.OfType<Folder>()
|
||||
.Where(i => _fileSystem.AreEqual(path, i.Path) || _fileSystem.ContainsSubPath(i.Path, path))
|
||||
.ToList();
|
||||
|
||||
if (existingFolders.Count > 0)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var libraryOptions = new LibraryOptions
|
||||
{
|
||||
PathInfos = new[] { new MediaPathInfo { Path = path } },
|
||||
EnablePhotos = true,
|
||||
EnableRealtimeMonitor = false,
|
||||
SaveLocalMetadata = true
|
||||
};
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
name = _localizationManager.GetLocalizedString("HeaderCameraUploads");
|
||||
}
|
||||
|
||||
return _libraryManager.AddVirtualFolder(name, CollectionType.HomeVideos, libraryOptions, true);
|
||||
}
|
||||
|
||||
private Tuple<string, string, string> GetUploadPath(DeviceInfo device)
|
||||
{
|
||||
var config = _config.GetUploadOptions();
|
||||
var path = config.CameraUploadPath;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
path = DefaultCameraUploadsPath;
|
||||
}
|
||||
|
||||
var topLibraryPath = path;
|
||||
|
||||
if (config.EnableCameraUploadSubfolders)
|
||||
{
|
||||
path = Path.Combine(path, _fileSystem.GetValidFilename(device.Name));
|
||||
}
|
||||
|
||||
return new Tuple<string, string, string>(path, topLibraryPath, null);
|
||||
}
|
||||
|
||||
internal string GetUploadsPath()
|
||||
{
|
||||
var config = _config.GetUploadOptions();
|
||||
var path = config.CameraUploadPath;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
path = DefaultCameraUploadsPath;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private string DefaultCameraUploadsPath => Path.Combine(_config.CommonApplicationPaths.DataPath, "camerauploads");
|
||||
|
||||
public bool CanAccessDevice(User user, string deviceId)
|
||||
{
|
||||
if (user == null)
|
||||
@@ -399,102 +203,4 @@ namespace Emby.Server.Implementations.Devices
|
||||
return policy.EnabledDevices.Contains(id, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
public class DeviceManagerEntryPoint : IServerEntryPoint
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private ILogger _logger;
|
||||
|
||||
public DeviceManagerEntryPoint(
|
||||
IDeviceManager deviceManager,
|
||||
IServerConfigurationManager config,
|
||||
ILogger<DeviceManagerEntryPoint> logger)
|
||||
{
|
||||
_deviceManager = (DeviceManager)deviceManager;
|
||||
_config = config;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
{
|
||||
if (!_config.Configuration.CameraUploadUpgraded && _config.Configuration.IsStartupWizardCompleted)
|
||||
{
|
||||
var path = _deviceManager.GetUploadsPath();
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
await _deviceManager.EnsureLibraryFolder(path, null).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error creating camera uploads library");
|
||||
}
|
||||
|
||||
_config.Configuration.CameraUploadUpgraded = true;
|
||||
_config.SaveConfiguration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Support
|
||||
private bool disposedValue = false; // To detect redundant calls
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// TODO: dispose managed state (managed objects).
|
||||
}
|
||||
|
||||
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
|
||||
// TODO: set large fields to null.
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
|
||||
// ~DeviceManagerEntryPoint() {
|
||||
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
// Dispose(false);
|
||||
// }
|
||||
|
||||
// This code added to correctly implement the disposable pattern.
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
Dispose(true);
|
||||
// TODO: uncomment the following line if the finalizer is overridden above.
|
||||
// GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class DevicesConfigStore : IConfigurationFactory
|
||||
{
|
||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||
{
|
||||
return new ConfigurationStore[]
|
||||
{
|
||||
new ConfigurationStore
|
||||
{
|
||||
Key = "devices",
|
||||
ConfigurationType = typeof(DevicesOptions)
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static class UploadConfigExtension
|
||||
{
|
||||
public static DevicesOptions GetUploadOptions(this IConfigurationManager config)
|
||||
{
|
||||
return config.GetConfiguration<DevicesOptions>("devices");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
{
|
||||
public class DtoService : IDtoService
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<DtoService> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IUserDataManager _userDataRepository;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
@@ -38,21 +38,23 @@ namespace Emby.Server.Implementations.Dto
|
||||
private readonly IProviderManager _providerManager;
|
||||
|
||||
private readonly IApplicationHost _appHost;
|
||||
private readonly Func<IMediaSourceManager> _mediaSourceManager;
|
||||
private readonly Func<ILiveTvManager> _livetvManager;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
private readonly Lazy<ILiveTvManager> _livetvManagerFactory;
|
||||
|
||||
private ILiveTvManager LivetvManager => _livetvManagerFactory.Value;
|
||||
|
||||
public DtoService(
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<DtoService> logger,
|
||||
ILibraryManager libraryManager,
|
||||
IUserDataManager userDataRepository,
|
||||
IItemRepository itemRepo,
|
||||
IImageProcessor imageProcessor,
|
||||
IProviderManager providerManager,
|
||||
IApplicationHost appHost,
|
||||
Func<IMediaSourceManager> mediaSourceManager,
|
||||
Func<ILiveTvManager> livetvManager)
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
Lazy<ILiveTvManager> livetvManagerFactory)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(DtoService));
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
_userDataRepository = userDataRepository;
|
||||
_itemRepo = itemRepo;
|
||||
@@ -60,7 +62,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
_providerManager = providerManager;
|
||||
_appHost = appHost;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_livetvManager = livetvManager;
|
||||
_livetvManagerFactory = livetvManagerFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,12 +127,12 @@ namespace Emby.Server.Implementations.Dto
|
||||
|
||||
if (programTuples.Count > 0)
|
||||
{
|
||||
_livetvManager().AddInfoToProgramDto(programTuples, options.Fields, user).GetAwaiter().GetResult();
|
||||
LivetvManager.AddInfoToProgramDto(programTuples, options.Fields, user).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
if (channelTuples.Count > 0)
|
||||
{
|
||||
_livetvManager().AddChannelInfo(channelTuples, options, user);
|
||||
LivetvManager.AddChannelInfo(channelTuples, options, user);
|
||||
}
|
||||
|
||||
return returnItems;
|
||||
@@ -142,12 +144,12 @@ namespace Emby.Server.Implementations.Dto
|
||||
if (item is LiveTvChannel tvChannel)
|
||||
{
|
||||
var list = new List<(BaseItemDto, LiveTvChannel)>(1) { (dto, tvChannel) };
|
||||
_livetvManager().AddChannelInfo(list, options, user);
|
||||
LivetvManager.AddChannelInfo(list, options, user);
|
||||
}
|
||||
else if (item is LiveTvProgram)
|
||||
{
|
||||
var list = new List<(BaseItem, BaseItemDto)>(1) { (item, dto) };
|
||||
var task = _livetvManager().AddInfoToProgramDto(list, options.Fields, user);
|
||||
var task = LivetvManager.AddInfoToProgramDto(list, options.Fields, user);
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
@@ -223,7 +225,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
if (item is IHasMediaSources
|
||||
&& options.ContainsField(ItemFields.MediaSources))
|
||||
{
|
||||
dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(item, true, user).ToArray();
|
||||
dto.MediaSources = _mediaSourceManager.GetStaticMediaSources(item, true, user).ToArray();
|
||||
|
||||
NormalizeMediaSourceContainers(dto);
|
||||
}
|
||||
@@ -254,7 +256,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
dto.Etag = item.GetEtag(user);
|
||||
}
|
||||
|
||||
var liveTvManager = _livetvManager();
|
||||
var liveTvManager = LivetvManager;
|
||||
var activeRecording = liveTvManager.GetActiveRecordingInfo(item.Path);
|
||||
if (activeRecording != null)
|
||||
{
|
||||
@@ -603,7 +605,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
|
||||
if (dictionary.TryGetValue(person.Name, out Person entity))
|
||||
{
|
||||
baseItemPerson.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary);
|
||||
baseItemPerson.PrimaryImageTag = GetTagAndFillBlurhash(dto, entity, ImageType.Primary);
|
||||
baseItemPerson.Id = entity.Id.ToString("N", CultureInfo.InvariantCulture);
|
||||
list.Add(baseItemPerson);
|
||||
}
|
||||
@@ -652,6 +654,70 @@ namespace Emby.Server.Implementations.Dto
|
||||
return _libraryManager.GetGenreId(name);
|
||||
}
|
||||
|
||||
private string GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ImageType imageType, int imageIndex = 0)
|
||||
{
|
||||
var image = item.GetImageInfo(imageType, imageIndex);
|
||||
if (image != null)
|
||||
{
|
||||
return GetTagAndFillBlurhash(dto, item, image);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ItemImageInfo image)
|
||||
{
|
||||
var tag = GetImageCacheTag(item, image);
|
||||
if (!string.IsNullOrEmpty(image.BlurHash))
|
||||
{
|
||||
if (dto.ImageBlurHashes == null)
|
||||
{
|
||||
dto.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
if (!dto.ImageBlurHashes.ContainsKey(image.Type))
|
||||
{
|
||||
dto.ImageBlurHashes[image.Type] = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
dto.ImageBlurHashes[image.Type][tag] = image.BlurHash;
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
private string[] GetTagsAndFillBlurhashes(BaseItemDto dto, BaseItem item, ImageType imageType, int limit)
|
||||
{
|
||||
return GetTagsAndFillBlurhashes(dto, item, imageType, item.GetImages(imageType).Take(limit).ToList());
|
||||
}
|
||||
|
||||
private string[] GetTagsAndFillBlurhashes(BaseItemDto dto, BaseItem item, ImageType imageType, List<ItemImageInfo> images)
|
||||
{
|
||||
var tags = GetImageTags(item, images);
|
||||
var hashes = new Dictionary<string, string>();
|
||||
for (int i = 0; i < images.Count; i++)
|
||||
{
|
||||
var img = images[i];
|
||||
if (!string.IsNullOrEmpty(img.BlurHash))
|
||||
{
|
||||
var tag = tags[i];
|
||||
hashes[tag] = img.BlurHash;
|
||||
}
|
||||
}
|
||||
|
||||
if (hashes.Count > 0)
|
||||
{
|
||||
if (dto.ImageBlurHashes == null)
|
||||
{
|
||||
dto.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
dto.ImageBlurHashes[imageType] = hashes;
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets simple property values on a DTOBaseItem
|
||||
/// </summary>
|
||||
@@ -672,8 +738,8 @@ namespace Emby.Server.Implementations.Dto
|
||||
dto.LockData = item.IsLocked;
|
||||
dto.ForcedSortName = item.ForcedSortName;
|
||||
}
|
||||
dto.Container = item.Container;
|
||||
|
||||
dto.Container = item.Container;
|
||||
dto.EndDate = item.EndDate;
|
||||
|
||||
if (options.ContainsField(ItemFields.ExternalUrls))
|
||||
@@ -692,10 +758,12 @@ namespace Emby.Server.Implementations.Dto
|
||||
dto.AspectRatio = hasAspectRatio.AspectRatio;
|
||||
}
|
||||
|
||||
dto.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>();
|
||||
|
||||
var backdropLimit = options.GetImageLimit(ImageType.Backdrop);
|
||||
if (backdropLimit > 0)
|
||||
{
|
||||
dto.BackdropImageTags = GetImageTags(item, item.GetImages(ImageType.Backdrop).Take(backdropLimit).ToList());
|
||||
dto.BackdropImageTags = GetTagsAndFillBlurhashes(dto, item, ImageType.Backdrop, backdropLimit);
|
||||
}
|
||||
|
||||
if (options.ContainsField(ItemFields.ScreenshotImageTags))
|
||||
@@ -703,7 +771,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
var screenshotLimit = options.GetImageLimit(ImageType.Screenshot);
|
||||
if (screenshotLimit > 0)
|
||||
{
|
||||
dto.ScreenshotImageTags = GetImageTags(item, item.GetImages(ImageType.Screenshot).Take(screenshotLimit).ToList());
|
||||
dto.ScreenshotImageTags = GetTagsAndFillBlurhashes(dto, item, ImageType.Screenshot, screenshotLimit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,12 +787,11 @@ namespace Emby.Server.Implementations.Dto
|
||||
|
||||
// Prevent implicitly captured closure
|
||||
var currentItem = item;
|
||||
foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type))
|
||||
.ToList())
|
||||
foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type)))
|
||||
{
|
||||
if (options.GetImageLimit(image.Type) > 0)
|
||||
{
|
||||
var tag = GetImageCacheTag(item, image);
|
||||
var tag = GetTagAndFillBlurhash(dto, item, image);
|
||||
|
||||
if (tag != null)
|
||||
{
|
||||
@@ -869,8 +936,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
if (albumParent != null)
|
||||
{
|
||||
dto.AlbumId = albumParent.Id;
|
||||
|
||||
dto.AlbumPrimaryImageTag = GetImageCacheTag(albumParent, ImageType.Primary);
|
||||
dto.AlbumPrimaryImageTag = GetTagAndFillBlurhash(dto, albumParent, ImageType.Primary);
|
||||
}
|
||||
|
||||
//if (options.ContainsField(ItemFields.MediaSourceCount))
|
||||
@@ -1045,7 +1111,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
}
|
||||
else
|
||||
{
|
||||
mediaStreams = _mediaSourceManager().GetStaticMediaSources(item, true)[0].MediaStreams.ToArray();
|
||||
mediaStreams = _mediaSourceManager.GetStaticMediaSources(item, true)[0].MediaStreams.ToArray();
|
||||
}
|
||||
|
||||
dto.MediaStreams = mediaStreams;
|
||||
@@ -1097,7 +1163,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
episodeSeries = episodeSeries ?? episode.Series;
|
||||
if (episodeSeries != null)
|
||||
{
|
||||
dto.SeriesPrimaryImageTag = GetImageCacheTag(episodeSeries, ImageType.Primary);
|
||||
dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, episodeSeries, ImageType.Primary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1143,7 +1209,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
series = series ?? season.Series;
|
||||
if (series != null)
|
||||
{
|
||||
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
|
||||
dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, series, ImageType.Primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1273,7 +1339,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
if (image != null)
|
||||
{
|
||||
dto.ParentLogoItemId = GetDtoId(parent);
|
||||
dto.ParentLogoImageTag = GetImageCacheTag(parent, image);
|
||||
dto.ParentLogoImageTag = GetTagAndFillBlurhash(dto, parent, image);
|
||||
}
|
||||
}
|
||||
if (artLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId == null)
|
||||
@@ -1283,7 +1349,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
if (image != null)
|
||||
{
|
||||
dto.ParentArtItemId = GetDtoId(parent);
|
||||
dto.ParentArtImageTag = GetImageCacheTag(parent, image);
|
||||
dto.ParentArtImageTag = GetTagAndFillBlurhash(dto, parent, image);
|
||||
}
|
||||
}
|
||||
if (thumbLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId == null || parent is Series) && !(parent is ICollectionFolder) && !(parent is UserView))
|
||||
@@ -1293,7 +1359,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
if (image != null)
|
||||
{
|
||||
dto.ParentThumbItemId = GetDtoId(parent);
|
||||
dto.ParentThumbImageTag = GetImageCacheTag(parent, image);
|
||||
dto.ParentThumbImageTag = GetTagAndFillBlurhash(dto, parent, image);
|
||||
}
|
||||
}
|
||||
if (backdropLimit > 0 && !((dto.BackdropImageTags != null && dto.BackdropImageTags.Length > 0) || (dto.ParentBackdropImageTags != null && dto.ParentBackdropImageTags.Length > 0)))
|
||||
@@ -1303,7 +1369,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
if (images.Count > 0)
|
||||
{
|
||||
dto.ParentBackdropItemId = GetDtoId(parent);
|
||||
dto.ParentBackdropImageTags = GetImageTags(parent, images);
|
||||
dto.ParentBackdropImageTags = GetTagsAndFillBlurhashes(dto, parent, ImageType.Backdrop, images);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- ProjectGuid is only included as a requirement for SonarQube analysis -->
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{E383961B-9356-4D5D-8233-9A1079D03055}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Emby.Naming\Emby.Naming.csproj" />
|
||||
@@ -29,14 +34,16 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.5" />
|
||||
<PackageReference Include="Mono.Nat" Version="2.0.1" />
|
||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.8.0" />
|
||||
<PackageReference Include="prometheus-net.DotNetRuntime" Version="3.3.1" />
|
||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.9.0" />
|
||||
<PackageReference Include="sharpcompress" Version="0.25.0" />
|
||||
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.1.0" />
|
||||
<PackageReference Include="DotNet.Glob" Version="3.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -47,6 +54,7 @@
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release'" >true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Code Analyzers-->
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
public class ExternalPortForwarding : IServerEntryPoint
|
||||
{
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<ExternalPortForwarding> _logger;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IDeviceDiscovery _deviceDiscovery;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
.Append(config.PublicHttpsPort).Append(Separator)
|
||||
.Append(_appHost.HttpPort).Append(Separator)
|
||||
.Append(_appHost.HttpsPort).Append(Separator)
|
||||
.Append(_appHost.EnableHttps).Append(Separator)
|
||||
.Append(_appHost.ListenWithHttps).Append(Separator)
|
||||
.Append(config.EnableRemoteAccess).Append(Separator)
|
||||
.ToString();
|
||||
}
|
||||
@@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
{
|
||||
yield return CreatePortMap(device, _appHost.HttpPort, _config.Configuration.PublicPort);
|
||||
|
||||
if (_appHost.EnableHttps)
|
||||
if (_appHost.ListenWithHttps)
|
||||
{
|
||||
yield return CreatePortMap(device, _appHost.HttpsPort, _config.Configuration.PublicHttpsPort);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<LibraryChangedNotifier> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// The library changed sync lock.
|
||||
@@ -302,7 +302,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
.Select(x => x.First())
|
||||
.ToList();
|
||||
|
||||
SendChangeNotifications(_itemsAdded.ToList(), itemsUpdated, _itemsRemoved.ToList(), foldersAddedTo, foldersRemovedFrom, CancellationToken.None);
|
||||
SendChangeNotifications(_itemsAdded.ToList(), itemsUpdated, _itemsRemoved.ToList(), foldersAddedTo, foldersRemovedFrom, CancellationToken.None).GetAwaiter().GetResult();
|
||||
|
||||
if (LibraryUpdateTimer != null)
|
||||
{
|
||||
@@ -327,7 +327,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// <param name="foldersAddedTo">The folders added to.</param>
|
||||
/// <param name="foldersRemovedFrom">The folders removed from.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
private async void SendChangeNotifications(List<BaseItem> itemsAdded, List<BaseItem> itemsUpdated, List<BaseItem> itemsRemoved, List<Folder> foldersAddedTo, List<Folder> foldersRemovedFrom, CancellationToken cancellationToken)
|
||||
private async Task SendChangeNotifications(List<BaseItem> itemsAdded, List<BaseItem> itemsUpdated, List<BaseItem> itemsRemoved, List<Folder> foldersAddedTo, List<Folder> foldersRemovedFrom, CancellationToken cancellationToken)
|
||||
{
|
||||
var userIds = _sessionManager.Sessions
|
||||
.Select(i => i.UserId)
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<RecordingNotifier> _logger;
|
||||
|
||||
public RecordingNotifier(
|
||||
ISessionManager sessionManager,
|
||||
@@ -42,27 +42,27 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnLiveTvManagerSeriesTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
private async void OnLiveTvManagerSeriesTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
{
|
||||
SendMessage("SeriesTimerCreated", e.Argument);
|
||||
await SendMessage("SeriesTimerCreated", e.Argument).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnLiveTvManagerTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
private async void OnLiveTvManagerTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
{
|
||||
SendMessage("TimerCreated", e.Argument);
|
||||
await SendMessage("TimerCreated", e.Argument).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnLiveTvManagerSeriesTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
private async void OnLiveTvManagerSeriesTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
{
|
||||
SendMessage("SeriesTimerCancelled", e.Argument);
|
||||
await SendMessage("SeriesTimerCancelled", e.Argument).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnLiveTvManagerTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
private async void OnLiveTvManagerTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs<TimerEventInfo> e)
|
||||
{
|
||||
SendMessage("TimerCancelled", e.Argument);
|
||||
await SendMessage("TimerCancelled", e.Argument).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async void SendMessage(string name, TimerEventInfo info)
|
||||
private async Task SendMessage(string name, TimerEventInfo info)
|
||||
{
|
||||
var users = _userManager.Users.Where(i => i.Policy.EnableLiveTvAccess).Select(i => i.Id).ToList();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using MediaBrowser.Model.Updates;
|
||||
|
||||
namespace Emby.Server.Implementations.EntryPoints
|
||||
{
|
||||
@@ -85,29 +86,29 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnPackageInstalling(object sender, InstallationEventArgs e)
|
||||
private async void OnPackageInstalling(object sender, InstallationInfo e)
|
||||
{
|
||||
SendMessageToAdminSessions("PackageInstalling", e.InstallationInfo);
|
||||
await SendMessageToAdminSessions("PackageInstalling", e).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPackageInstallationCancelled(object sender, InstallationEventArgs e)
|
||||
private async void OnPackageInstallationCancelled(object sender, InstallationInfo e)
|
||||
{
|
||||
SendMessageToAdminSessions("PackageInstallationCancelled", e.InstallationInfo);
|
||||
await SendMessageToAdminSessions("PackageInstallationCancelled", e).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPackageInstallationCompleted(object sender, InstallationEventArgs e)
|
||||
private async void OnPackageInstallationCompleted(object sender, InstallationInfo e)
|
||||
{
|
||||
SendMessageToAdminSessions("PackageInstallationCompleted", e.InstallationInfo);
|
||||
await SendMessageToAdminSessions("PackageInstallationCompleted", e).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
|
||||
private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
|
||||
{
|
||||
SendMessageToAdminSessions("PackageInstallationFailed", e.InstallationInfo);
|
||||
await SendMessageToAdminSessions("PackageInstallationFailed", e.InstallationInfo).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnTaskCompleted(object sender, TaskCompletionEventArgs e)
|
||||
private async void OnTaskCompleted(object sender, TaskCompletionEventArgs e)
|
||||
{
|
||||
SendMessageToAdminSessions("ScheduledTaskEnded", e.Result);
|
||||
await SendMessageToAdminSessions("ScheduledTaskEnded", e.Result).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -115,9 +116,9 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
private void OnPluginUninstalled(object sender, GenericEventArgs<IPlugin> e)
|
||||
private async void OnPluginUninstalled(object sender, IPlugin e)
|
||||
{
|
||||
SendMessageToAdminSessions("PluginUninstalled", e.Argument.GetPluginInfo());
|
||||
await SendMessageToAdminSessions("PluginUninstalled", e).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,9 +126,9 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void OnHasPendingRestartChanged(object sender, EventArgs e)
|
||||
private async void OnHasPendingRestartChanged(object sender, EventArgs e)
|
||||
{
|
||||
_sessionManager.SendRestartRequiredNotification(CancellationToken.None);
|
||||
await _sessionManager.SendRestartRequiredNotification(CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -135,11 +136,11 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
private void OnUserUpdated(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
var dto = _userManager.GetUserDto(e.Argument);
|
||||
|
||||
SendMessageToUserSession(e.Argument, "UserUpdated", dto);
|
||||
await SendMessageToUserSession(e.Argument, "UserUpdated", dto).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -147,26 +148,26 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
private void OnUserDeleted(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserDeleted(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
SendMessageToUserSession(e.Argument, "UserDeleted", e.Argument.Id.ToString("N", CultureInfo.InvariantCulture));
|
||||
await SendMessageToUserSession(e.Argument, "UserDeleted", e.Argument.Id.ToString("N", CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnUserPolicyUpdated(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserPolicyUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
var dto = _userManager.GetUserDto(e.Argument);
|
||||
|
||||
SendMessageToUserSession(e.Argument, "UserPolicyUpdated", dto);
|
||||
await SendMessageToUserSession(e.Argument, "UserPolicyUpdated", dto).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void OnUserConfigurationUpdated(object sender, GenericEventArgs<User> e)
|
||||
private async void OnUserConfigurationUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
var dto = _userManager.GetUserDto(e.Argument);
|
||||
|
||||
SendMessageToUserSession(e.Argument, "UserConfigurationUpdated", dto);
|
||||
await SendMessageToUserSession(e.Argument, "UserConfigurationUpdated", dto).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async void SendMessageToAdminSessions<T>(string name, T data)
|
||||
private async Task SendMessageToAdminSessions<T>(string name, T data)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -178,7 +179,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
}
|
||||
}
|
||||
|
||||
private async void SendMessageToUserSession<T>(User user, string name, T data)
|
||||
private async Task SendMessageToUserSession<T>(User user, string name, T data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -16,46 +16,63 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IConfiguration _appConfig;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IStartupOptions _startupOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StartupWizard"/> class.
|
||||
/// </summary>
|
||||
/// <param name="appHost">The application host.</param>
|
||||
/// <param name="appConfig">The application configuration.</param>
|
||||
/// <param name="config">The configuration manager.</param>
|
||||
public StartupWizard(IServerApplicationHost appHost, IConfiguration appConfig, IServerConfigurationManager config)
|
||||
/// <param name="startupOptions">The application startup options.</param>
|
||||
public StartupWizard(
|
||||
IServerApplicationHost appHost,
|
||||
IConfiguration appConfig,
|
||||
IServerConfigurationManager config,
|
||||
IStartupOptions startupOptions)
|
||||
{
|
||||
_appHost = appHost;
|
||||
_appConfig = appConfig;
|
||||
_config = config;
|
||||
_startupOptions = startupOptions;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task RunAsync()
|
||||
{
|
||||
Run();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void Run()
|
||||
{
|
||||
if (!_appHost.CanLaunchWebBrowser)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_appConfig.HostWebClient())
|
||||
// Always launch the startup wizard if possible when it has not been completed
|
||||
if (!_config.Configuration.IsStartupWizardCompleted && _appConfig.HostWebClient())
|
||||
{
|
||||
BrowserLauncher.OpenSwaggerPage(_appHost);
|
||||
BrowserLauncher.OpenWebApp(_appHost);
|
||||
return;
|
||||
}
|
||||
else if (!_config.Configuration.IsStartupWizardCompleted)
|
||||
|
||||
// Do nothing if the web app is configured to not run automatically
|
||||
if (!_config.Configuration.AutoRunWebApp || _startupOptions.NoAutoRunWebApp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Launch the swagger page if the web client is not hosted, otherwise open the web client
|
||||
if (_appConfig.HostWebClient())
|
||||
{
|
||||
BrowserLauncher.OpenWebApp(_appHost);
|
||||
}
|
||||
else if (_config.Configuration.AutoRunWebApp)
|
||||
else
|
||||
{
|
||||
var options = ((ApplicationHost)_appHost).StartupOptions;
|
||||
|
||||
if (!options.NoAutoRunWebApp)
|
||||
{
|
||||
BrowserLauncher.OpenWebApp(_appHost);
|
||||
}
|
||||
BrowserLauncher.OpenSwaggerPage(_appHost);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Emby.Server.Implementations.Udp;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.EntryPoints
|
||||
@@ -20,8 +21,9 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<UdpServerEntryPoint> _logger;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IConfiguration _config;
|
||||
|
||||
/// <summary>
|
||||
/// The UDP server.
|
||||
@@ -35,19 +37,21 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
/// </summary>
|
||||
public UdpServerEntryPoint(
|
||||
ILogger<UdpServerEntryPoint> logger,
|
||||
IServerApplicationHost appHost)
|
||||
IServerApplicationHost appHost,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
_logger = logger;
|
||||
_appHost = appHost;
|
||||
|
||||
_config = configuration;
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task RunAsync()
|
||||
public Task RunAsync()
|
||||
{
|
||||
_udpServer = new UdpServer(_logger, _appHost);
|
||||
_udpServer = new UdpServer(_logger, _appHost, _config);
|
||||
_udpServer.Start(PortNumber, _cancellationTokenSource.Token);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
@@ -21,10 +22,10 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||
/// </summary>
|
||||
public class HttpClientManager : IHttpClient
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<HttpClientManager> _logger;
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly Func<string> _defaultUserAgentFn;
|
||||
private readonly IApplicationHost _appHost;
|
||||
|
||||
/// <summary>
|
||||
/// Holds a dictionary of http clients by host. Use GetHttpClient(host) to retrieve or create a client for web requests.
|
||||
@@ -40,12 +41,12 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||
IApplicationPaths appPaths,
|
||||
ILogger<HttpClientManager> logger,
|
||||
IFileSystem fileSystem,
|
||||
Func<string> defaultUserAgentFn)
|
||||
IApplicationHost appHost)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_fileSystem = fileSystem;
|
||||
_appPaths = appPaths ?? throw new ArgumentNullException(nameof(appPaths));
|
||||
_defaultUserAgentFn = defaultUserAgentFn;
|
||||
_appHost = appHost;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,7 +92,7 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||
if (options.EnableDefaultUserAgent
|
||||
&& !request.Headers.TryGetValues(HeaderNames.UserAgent, out _))
|
||||
{
|
||||
request.Headers.Add(HeaderNames.UserAgent, _defaultUserAgentFn());
|
||||
request.Headers.Add(HeaderNames.UserAgent, _appHost.ApplicationUserAgent);
|
||||
}
|
||||
|
||||
switch (options.DecompressionMethod)
|
||||
|
||||
@@ -6,14 +6,16 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Net.WebSockets;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.Server.Implementations.Net;
|
||||
using Emby.Server.Implementations.Services;
|
||||
using Emby.Server.Implementations.SocketSharp;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Authentication;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Events;
|
||||
@@ -21,15 +23,17 @@ using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using ServiceStack.Text.Jsv;
|
||||
|
||||
namespace Emby.Server.Implementations.HttpServer
|
||||
{
|
||||
public class HttpListenerHost : IHttpServer, IDisposable
|
||||
public class HttpListenerHost : IHttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// The key for a setting that specifies the default redirect path
|
||||
@@ -37,18 +41,18 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// </summary>
|
||||
public const string DefaultRedirectKey = "HttpListenerHost:DefaultRedirectPath";
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<HttpListenerHost> _logger;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly INetworkManager _networkManager;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IXmlSerializer _xmlSerializer;
|
||||
private readonly IHttpListener _socketListener;
|
||||
private readonly Func<Type, Func<string, object>> _funcParseFn;
|
||||
private readonly string _defaultRedirectPath;
|
||||
private readonly string _baseUrlPrefix;
|
||||
|
||||
private readonly Dictionary<Type, Type> _serviceOperationsMap = new Dictionary<Type, Type>();
|
||||
private readonly List<IWebSocketConnection> _webSocketConnections = new List<IWebSocketConnection>();
|
||||
private readonly IHostEnvironment _hostEnvironment;
|
||||
|
||||
private IWebSocketListener[] _webSocketListeners = Array.Empty<IWebSocketListener>();
|
||||
@@ -62,10 +66,10 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
INetworkManager networkManager,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IXmlSerializer xmlSerializer,
|
||||
IHttpListener socketListener,
|
||||
ILocalizationManager localizationManager,
|
||||
ServiceController serviceController,
|
||||
IHostEnvironment hostEnvironment)
|
||||
IHostEnvironment hostEnvironment,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
_appHost = applicationHost;
|
||||
_logger = logger;
|
||||
@@ -75,11 +79,9 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
_networkManager = networkManager;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_xmlSerializer = xmlSerializer;
|
||||
_socketListener = socketListener;
|
||||
ServiceController = serviceController;
|
||||
|
||||
_socketListener.WebSocketConnected = OnWebSocketConnected;
|
||||
_hostEnvironment = hostEnvironment;
|
||||
_loggerFactory = loggerFactory;
|
||||
|
||||
_funcParseFn = t => s => JsvReader.GetParseFn(t)(s);
|
||||
|
||||
@@ -171,38 +173,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
return attributes;
|
||||
}
|
||||
|
||||
private void OnWebSocketConnected(WebSocketConnectEventArgs e)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var connection = new WebSocketConnection(e.WebSocket, e.Endpoint, _jsonSerializer, _logger)
|
||||
{
|
||||
OnReceive = ProcessWebSocketMessageReceived,
|
||||
Url = e.Url,
|
||||
QueryString = e.QueryString
|
||||
};
|
||||
|
||||
connection.Closed += OnConnectionClosed;
|
||||
|
||||
lock (_webSocketConnections)
|
||||
{
|
||||
_webSocketConnections.Add(connection);
|
||||
}
|
||||
|
||||
WebSocketConnected?.Invoke(this, new GenericEventArgs<IWebSocketConnection>(connection));
|
||||
}
|
||||
|
||||
private void OnConnectionClosed(object sender, EventArgs e)
|
||||
{
|
||||
lock (_webSocketConnections)
|
||||
{
|
||||
_webSocketConnections.Remove((IWebSocketConnection)sender);
|
||||
}
|
||||
}
|
||||
|
||||
private static Exception GetActualException(Exception ex)
|
||||
{
|
||||
if (ex is AggregateException agg)
|
||||
@@ -230,7 +200,8 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
switch (ex)
|
||||
{
|
||||
case ArgumentException _: return 400;
|
||||
case SecurityException _: return 401;
|
||||
case AuthenticationException _: return 401;
|
||||
case SecurityException _: return 403;
|
||||
case DirectoryNotFoundException _:
|
||||
case FileNotFoundException _:
|
||||
case ResourceNotFoundException _: return 404;
|
||||
@@ -239,81 +210,46 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ErrorHandler(Exception ex, IRequest httpReq, bool logExceptionStackTrace, string urlToLog)
|
||||
private async Task ErrorHandler(Exception ex, IRequest httpReq, int statusCode, string urlToLog, bool ignoreStackTrace)
|
||||
{
|
||||
try
|
||||
if (ignoreStackTrace)
|
||||
{
|
||||
ex = GetActualException(ex);
|
||||
|
||||
if (logExceptionStackTrace)
|
||||
{
|
||||
_logger.LogError(ex, "Error processing request. URL: {Url}", urlToLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogError("Error processing request: {Message}. URL: {Url}", ex.Message.TrimEnd('.'), urlToLog);
|
||||
}
|
||||
|
||||
var httpRes = httpReq.Response;
|
||||
|
||||
if (httpRes.HasStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var statusCode = GetStatusCode(ex);
|
||||
httpRes.StatusCode = statusCode;
|
||||
|
||||
var errContent = NormalizeExceptionMessage(ex.Message);
|
||||
httpRes.ContentType = "text/plain";
|
||||
httpRes.ContentLength = errContent.Length;
|
||||
await httpRes.WriteAsync(errContent).ConfigureAwait(false);
|
||||
_logger.LogError("Error processing request: {Message}. URL: {Url}", ex.Message.TrimEnd('.'), urlToLog);
|
||||
}
|
||||
catch (Exception errorEx)
|
||||
else
|
||||
{
|
||||
_logger.LogError(errorEx, "Error this.ProcessRequest(context)(Exception while writing error to the response). URL: {Url}", urlToLog);
|
||||
_logger.LogError(ex, "Error processing request. URL: {Url}", urlToLog);
|
||||
}
|
||||
|
||||
var httpRes = httpReq.Response;
|
||||
|
||||
if (httpRes.HasStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
httpRes.StatusCode = statusCode;
|
||||
|
||||
var errContent = _hostEnvironment.IsDevelopment()
|
||||
? (NormalizeExceptionMessage(ex) ?? string.Empty)
|
||||
: "Error processing request.";
|
||||
httpRes.ContentType = "text/plain";
|
||||
httpRes.ContentLength = errContent.Length;
|
||||
await httpRes.WriteAsync(errContent).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private string NormalizeExceptionMessage(string msg)
|
||||
private string NormalizeExceptionMessage(Exception ex)
|
||||
{
|
||||
if (msg == null)
|
||||
// Do not expose the exception message for AuthenticationException
|
||||
if (ex is AuthenticationException)
|
||||
{
|
||||
return string.Empty;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Strip any information we don't want to reveal
|
||||
|
||||
msg = msg.Replace(_config.ApplicationPaths.ProgramSystemPath, string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
msg = msg.Replace(_config.ApplicationPaths.ProgramDataPath, string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shut down the Web Service
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
List<IWebSocketConnection> connections;
|
||||
|
||||
lock (_webSocketConnections)
|
||||
{
|
||||
connections = _webSocketConnections.ToList();
|
||||
_webSocketConnections.Clear();
|
||||
}
|
||||
|
||||
foreach (var connection in connections)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error disposing connection");
|
||||
}
|
||||
}
|
||||
return ex.Message
|
||||
?.Replace(_config.ApplicationPaths.ProgramSystemPath, string.Empty, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace(_config.ApplicationPaths.ProgramDataPath, string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static string RemoveQueryStringByKey(string url, string key)
|
||||
@@ -425,33 +361,52 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate a connection from a remote IP address to a URL to see if a redirection to HTTPS is required.
|
||||
/// </summary>
|
||||
/// <returns>True if the request is valid, or false if the request is not valid and an HTTPS redirect is required.</returns>
|
||||
private bool ValidateSsl(string remoteIp, string urlString)
|
||||
{
|
||||
if (_config.Configuration.RequireHttps && _appHost.EnableHttps && !_config.Configuration.IsBehindProxy)
|
||||
if (_config.Configuration.RequireHttps
|
||||
&& _appHost.ListenWithHttps
|
||||
&& !urlString.Contains("https://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (urlString.IndexOf("https://", StringComparison.OrdinalIgnoreCase) == -1)
|
||||
// These are hacks, but if these ever occur on ipv6 in the local network they could be incorrectly redirected
|
||||
if (urlString.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) != -1
|
||||
|| urlString.IndexOf("dlna/", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
// These are hacks, but if these ever occur on ipv6 in the local network they could be incorrectly redirected
|
||||
if (urlString.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) != -1
|
||||
|| urlString.IndexOf("dlna/", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_networkManager.IsInLocalNetwork(remoteIp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!_networkManager.IsInLocalNetwork(remoteIp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task RequestHandler(HttpContext context)
|
||||
{
|
||||
if (context.WebSockets.IsWebSocketRequest)
|
||||
{
|
||||
return WebSocketRequestHandler(context);
|
||||
}
|
||||
|
||||
var request = context.Request;
|
||||
var response = context.Response;
|
||||
var localPath = context.Request.Path.ToString();
|
||||
|
||||
var req = new WebSocketSharpRequest(request, response, request.Path);
|
||||
return RequestHandler(req, request.GetDisplayUrl(), request.Host.ToString(), localPath, context.RequestAborted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable method that can be used to implement a custom handler.
|
||||
/// </summary>
|
||||
public async Task RequestHandler(IHttpRequest httpReq, string urlString, string host, string localPath, CancellationToken cancellationToken)
|
||||
private async Task RequestHandler(IHttpRequest httpReq, string urlString, string host, string localPath, CancellationToken cancellationToken)
|
||||
{
|
||||
var stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
@@ -494,9 +449,10 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
httpRes.StatusCode = 200;
|
||||
httpRes.Headers.Add("Access-Control-Allow-Origin", "*");
|
||||
httpRes.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
|
||||
httpRes.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Authorization, Range, X-MediaBrowser-Token, X-Emby-Authorization");
|
||||
foreach(var (key, value) in GetDefaultCorsHeaders(httpReq))
|
||||
{
|
||||
httpRes.Headers.Add(key, value);
|
||||
}
|
||||
httpRes.ContentType = "text/plain";
|
||||
await httpRes.WriteAsync(string.Empty, cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -536,22 +492,50 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception requestEx)
|
||||
{
|
||||
// Do not handle exceptions manually when in development mode
|
||||
// The framework-defined development exception page will be returned instead
|
||||
if (_hostEnvironment.IsDevelopment())
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
var requestInnerEx = GetActualException(requestEx);
|
||||
var statusCode = GetStatusCode(requestInnerEx);
|
||||
|
||||
bool ignoreStackTrace =
|
||||
ex is SocketException
|
||||
|| ex is IOException
|
||||
|| ex is OperationCanceledException
|
||||
|| ex is SecurityException
|
||||
|| ex is FileNotFoundException;
|
||||
await ErrorHandler(ex, httpReq, !ignoreStackTrace, urlToLog).ConfigureAwait(false);
|
||||
foreach (var (key, value) in GetDefaultCorsHeaders(httpReq))
|
||||
{
|
||||
if (!httpRes.Headers.ContainsKey(key))
|
||||
{
|
||||
httpRes.Headers.Add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
bool ignoreStackTrace =
|
||||
requestInnerEx is SocketException
|
||||
|| requestInnerEx is IOException
|
||||
|| requestInnerEx is OperationCanceledException
|
||||
|| requestInnerEx is SecurityException
|
||||
|| requestInnerEx is AuthenticationException
|
||||
|| requestInnerEx is FileNotFoundException;
|
||||
|
||||
// Do not handle 500 server exceptions manually when in development mode.
|
||||
// Instead, re-throw the exception so it can be handled by the DeveloperExceptionPageMiddleware.
|
||||
// However, do not use the DeveloperExceptionPageMiddleware when the stack trace should be ignored,
|
||||
// because it will log the stack trace when it handles the exception.
|
||||
if (statusCode == 500 && !ignoreStackTrace && _hostEnvironment.IsDevelopment())
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
await ErrorHandler(requestInnerEx, httpReq, statusCode, urlToLog, ignoreStackTrace).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception handlerException)
|
||||
{
|
||||
var aggregateEx = new AggregateException("Error while handling request exception", requestEx, handlerException);
|
||||
_logger.LogError(aggregateEx, "Error while handling exception in response to {Url}", urlToLog);
|
||||
|
||||
if (_hostEnvironment.IsDevelopment())
|
||||
{
|
||||
throw aggregateEx;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -569,6 +553,68 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
private async Task WebSocketRequestHandler(HttpContext context)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("WS {IP} request", context.Connection.RemoteIpAddress);
|
||||
|
||||
WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false);
|
||||
|
||||
var connection = new WebSocketConnection(
|
||||
_loggerFactory.CreateLogger<WebSocketConnection>(),
|
||||
webSocket,
|
||||
context.Connection.RemoteIpAddress,
|
||||
context.Request.Query)
|
||||
{
|
||||
OnReceive = ProcessWebSocketMessageReceived
|
||||
};
|
||||
|
||||
WebSocketConnected?.Invoke(this, new GenericEventArgs<IWebSocketConnection>(connection));
|
||||
|
||||
await connection.ProcessAsync().ConfigureAwait(false);
|
||||
_logger.LogInformation("WS {IP} closed", context.Connection.RemoteIpAddress);
|
||||
}
|
||||
catch (Exception ex) // Otherwise ASP.Net will ignore the exception
|
||||
{
|
||||
_logger.LogError(ex, "WS {IP} WebSocketRequestHandler error", context.Connection.RemoteIpAddress);
|
||||
if (!context.Response.HasStarted)
|
||||
{
|
||||
context.Response.StatusCode = 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the default CORS headers
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public IDictionary<string, string> GetDefaultCorsHeaders(IRequest req)
|
||||
{
|
||||
var origin = req.Headers["Origin"];
|
||||
if (origin == StringValues.Empty)
|
||||
{
|
||||
origin = req.Headers["Host"];
|
||||
if (origin == StringValues.Empty)
|
||||
{
|
||||
origin = "*";
|
||||
}
|
||||
}
|
||||
|
||||
var headers = new Dictionary<string, string>();
|
||||
headers.Add("Access-Control-Allow-Origin", origin);
|
||||
headers.Add("Access-Control-Allow-Credentials", "true");
|
||||
headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
|
||||
headers.Add("Access-Control-Allow-Headers", "Content-Type, Authorization, Range, X-MediaBrowser-Token, X-Emby-Authorization, Cookie");
|
||||
return headers;
|
||||
}
|
||||
|
||||
// Entry point for HttpListener
|
||||
public ServiceHandler GetServiceHandler(IHttpRequest httpReq)
|
||||
{
|
||||
@@ -615,7 +661,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
ResponseFilters = new Action<IRequest, HttpResponse, object>[]
|
||||
{
|
||||
new ResponseFilter(_logger).FilterResponse
|
||||
new ResponseFilter(this, _logger).FilterResponse
|
||||
};
|
||||
}
|
||||
|
||||
@@ -676,11 +722,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
return _jsonSerializer.DeserializeFromStreamAsync(stream, type);
|
||||
}
|
||||
|
||||
public Task ProcessWebSocketRequest(HttpContext context)
|
||||
{
|
||||
return _socketListener.ProcessWebSocketRequest(context);
|
||||
}
|
||||
|
||||
private string NormalizeEmbyRoutePath(string path)
|
||||
{
|
||||
_logger.LogDebug("Normalizing /emby route");
|
||||
@@ -699,28 +740,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
return _baseUrlPrefix + NormalizeUrlPath(path);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the web socket message received.
|
||||
/// </summary>
|
||||
@@ -732,8 +751,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
_logger.LogDebug("Websocket message received: {0}", result.MessageType);
|
||||
|
||||
IEnumerable<Task> GetTasks()
|
||||
{
|
||||
foreach (var x in _webSocketListeners)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<HttpResultFactory> _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IStreamHelper _streamHelper;
|
||||
@@ -50,12 +50,13 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
_fileSystem = fileSystem;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_streamHelper = streamHelper;
|
||||
_logger = loggerfactory.CreateLogger("HttpResultFactory");
|
||||
_logger = loggerfactory.CreateLogger<HttpResultFactory>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the result.
|
||||
/// </summary>
|
||||
/// <param name="requestContext">The request context.</param>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="contentType">Type of the content.</param>
|
||||
/// <param name="responseHeaders">The response headers.</param>
|
||||
@@ -255,16 +256,20 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
{
|
||||
var acceptEncoding = request.Headers[HeaderNames.AcceptEncoding].ToString();
|
||||
|
||||
if (string.IsNullOrEmpty(acceptEncoding))
|
||||
if (!string.IsNullOrEmpty(acceptEncoding))
|
||||
{
|
||||
//if (_brotliCompressor != null && acceptEncoding.IndexOf("br", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
// if (_brotliCompressor != null && acceptEncoding.IndexOf("br", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
// return "br";
|
||||
|
||||
if (acceptEncoding.IndexOf("deflate", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
if (acceptEncoding.Contains("deflate", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "deflate";
|
||||
}
|
||||
|
||||
if (acceptEncoding.IndexOf("gzip", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
if (acceptEncoding.Contains("gzip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "gzip";
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -426,7 +431,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
if (!noCache)
|
||||
{
|
||||
if (!DateTime.TryParseExact(requestContext.Headers[HeaderNames.IfModifiedSince], HttpDateFormat, _enUSculture, DateTimeStyles.AssumeUniversal, out var ifModifiedSinceHeader))
|
||||
if (!DateTime.TryParseExact(requestContext.Headers[HeaderNames.IfModifiedSince], HttpDateFormat, _enUSculture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out var ifModifiedSinceHeader))
|
||||
{
|
||||
_logger.LogDebug("Failed to parse If-Modified-Since header date: {0}", requestContext.Headers[HeaderNames.IfModifiedSince]);
|
||||
return null;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.Server.Implementations.Net;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Emby.Server.Implementations.HttpServer
|
||||
{
|
||||
public interface IHttpListener : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error handler.
|
||||
/// </summary>
|
||||
/// <value>The error handler.</value>
|
||||
Func<Exception, IRequest, bool, bool, Task> ErrorHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the request handler.
|
||||
/// </summary>
|
||||
/// <value>The request handler.</value>
|
||||
Func<IHttpRequest, string, string, string, CancellationToken, Task> RequestHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the web socket handler.
|
||||
/// </summary>
|
||||
/// <value>The web socket handler.</value>
|
||||
Action<WebSocketConnectEventArgs> WebSocketConnected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stops this instance.
|
||||
/// </summary>
|
||||
Task Stop();
|
||||
|
||||
Task ProcessWebSocketRequest(HttpContext ctx);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -13,14 +15,17 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// </summary>
|
||||
public class ResponseFilter
|
||||
{
|
||||
private readonly IHttpServer _server;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ResponseFilter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="server">The HTTP server.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public ResponseFilter(ILogger logger)
|
||||
public ResponseFilter(IHttpServer server, ILogger logger)
|
||||
{
|
||||
_server = server;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -32,10 +37,16 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// <param name="dto">The dto.</param>
|
||||
public void FilterResponse(IRequest req, HttpResponse res, object dto)
|
||||
{
|
||||
foreach(var (key, value) in _server.GetDefaultCorsHeaders(req))
|
||||
{
|
||||
res.Headers.Add(key, value);
|
||||
}
|
||||
// Try to prevent compatibility view
|
||||
res.Headers.Add("Access-Control-Allow-Headers", "Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, Content-Type, Date, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, X-MediaBrowser-Token, X-Emby-Authorization");
|
||||
res.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
|
||||
res.Headers.Add("Access-Control-Allow-Origin", "*");
|
||||
res.Headers["Access-Control-Allow-Headers"] = ("Accept, Accept-Language, Authorization, Cache-Control, " +
|
||||
"Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, " +
|
||||
"Content-Type, Cookie, Date, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, " +
|
||||
"Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, X-MediaBrowser-Token, " +
|
||||
"X-Emby-Authorization");
|
||||
|
||||
if (dto is Exception exception)
|
||||
{
|
||||
@@ -82,6 +93,10 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (inString.Length == 0)
|
||||
{
|
||||
return inString;
|
||||
}
|
||||
|
||||
var newString = new StringBuilder(inString.Length);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Linq;
|
||||
using Emby.Server.Implementations.SocketSharp;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Authentication;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Net;
|
||||
@@ -44,7 +45,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
|
||||
public User Authenticate(HttpRequest request, IAuthenticationAttributes authAttributes)
|
||||
{
|
||||
var req = new WebSocketSharpRequest(request, null, request.Path, _logger);
|
||||
var req = new WebSocketSharpRequest(request, null, request.Path);
|
||||
var user = ValidateUser(req, authAttributes);
|
||||
return user;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
|
||||
if (user == null && auth.UserId != Guid.Empty)
|
||||
{
|
||||
throw new SecurityException("User with Id " + auth.UserId + " not found");
|
||||
throw new AuthenticationException("User with Id " + auth.UserId + " not found");
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
@@ -108,18 +109,12 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
{
|
||||
if (user.Policy.IsDisabled)
|
||||
{
|
||||
throw new SecurityException("User account has been disabled.")
|
||||
{
|
||||
SecurityExceptionType = SecurityExceptionType.Unauthenticated
|
||||
};
|
||||
throw new SecurityException("User account has been disabled.");
|
||||
}
|
||||
|
||||
if (!user.Policy.EnableRemoteAccess && !_networkManager.IsInLocalNetwork(request.RemoteIp))
|
||||
{
|
||||
throw new SecurityException("User account has been disabled.")
|
||||
{
|
||||
SecurityExceptionType = SecurityExceptionType.Unauthenticated
|
||||
};
|
||||
throw new SecurityException("User account has been disabled.");
|
||||
}
|
||||
|
||||
if (!user.Policy.IsAdministrator
|
||||
@@ -128,10 +123,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
{
|
||||
request.Response.Headers.Add("X-Application-Error-Code", "ParentalControl");
|
||||
|
||||
throw new SecurityException("This user account is not allowed access at this time.")
|
||||
{
|
||||
SecurityExceptionType = SecurityExceptionType.ParentalControl
|
||||
};
|
||||
throw new SecurityException("This user account is not allowed access at this time.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,10 +188,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
{
|
||||
if (user == null || !user.Policy.IsAdministrator)
|
||||
{
|
||||
throw new SecurityException("User does not have admin access.")
|
||||
{
|
||||
SecurityExceptionType = SecurityExceptionType.Unauthenticated
|
||||
};
|
||||
throw new SecurityException("User does not have admin access.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,10 +196,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
{
|
||||
if (user == null || !user.Policy.EnableContentDeletion)
|
||||
{
|
||||
throw new SecurityException("User does not have delete access.")
|
||||
{
|
||||
SecurityExceptionType = SecurityExceptionType.Unauthenticated
|
||||
};
|
||||
throw new SecurityException("User does not have delete access.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,10 +204,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
{
|
||||
if (user == null || !user.Policy.EnableContentDownloading)
|
||||
{
|
||||
throw new SecurityException("User does not have download access.")
|
||||
{
|
||||
SecurityExceptionType = SecurityExceptionType.Unauthenticated
|
||||
};
|
||||
throw new SecurityException("User does not have download access.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,14 +219,14 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
{
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
throw new SecurityException("Access token is required.");
|
||||
throw new AuthenticationException("Access token is required.");
|
||||
}
|
||||
|
||||
var info = GetTokenInfo(request);
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
throw new SecurityException("Access token is invalid or expired.");
|
||||
throw new AuthenticationException("Access token is invalid or expired.");
|
||||
}
|
||||
|
||||
//if (!string.IsNullOrEmpty(info.UserId))
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO.Pipelines;
|
||||
using System.Net;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.Server.Implementations.Net;
|
||||
using MediaBrowser.Common.Json;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using UtfUnknown;
|
||||
|
||||
namespace Emby.Server.Implementations.HttpServer
|
||||
{
|
||||
@@ -21,72 +24,53 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<WebSocketConnection> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// The json serializer.
|
||||
/// The json serializer options.
|
||||
/// </summary>
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly JsonSerializerOptions _jsonOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The socket.
|
||||
/// </summary>
|
||||
private readonly IWebSocket _socket;
|
||||
private readonly WebSocket _socket;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WebSocketConnection" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="socket">The socket.</param>
|
||||
/// <param name="remoteEndPoint">The remote end point.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <exception cref="ArgumentNullException">socket</exception>
|
||||
public WebSocketConnection(IWebSocket socket, string remoteEndPoint, IJsonSerializer jsonSerializer, ILogger logger)
|
||||
/// <param name="query">The query.</param>
|
||||
public WebSocketConnection(
|
||||
ILogger<WebSocketConnection> logger,
|
||||
WebSocket socket,
|
||||
IPAddress? remoteEndPoint,
|
||||
IQueryCollection query)
|
||||
{
|
||||
if (socket == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(socket));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(remoteEndPoint))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(remoteEndPoint));
|
||||
}
|
||||
|
||||
if (jsonSerializer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(jsonSerializer));
|
||||
}
|
||||
|
||||
if (logger == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
Id = Guid.NewGuid();
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_socket = socket;
|
||||
_socket.OnReceiveBytes = OnReceiveInternal;
|
||||
|
||||
RemoteEndPoint = remoteEndPoint;
|
||||
_logger = logger;
|
||||
_socket = socket;
|
||||
RemoteEndPoint = remoteEndPoint;
|
||||
QueryString = query;
|
||||
|
||||
socket.Closed += OnSocketClosed;
|
||||
_jsonOptions = JsonDefaults.GetOptions();
|
||||
LastActivityDate = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<EventArgs> Closed;
|
||||
public event EventHandler<EventArgs>? Closed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the remote end point.
|
||||
/// </summary>
|
||||
public string RemoteEndPoint { get; private set; }
|
||||
public IPAddress? RemoteEndPoint { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the receive action.
|
||||
/// </summary>
|
||||
/// <value>The receive action.</value>
|
||||
public Func<WebSocketMessageInfo, Task> OnReceive { get; set; }
|
||||
public Func<WebSocketMessageInfo, Task>? OnReceive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last activity date.
|
||||
@@ -94,23 +78,14 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// <value>The last activity date.</value>
|
||||
public DateTime LastActivityDate { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the id.
|
||||
/// </summary>
|
||||
/// <value>The id.</value>
|
||||
public Guid Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the URL.
|
||||
/// </summary>
|
||||
/// <value>The URL.</value>
|
||||
public string Url { get; set; }
|
||||
/// <inheritdoc />
|
||||
public DateTime LastKeepAliveDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the query string.
|
||||
/// </summary>
|
||||
/// <value>The query string.</value>
|
||||
public IQueryCollection QueryString { get; set; }
|
||||
public IQueryCollection QueryString { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state.
|
||||
@@ -118,70 +93,6 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// <value>The state.</value>
|
||||
public WebSocketState State => _socket.State;
|
||||
|
||||
void OnSocketClosed(object sender, EventArgs e)
|
||||
{
|
||||
Closed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when [receive].
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes.</param>
|
||||
private void OnReceiveInternal(byte[] bytes)
|
||||
{
|
||||
LastActivityDate = DateTime.UtcNow;
|
||||
|
||||
if (OnReceive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var charset = CharsetDetector.DetectFromBytes(bytes).Detected?.EncodingName;
|
||||
|
||||
if (string.Equals(charset, "utf-8", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
OnReceiveInternal(Encoding.UTF8.GetString(bytes, 0, bytes.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
OnReceiveInternal(Encoding.ASCII.GetString(bytes, 0, bytes.Length));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnReceiveInternal(string message)
|
||||
{
|
||||
LastActivityDate = DateTime.UtcNow;
|
||||
|
||||
if (!message.StartsWith("{", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// This info is useful sometimes but also clogs up the log
|
||||
_logger.LogDebug("Received web socket message that is not a json structure: {message}", message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OnReceive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var stub = (WebSocketMessage<object>)_jsonSerializer.DeserializeFromString(message, typeof(WebSocketMessage<object>));
|
||||
|
||||
var info = new WebSocketMessageInfo
|
||||
{
|
||||
MessageType = stub.MessageType,
|
||||
Data = stub.Data?.ToString(),
|
||||
Connection = this
|
||||
};
|
||||
|
||||
OnReceive(info);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error processing web socket message");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message asynchronously.
|
||||
/// </summary>
|
||||
@@ -189,48 +100,144 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="ArgumentNullException">message</exception>
|
||||
public Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
var json = _jsonSerializer.SerializeToString(message);
|
||||
|
||||
return SendAsync(json, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="buffer">The buffer.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendAsync(byte[] buffer, CancellationToken cancellationToken)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
return _socket.SendAsync(buffer, true, cancellationToken);
|
||||
var json = JsonSerializer.SerializeToUtf8Bytes(message, _jsonOptions);
|
||||
return _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task SendAsync(string text, CancellationToken cancellationToken)
|
||||
public async Task ProcessAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
var pipe = new Pipe();
|
||||
var writer = pipe.Writer;
|
||||
|
||||
ValueWebSocketReceiveResult receiveresult;
|
||||
do
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
// Allocate at least 512 bytes from the PipeWriter
|
||||
Memory<byte> memory = writer.GetMemory(512);
|
||||
try
|
||||
{
|
||||
receiveresult = await _socket.ReceiveAsync(memory, cancellationToken);
|
||||
}
|
||||
catch (WebSocketException ex)
|
||||
{
|
||||
_logger.LogWarning("WS {IP} error receiving data: {Message}", RemoteEndPoint, ex.Message);
|
||||
break;
|
||||
}
|
||||
|
||||
int bytesRead = receiveresult.Count;
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Tell the PipeWriter how much was read from the Socket
|
||||
writer.Advance(bytesRead);
|
||||
|
||||
// Make the data available to the PipeReader
|
||||
FlushResult flushResult = await writer.FlushAsync();
|
||||
if (flushResult.IsCompleted)
|
||||
{
|
||||
// The PipeReader stopped reading
|
||||
break;
|
||||
}
|
||||
|
||||
LastActivityDate = DateTime.UtcNow;
|
||||
|
||||
if (receiveresult.EndOfMessage)
|
||||
{
|
||||
await ProcessInternal(pipe.Reader).ConfigureAwait(false);
|
||||
}
|
||||
} while (
|
||||
(_socket.State == WebSocketState.Open || _socket.State == WebSocketState.Connecting)
|
||||
&& receiveresult.MessageType != WebSocketMessageType.Close);
|
||||
|
||||
Closed?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
if (_socket.State == WebSocketState.Open
|
||||
|| _socket.State == WebSocketState.CloseReceived
|
||||
|| _socket.State == WebSocketState.CloseSent)
|
||||
{
|
||||
await _socket.CloseAsync(
|
||||
WebSocketCloseStatus.NormalClosure,
|
||||
string.Empty,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ProcessInternal(PipeReader reader)
|
||||
{
|
||||
ReadResult result = await reader.ReadAsync().ConfigureAwait(false);
|
||||
ReadOnlySequence<byte> buffer = result.Buffer;
|
||||
|
||||
if (OnReceive == null)
|
||||
{
|
||||
// Tell the PipeReader how much of the buffer we have consumed
|
||||
reader.AdvanceTo(buffer.End);
|
||||
return;
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
WebSocketMessage<object> stub;
|
||||
try
|
||||
{
|
||||
|
||||
return _socket.SendAsync(text, true, cancellationToken);
|
||||
if (buffer.IsSingleSegment)
|
||||
{
|
||||
stub = JsonSerializer.Deserialize<WebSocketMessage<object>>(buffer.FirstSpan, _jsonOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
var buf = ArrayPool<byte>.Shared.Rent(Convert.ToInt32(buffer.Length));
|
||||
try
|
||||
{
|
||||
buffer.CopyTo(buf);
|
||||
stub = JsonSerializer.Deserialize<WebSocketMessage<object>>(buf, _jsonOptions);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
// Tell the PipeReader how much of the buffer we have consumed
|
||||
reader.AdvanceTo(buffer.End);
|
||||
_logger.LogError(ex, "Error processing web socket message");
|
||||
return;
|
||||
}
|
||||
|
||||
// Tell the PipeReader how much of the buffer we have consumed
|
||||
reader.AdvanceTo(buffer.End);
|
||||
|
||||
_logger.LogDebug("WS {IP} received message: {@Message}", RemoteEndPoint, stub);
|
||||
|
||||
var info = new WebSocketMessageInfo
|
||||
{
|
||||
MessageType = stub.MessageType,
|
||||
Data = stub.Data?.ToString(), // Data can be null
|
||||
Connection = this
|
||||
};
|
||||
|
||||
if (info.MessageType.Equals("KeepAlive", StringComparison.Ordinal))
|
||||
{
|
||||
await SendKeepAliveResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
await OnReceive(info).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private Task SendKeepAliveResponse()
|
||||
{
|
||||
LastKeepAliveDate = DateTime.UtcNow;
|
||||
return SendAsync(new WebSocketMessage<string>
|
||||
{
|
||||
MessageType = "KeepAlive"
|
||||
}, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -11,12 +11,18 @@ using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Model.IO;
|
||||
using Emby.Server.Implementations.Library;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.IO
|
||||
{
|
||||
public class LibraryMonitor : ILibraryMonitor
|
||||
{
|
||||
private readonly ILogger<LibraryMonitor> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IServerConfigurationManager _configurationManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// The file system watchers.
|
||||
/// </summary>
|
||||
@@ -32,38 +38,6 @@ namespace Emby.Server.Implementations.IO
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, string> _tempIgnoredPaths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Any file name ending in any of these will be ignored by the watchers.
|
||||
/// </summary>
|
||||
private static readonly HashSet<string> _alwaysIgnoreFiles = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"small.jpg",
|
||||
"albumart.jpg",
|
||||
|
||||
// WMC temp recording directories that will constantly be written to
|
||||
"TempRec",
|
||||
"TempSBE"
|
||||
};
|
||||
|
||||
private static readonly string[] _alwaysIgnoreSubstrings = new string[]
|
||||
{
|
||||
// Synology
|
||||
"eaDir",
|
||||
"#recycle",
|
||||
".wd_tv",
|
||||
".actors"
|
||||
};
|
||||
|
||||
private static readonly HashSet<string> _alwaysIgnoreExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
// thumbs.db
|
||||
".db",
|
||||
|
||||
// bts sync files
|
||||
".bts",
|
||||
".sync"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Add the path to our temporary ignore list. Use when writing to a path within our listening scope.
|
||||
/// </summary>
|
||||
@@ -113,34 +87,23 @@ namespace Emby.Server.Implementations.IO
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error in ReportFileSystemChanged for {path}", path);
|
||||
_logger.LogError(ex, "Error in ReportFileSystemChanged for {path}", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the logger.
|
||||
/// </summary>
|
||||
/// <value>The logger.</value>
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
private ILibraryManager LibraryManager { get; set; }
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryMonitor" /> class.
|
||||
/// </summary>
|
||||
public LibraryMonitor(
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<LibraryMonitor> logger,
|
||||
ILibraryManager libraryManager,
|
||||
IServerConfigurationManager configurationManager,
|
||||
IFileSystem fileSystem)
|
||||
{
|
||||
LibraryManager = libraryManager;
|
||||
Logger = loggerFactory.CreateLogger(GetType().Name);
|
||||
ConfigurationManager = configurationManager;
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
_configurationManager = configurationManager;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
@@ -151,7 +114,7 @@ namespace Emby.Server.Implementations.IO
|
||||
return false;
|
||||
}
|
||||
|
||||
var options = LibraryManager.GetLibraryOptions(item);
|
||||
var options = _libraryManager.GetLibraryOptions(item);
|
||||
|
||||
if (options != null)
|
||||
{
|
||||
@@ -163,12 +126,12 @@ namespace Emby.Server.Implementations.IO
|
||||
|
||||
public void Start()
|
||||
{
|
||||
LibraryManager.ItemAdded += OnLibraryManagerItemAdded;
|
||||
LibraryManager.ItemRemoved += OnLibraryManagerItemRemoved;
|
||||
_libraryManager.ItemAdded += OnLibraryManagerItemAdded;
|
||||
_libraryManager.ItemRemoved += OnLibraryManagerItemRemoved;
|
||||
|
||||
var pathsToWatch = new List<string>();
|
||||
|
||||
var paths = LibraryManager
|
||||
var paths = _libraryManager
|
||||
.RootFolder
|
||||
.Children
|
||||
.Where(IsLibraryMonitorEnabled)
|
||||
@@ -261,7 +224,7 @@ namespace Emby.Server.Implementations.IO
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
// Seeing a crash in the mono runtime due to an exception being thrown on a different thread
|
||||
Logger.LogInformation("Skipping realtime monitor for {Path} because the path does not exist", path);
|
||||
_logger.LogInformation("Skipping realtime monitor for {Path} because the path does not exist", path);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -297,7 +260,7 @@ namespace Emby.Server.Implementations.IO
|
||||
if (_fileSystemWatchers.TryAdd(path, newWatcher))
|
||||
{
|
||||
newWatcher.EnableRaisingEvents = true;
|
||||
Logger.LogInformation("Watching directory " + path);
|
||||
_logger.LogInformation("Watching directory " + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -307,7 +270,7 @@ namespace Emby.Server.Implementations.IO
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error watching path: {path}", path);
|
||||
_logger.LogError(ex, "Error watching path: {path}", path);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -333,7 +296,7 @@ namespace Emby.Server.Implementations.IO
|
||||
{
|
||||
using (watcher)
|
||||
{
|
||||
Logger.LogInformation("Stopping directory watching for path {Path}", watcher.Path);
|
||||
_logger.LogInformation("Stopping directory watching for path {Path}", watcher.Path);
|
||||
|
||||
watcher.Created -= OnWatcherChanged;
|
||||
watcher.Deleted -= OnWatcherChanged;
|
||||
@@ -372,7 +335,7 @@ namespace Emby.Server.Implementations.IO
|
||||
var ex = e.GetException();
|
||||
var dw = (FileSystemWatcher)sender;
|
||||
|
||||
Logger.LogError(ex, "Error in Directory watcher for: {Path}", dw.Path);
|
||||
_logger.LogError(ex, "Error in Directory watcher for: {Path}", dw.Path);
|
||||
|
||||
DisposeWatcher(dw, true);
|
||||
}
|
||||
@@ -390,7 +353,7 @@ namespace Emby.Server.Implementations.IO
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Exception in ReportFileSystemChanged. Path: {FullPath}", e.FullPath);
|
||||
_logger.LogError(ex, "Exception in ReportFileSystemChanged. Path: {FullPath}", e.FullPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,12 +364,7 @@ namespace Emby.Server.Implementations.IO
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
var monitorPath = !string.IsNullOrEmpty(filename) &&
|
||||
!_alwaysIgnoreFiles.Contains(filename) &&
|
||||
!_alwaysIgnoreExtensions.Contains(Path.GetExtension(path)) &&
|
||||
_alwaysIgnoreSubstrings.All(i => path.IndexOf(i, StringComparison.OrdinalIgnoreCase) == -1);
|
||||
var monitorPath = !IgnorePatterns.ShouldIgnore(path);
|
||||
|
||||
// Ignore certain files
|
||||
var tempIgnorePaths = _tempIgnoredPaths.Keys.ToList();
|
||||
@@ -416,13 +374,13 @@ namespace Emby.Server.Implementations.IO
|
||||
{
|
||||
if (_fileSystem.AreEqual(i, path))
|
||||
{
|
||||
Logger.LogDebug("Ignoring change to {Path}", path);
|
||||
_logger.LogDebug("Ignoring change to {Path}", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_fileSystem.ContainsSubPath(i, path))
|
||||
{
|
||||
Logger.LogDebug("Ignoring change to {Path}", path);
|
||||
_logger.LogDebug("Ignoring change to {Path}", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -430,7 +388,7 @@ namespace Emby.Server.Implementations.IO
|
||||
var parent = Path.GetDirectoryName(i);
|
||||
if (!string.IsNullOrEmpty(parent) && _fileSystem.AreEqual(parent, path))
|
||||
{
|
||||
Logger.LogDebug("Ignoring change to {Path}", path);
|
||||
_logger.LogDebug("Ignoring change to {Path}", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -485,7 +443,7 @@ namespace Emby.Server.Implementations.IO
|
||||
}
|
||||
}
|
||||
|
||||
var newRefresher = new FileRefresher(path, ConfigurationManager, LibraryManager, Logger);
|
||||
var newRefresher = new FileRefresher(path, _configurationManager, _libraryManager, _logger);
|
||||
newRefresher.Completed += NewRefresher_Completed;
|
||||
_activeRefreshers.Add(newRefresher);
|
||||
}
|
||||
@@ -502,8 +460,8 @@ namespace Emby.Server.Implementations.IO
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
LibraryManager.ItemAdded -= OnLibraryManagerItemAdded;
|
||||
LibraryManager.ItemRemoved -= OnLibraryManagerItemRemoved;
|
||||
_libraryManager.ItemAdded -= OnLibraryManagerItemAdded;
|
||||
_libraryManager.ItemRemoved -= OnLibraryManagerItemRemoved;
|
||||
|
||||
foreach (var watcher in _fileSystemWatchers.Values.ToList())
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Emby.Server.Implementations.IO
|
||||
/// </summary>
|
||||
public class ManagedFileSystem : IFileSystem
|
||||
{
|
||||
protected ILogger Logger;
|
||||
protected ILogger<ManagedFileSystem> Logger;
|
||||
|
||||
private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
|
||||
private readonly string _tempPath;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
||||
namespace Emby.Server.Implementations
|
||||
{
|
||||
public interface IStartupOptions
|
||||
@@ -36,5 +40,10 @@ namespace Emby.Server.Implementations
|
||||
/// Gets the value of the --plugin-manifest-url command line option.
|
||||
/// </summary>
|
||||
string PluginManifestUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the --published-server-url command line option.
|
||||
/// </summary>
|
||||
Uri PublishedServerUrl { get; }
|
||||
}
|
||||
}
|
||||
|
||||
60
Emby.Server.Implementations/Images/ArtistImageProvider.cs
Normal file
60
Emby.Server.Implementations/Images/ArtistImageProvider.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Emby.Server.Implementations.Images;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
namespace Emby.Server.Implementations.Images
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ArtistImageProvider.
|
||||
/// </summary>
|
||||
public class ArtistImageProvider : BaseDynamicImageProvider<MusicArtist>
|
||||
{
|
||||
/// <summary>
|
||||
/// The library manager.
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public ArtistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get children objects used to create an artist image.
|
||||
/// </summary>
|
||||
/// <param name="item">The artist used to create the image.</param>
|
||||
/// <returns>Any relevant children objects.</returns>
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
return Array.Empty<BaseItem>();
|
||||
|
||||
// TODO enable this when BaseDynamicImageProvider objects are configurable
|
||||
// return _libraryManager.GetItemList(new InternalItemsQuery
|
||||
// {
|
||||
// ArtistIds = new[] { item.Id },
|
||||
// IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
|
||||
// OrderBy = new[] { (ItemSortBy.Random, SortOrder.Ascending) },
|
||||
// Limit = 4,
|
||||
// Recursive = true,
|
||||
// ImageTypes = new[] { ImageType.Primary },
|
||||
// DtoOptions = new DtoOptions(false)
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,8 @@ namespace Emby.Server.Implementations.Images
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
protected virtual string CreateImage(BaseItem item,
|
||||
protected virtual string CreateImage(
|
||||
BaseItem item,
|
||||
IReadOnlyCollection<BaseItem> itemsWithImages,
|
||||
string outputPathWithoutExtension,
|
||||
ImageType imageType,
|
||||
@@ -214,7 +215,12 @@ namespace Emby.Server.Implementations.Images
|
||||
|
||||
if (imageType == ImageType.Primary)
|
||||
{
|
||||
if (item is UserView || item is Playlist || item is MusicGenre || item is Genre || item is PhotoAlbum)
|
||||
if (item is UserView
|
||||
|| item is Playlist
|
||||
|| item is MusicGenre
|
||||
|| item is Genre
|
||||
|| item is PhotoAlbum
|
||||
|| item is MusicArtist)
|
||||
{
|
||||
return CreateSquareCollage(item, itemsWithImages, outputPath);
|
||||
}
|
||||
@@ -225,7 +231,7 @@ namespace Emby.Server.Implementations.Images
|
||||
throw new ArgumentException("Unexpected image type", nameof(imageType));
|
||||
}
|
||||
|
||||
public bool HasChanged(BaseItem item, IDirectoryService directoryServicee)
|
||||
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
|
||||
{
|
||||
if (!Supports(item))
|
||||
{
|
||||
@@ -236,6 +242,7 @@ namespace Emby.Server.Implementations.Images
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SupportedImages.Contains(ImageType.Thumb) && HasChanged(item, ImageType.Thumb))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -11,7 +13,7 @@ using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
namespace Emby.Server.Implementations.UserViews
|
||||
namespace Emby.Server.Implementations.Images
|
||||
{
|
||||
public class CollectionFolderImageProvider : BaseDynamicImageProvider<CollectionFolder>
|
||||
{
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -14,18 +16,16 @@ using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace Emby.Server.Implementations.UserViews
|
||||
namespace Emby.Server.Implementations.Images
|
||||
{
|
||||
public class DynamicImageProvider : BaseDynamicImageProvider<UserView>
|
||||
{
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public DynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, IUserManager userManager, ILibraryManager libraryManager)
|
||||
public DynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, IUserManager userManager)
|
||||
: base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Emby.Server.Implementations.Images;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
@@ -11,7 +13,7 @@ using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
namespace Emby.Server.Implementations.UserViews
|
||||
namespace Emby.Server.Implementations.Images
|
||||
{
|
||||
public abstract class BaseFolderImageProvider<T> : BaseDynamicImageProvider<T>
|
||||
where T : Folder, new()
|
||||
@@ -75,16 +77,12 @@ namespace Emby.Server.Implementations.UserViews
|
||||
return false;
|
||||
}
|
||||
|
||||
var folder = item as Folder;
|
||||
if (folder != null)
|
||||
if (item is Folder && item.IsTopParent)
|
||||
{
|
||||
if (folder.IsTopParent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
//return item.SourceType == SourceType.Library;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Emby.Server.Implementations.Images;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
@@ -9,66 +9,21 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
namespace Emby.Server.Implementations.Playlists
|
||||
namespace Emby.Server.Implementations.Images
|
||||
{
|
||||
public class PlaylistImageProvider : BaseDynamicImageProvider<Playlist>
|
||||
{
|
||||
public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
var playlist = (Playlist)item;
|
||||
|
||||
return playlist.GetManageableItems()
|
||||
.Select(i =>
|
||||
{
|
||||
var subItem = i.Item2;
|
||||
|
||||
var episode = subItem as Episode;
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
var series = episode.Series;
|
||||
if (series != null && series.HasImage(ImageType.Primary))
|
||||
{
|
||||
return series;
|
||||
}
|
||||
}
|
||||
|
||||
if (subItem.HasImage(ImageType.Primary))
|
||||
{
|
||||
return subItem;
|
||||
}
|
||||
|
||||
var parent = subItem.GetOwner() ?? subItem.GetParent();
|
||||
|
||||
if (parent != null && parent.HasImage(ImageType.Primary))
|
||||
{
|
||||
if (parent is MusicAlbum)
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
.Where(i => i != null)
|
||||
.GroupBy(x => x.Id)
|
||||
.Select(x => x.First())
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class MusicGenreImageProvider.
|
||||
/// </summary>
|
||||
public class MusicGenreImageProvider : BaseDynamicImageProvider<MusicGenre>
|
||||
{
|
||||
/// <summary>
|
||||
/// The library manager.
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public MusicGenreImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
||||
@@ -76,6 +31,11 @@ namespace Emby.Server.Implementations.Playlists
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get children objects used to create an music genre image.
|
||||
/// </summary>
|
||||
/// <param name="item">The music genre used to create the image.</param>
|
||||
/// <returns>Any relevant children objects.</returns>
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
return _libraryManager.GetItemList(new InternalItemsQuery
|
||||
@@ -91,8 +51,14 @@ namespace Emby.Server.Implementations.Playlists
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GenreImageProvider.
|
||||
/// </summary>
|
||||
public class GenreImageProvider : BaseDynamicImageProvider<Genre>
|
||||
{
|
||||
/// <summary>
|
||||
/// The library manager.
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
public GenreImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
||||
@@ -100,6 +66,11 @@ namespace Emby.Server.Implementations.Playlists
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get children objects used to create an genre image.
|
||||
/// </summary>
|
||||
/// <param name="item">The genre used to create the image.</param>
|
||||
/// <returns>Any relevant children objects.</returns>
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
return _libraryManager.GetItemList(new InternalItemsQuery
|
||||
66
Emby.Server.Implementations/Images/PlaylistImageProvider.cs
Normal file
66
Emby.Server.Implementations/Images/PlaylistImageProvider.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace Emby.Server.Implementations.Images
|
||||
{
|
||||
public class PlaylistImageProvider : BaseDynamicImageProvider<Playlist>
|
||||
{
|
||||
public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
var playlist = (Playlist)item;
|
||||
|
||||
return playlist.GetManageableItems()
|
||||
.Select(i =>
|
||||
{
|
||||
var subItem = i.Item2;
|
||||
|
||||
var episode = subItem as Episode;
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
var series = episode.Series;
|
||||
if (series != null && series.HasImage(ImageType.Primary))
|
||||
{
|
||||
return series;
|
||||
}
|
||||
}
|
||||
|
||||
if (subItem.HasImage(ImageType.Primary))
|
||||
{
|
||||
return subItem;
|
||||
}
|
||||
|
||||
var parent = subItem.GetOwner() ?? subItem.GetParent();
|
||||
|
||||
if (parent != null && parent.HasImage(ImageType.Primary))
|
||||
{
|
||||
if (parent is MusicAlbum)
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
.Where(i => i != null)
|
||||
.GroupBy(x => x.Id)
|
||||
.Select(x => x.First())
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
@@ -16,32 +14,6 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
/// Any folder named in this list will be ignored
|
||||
/// </summary>
|
||||
private static readonly string[] _ignoreFolders =
|
||||
{
|
||||
"metadata",
|
||||
"ps3_update",
|
||||
"ps3_vprm",
|
||||
"extrafanart",
|
||||
"extrathumbs",
|
||||
".actors",
|
||||
".wd_tv",
|
||||
|
||||
// Synology
|
||||
"@eaDir",
|
||||
"eaDir",
|
||||
"#recycle",
|
||||
|
||||
// Qnap
|
||||
"@Recycle",
|
||||
".@__thumb",
|
||||
"$RECYCLE.BIN",
|
||||
"System Volume Information",
|
||||
".grab",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CoreResolutionIgnoreRule"/> class.
|
||||
/// </summary>
|
||||
@@ -60,23 +32,15 @@ namespace Emby.Server.Implementations.Library
|
||||
return false;
|
||||
}
|
||||
|
||||
var filename = fileInfo.Name;
|
||||
|
||||
// Ignore hidden files on UNIX
|
||||
if (Environment.OSVersion.Platform != PlatformID.Win32NT
|
||||
&& filename[0] == '.')
|
||||
if (IgnorePatterns.ShouldIgnore(fileInfo.FullName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var filename = fileInfo.Name;
|
||||
|
||||
if (fileInfo.IsDirectory)
|
||||
{
|
||||
// Ignore any folders in our list
|
||||
if (_ignoreFolders.Contains(filename, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
// Ignore trailer folders but allow it at the collection level
|
||||
@@ -109,11 +73,6 @@ namespace Emby.Server.Implementations.Library
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore samples
|
||||
Match m = Regex.Match(filename, @"\bsample\b", RegexOptions.IgnoreCase);
|
||||
|
||||
return m.Success;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
if (resolvedUser == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(resolvedUser));
|
||||
throw new AuthenticationException($"Specified user does not exist.");
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
@@ -135,43 +135,5 @@ namespace Emby.Server.Implementations.Library
|
||||
? null
|
||||
: Hex.Encode(PasswordHash.Parse(user.EasyPassword).Hash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hashed string.
|
||||
/// </summary>
|
||||
public string GetHashedString(User user, string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(user.Password))
|
||||
{
|
||||
return _cryptographyProvider.CreatePasswordHash(str).ToString();
|
||||
}
|
||||
|
||||
// TODO: make use of iterations parameter?
|
||||
PasswordHash passwordHash = PasswordHash.Parse(user.Password);
|
||||
var salt = passwordHash.Salt.ToArray();
|
||||
return new PasswordHash(
|
||||
passwordHash.Id,
|
||||
_cryptographyProvider.ComputeHash(
|
||||
passwordHash.Id,
|
||||
Encoding.UTF8.GetBytes(str),
|
||||
salt),
|
||||
salt,
|
||||
passwordHash.Parameters.ToDictionary(x => x.Key, y => y.Value)).ToString();
|
||||
}
|
||||
|
||||
public ReadOnlySpan<byte> GetHashed(User user, string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(user.Password))
|
||||
{
|
||||
return _cryptographyProvider.CreatePasswordHash(str).Hash;
|
||||
}
|
||||
|
||||
// TODO: make use of iterations parameter?
|
||||
PasswordHash passwordHash = PasswordHash.Parse(user.Password);
|
||||
return _cryptographyProvider.ComputeHash(
|
||||
passwordHash.Id,
|
||||
Encoding.UTF8.GetBytes(str),
|
||||
passwordHash.Salt.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
Emby.Server.Implementations/Library/IgnorePatterns.cs
Normal file
74
Emby.Server.Implementations/Library/IgnorePatterns.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Linq;
|
||||
using DotNet.Globbing;
|
||||
|
||||
namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// Glob patterns for files to ignore
|
||||
/// </summary>
|
||||
public static class IgnorePatterns
|
||||
{
|
||||
/// <summary>
|
||||
/// Files matching these glob patterns will be ignored
|
||||
/// </summary>
|
||||
public static readonly string[] Patterns = new string[]
|
||||
{
|
||||
"**/small.jpg",
|
||||
"**/albumart.jpg",
|
||||
"**/*sample*",
|
||||
|
||||
// Directories
|
||||
"**/metadata/**",
|
||||
"**/ps3_update/**",
|
||||
"**/ps3_vprm/**",
|
||||
"**/extrafanart/**",
|
||||
"**/extrathumbs/**",
|
||||
"**/.actors/**",
|
||||
"**/.wd_tv/**",
|
||||
"**/lost+found/**",
|
||||
|
||||
// WMC temp recording directories that will constantly be written to
|
||||
"**/TempRec/**",
|
||||
"**/TempSBE/**",
|
||||
|
||||
// Synology
|
||||
"**/eaDir/**",
|
||||
"**/@eaDir/**",
|
||||
"**/#recycle/**",
|
||||
|
||||
// Qnap
|
||||
"**/@Recycle/**",
|
||||
"**/.@__thumb/**",
|
||||
"**/$RECYCLE.BIN/**",
|
||||
"**/System Volume Information/**",
|
||||
"**/.grab/**",
|
||||
|
||||
// Unix hidden files and directories
|
||||
"**/.*/**",
|
||||
|
||||
// thumbs.db
|
||||
"**/thumbs.db",
|
||||
|
||||
// bts sync files
|
||||
"**/*.bts",
|
||||
"**/*.sync",
|
||||
};
|
||||
|
||||
private static readonly GlobOptions _globOptions = new GlobOptions
|
||||
{
|
||||
Evaluation = {
|
||||
CaseInsensitive = true
|
||||
}
|
||||
};
|
||||
|
||||
private static readonly Glob[] _globs = Patterns.Select(p => Glob.Parse(p, _globOptions)).ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the supplied path should be ignored
|
||||
/// </summary>
|
||||
public static bool ShouldIgnore(string path)
|
||||
{
|
||||
return _globs.Any(g => g.IsMatch(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -35,6 +36,7 @@ using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
@@ -50,13 +52,34 @@ using VideoResolver = Emby.Naming.Video.VideoResolver;
|
||||
namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// Class LibraryManager
|
||||
/// Class LibraryManager.
|
||||
/// </summary>
|
||||
public class LibraryManager : ILibraryManager
|
||||
{
|
||||
private readonly ILogger<LibraryManager> _logger;
|
||||
private readonly ITaskManager _taskManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IUserDataManager _userDataRepository;
|
||||
private readonly IServerConfigurationManager _configurationManager;
|
||||
private readonly Lazy<ILibraryMonitor> _libraryMonitorFactory;
|
||||
private readonly Lazy<IProviderManager> _providerManagerFactory;
|
||||
private readonly Lazy<IUserViewManager> _userviewManagerFactory;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IItemRepository _itemRepository;
|
||||
private readonly ConcurrentDictionary<Guid, BaseItem> _libraryItemsCache;
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
|
||||
private NamingOptions _namingOptions;
|
||||
private string[] _videoFileExtensions;
|
||||
|
||||
private ILibraryMonitor LibraryMonitor => _libraryMonitorFactory.Value;
|
||||
|
||||
private IProviderManager ProviderManager => _providerManagerFactory.Value;
|
||||
|
||||
private IUserViewManager UserViewManager => _userviewManagerFactory.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the postscan tasks.
|
||||
/// </summary>
|
||||
@@ -89,12 +112,6 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <value>The comparers.</value>
|
||||
private IBaseItemComparer[] Comparers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the active item repository
|
||||
/// </summary>
|
||||
/// <value>The item repository.</value>
|
||||
public IItemRepository ItemRepository { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [item added].
|
||||
/// </summary>
|
||||
@@ -110,90 +127,56 @@ namespace Emby.Server.Implementations.Library
|
||||
/// </summary>
|
||||
public event EventHandler<ItemChangeEventArgs> ItemRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// The _task manager
|
||||
/// </summary>
|
||||
private readonly ITaskManager _taskManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _user manager
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _user data repository
|
||||
/// </summary>
|
||||
private readonly IUserDataManager _userDataRepository;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration manager.
|
||||
/// </summary>
|
||||
/// <value>The configuration manager.</value>
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
private readonly Func<ILibraryMonitor> _libraryMonitorFactory;
|
||||
private readonly Func<IProviderManager> _providerManagerFactory;
|
||||
private readonly Func<IUserViewManager> _userviewManager;
|
||||
public bool IsScanRunning { get; private set; }
|
||||
|
||||
private IServerApplicationHost _appHost;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
|
||||
/// <summary>
|
||||
/// The _library items cache
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<Guid, BaseItem> _libraryItemsCache;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the library items cache.
|
||||
/// </summary>
|
||||
/// <value>The library items cache.</value>
|
||||
private ConcurrentDictionary<Guid, BaseItem> LibraryItemsCache => _libraryItemsCache;
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryManager" /> class.
|
||||
/// </summary>
|
||||
/// <param name="appHost">The application host</param>
|
||||
/// <param name="loggerFactory">The logger factory.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="taskManager">The task manager.</param>
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
/// <param name="configurationManager">The configuration manager.</param>
|
||||
/// <param name="userDataRepository">The user data repository.</param>
|
||||
/// <param name="libraryMonitorFactory">The library monitor.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="providerManagerFactory">The provider manager.</param>
|
||||
/// <param name="userviewManagerFactory">The userview manager.</param>
|
||||
/// <param name="mediaEncoder">The media encoder.</param>
|
||||
/// <param name="itemRepository">The item repository.</param>
|
||||
/// <param name="imageProcessor">The image processor.</param>
|
||||
public LibraryManager(
|
||||
IServerApplicationHost appHost,
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<LibraryManager> logger,
|
||||
ITaskManager taskManager,
|
||||
IUserManager userManager,
|
||||
IServerConfigurationManager configurationManager,
|
||||
IUserDataManager userDataRepository,
|
||||
Func<ILibraryMonitor> libraryMonitorFactory,
|
||||
Lazy<ILibraryMonitor> libraryMonitorFactory,
|
||||
IFileSystem fileSystem,
|
||||
Func<IProviderManager> providerManagerFactory,
|
||||
Func<IUserViewManager> userviewManager,
|
||||
IMediaEncoder mediaEncoder)
|
||||
Lazy<IProviderManager> providerManagerFactory,
|
||||
Lazy<IUserViewManager> userviewManagerFactory,
|
||||
IMediaEncoder mediaEncoder,
|
||||
IItemRepository itemRepository,
|
||||
IImageProcessor imageProcessor)
|
||||
{
|
||||
_appHost = appHost;
|
||||
_logger = loggerFactory.CreateLogger(nameof(LibraryManager));
|
||||
_logger = logger;
|
||||
_taskManager = taskManager;
|
||||
_userManager = userManager;
|
||||
ConfigurationManager = configurationManager;
|
||||
_configurationManager = configurationManager;
|
||||
_userDataRepository = userDataRepository;
|
||||
_libraryMonitorFactory = libraryMonitorFactory;
|
||||
_fileSystem = fileSystem;
|
||||
_providerManagerFactory = providerManagerFactory;
|
||||
_userviewManager = userviewManager;
|
||||
_userviewManagerFactory = userviewManagerFactory;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_itemRepository = itemRepository;
|
||||
_imageProcessor = imageProcessor;
|
||||
|
||||
_libraryItemsCache = new ConcurrentDictionary<Guid, BaseItem>();
|
||||
|
||||
ConfigurationManager.ConfigurationUpdated += ConfigurationUpdated;
|
||||
_configurationManager.ConfigurationUpdated += ConfigurationUpdated;
|
||||
|
||||
RecordConfigurationValues(configurationManager.Configuration);
|
||||
}
|
||||
@@ -272,7 +255,7 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void ConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
var config = ConfigurationManager.Configuration;
|
||||
var config = _configurationManager.Configuration;
|
||||
|
||||
var wizardChanged = config.IsStartupWizardCompleted != _wizardCompleted;
|
||||
|
||||
@@ -306,7 +289,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
LibraryItemsCache.AddOrUpdate(item.Id, item, delegate { return item; });
|
||||
_libraryItemsCache.AddOrUpdate(item.Id, item, delegate { return item; });
|
||||
}
|
||||
|
||||
public void DeleteItem(BaseItem item, DeleteOptions options)
|
||||
@@ -437,10 +420,10 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
item.SetParent(null);
|
||||
|
||||
ItemRepository.DeleteItem(item.Id);
|
||||
_itemRepository.DeleteItem(item.Id);
|
||||
foreach (var child in children)
|
||||
{
|
||||
ItemRepository.DeleteItem(child.Id);
|
||||
_itemRepository.DeleteItem(child.Id);
|
||||
}
|
||||
|
||||
_libraryItemsCache.TryRemove(item.Id, out BaseItem removed);
|
||||
@@ -509,15 +492,15 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
if (key.StartsWith(ConfigurationManager.ApplicationPaths.ProgramDataPath, StringComparison.Ordinal))
|
||||
if (key.StartsWith(_configurationManager.ApplicationPaths.ProgramDataPath, StringComparison.Ordinal))
|
||||
{
|
||||
// Try to normalize paths located underneath program-data in an attempt to make them more portable
|
||||
key = key.Substring(ConfigurationManager.ApplicationPaths.ProgramDataPath.Length)
|
||||
key = key.Substring(_configurationManager.ApplicationPaths.ProgramDataPath.Length)
|
||||
.TrimStart(new[] { '/', '\\' })
|
||||
.Replace("/", "\\");
|
||||
}
|
||||
|
||||
if (forceCaseInsensitive || !ConfigurationManager.Configuration.EnableCaseSensitiveItemIds)
|
||||
if (forceCaseInsensitive || !_configurationManager.Configuration.EnableCaseSensitiveItemIds)
|
||||
{
|
||||
key = key.ToLowerInvariant();
|
||||
}
|
||||
@@ -527,8 +510,8 @@ namespace Emby.Server.Implementations.Library
|
||||
return key.GetMD5();
|
||||
}
|
||||
|
||||
public BaseItem ResolvePath(FileSystemMetadata fileInfo, Folder parent = null)
|
||||
=> ResolvePath(fileInfo, new DirectoryService(_fileSystem), null, parent);
|
||||
public BaseItem ResolvePath(FileSystemMetadata fileInfo, Folder parent = null, bool allowIgnorePath = true)
|
||||
=> ResolvePath(fileInfo, new DirectoryService(_fileSystem), null, parent, allowIgnorePath: allowIgnorePath);
|
||||
|
||||
private BaseItem ResolvePath(
|
||||
FileSystemMetadata fileInfo,
|
||||
@@ -536,7 +519,8 @@ namespace Emby.Server.Implementations.Library
|
||||
IItemResolver[] resolvers,
|
||||
Folder parent = null,
|
||||
string collectionType = null,
|
||||
LibraryOptions libraryOptions = null)
|
||||
LibraryOptions libraryOptions = null,
|
||||
bool allowIgnorePath = true)
|
||||
{
|
||||
if (fileInfo == null)
|
||||
{
|
||||
@@ -550,7 +534,7 @@ namespace Emby.Server.Implementations.Library
|
||||
collectionType = GetContentTypeOverride(fullPath, true);
|
||||
}
|
||||
|
||||
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService)
|
||||
var args = new ItemResolveArgs(_configurationManager.ApplicationPaths, directoryService)
|
||||
{
|
||||
Parent = parent,
|
||||
Path = fullPath,
|
||||
@@ -560,7 +544,7 @@ namespace Emby.Server.Implementations.Library
|
||||
};
|
||||
|
||||
// Return null if ignore rules deem that we should do so
|
||||
if (IgnoreFile(args.FileInfo, args.Parent))
|
||||
if (allowIgnorePath && IgnoreFile(args.FileInfo, args.Parent))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -720,11 +704,13 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <exception cref="InvalidOperationException">Cannot create the root folder until plugins have loaded.</exception>
|
||||
public AggregateFolder CreateRootFolder()
|
||||
{
|
||||
var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath;
|
||||
var rootFolderPath = _configurationManager.ApplicationPaths.RootFolderPath;
|
||||
|
||||
Directory.CreateDirectory(rootFolderPath);
|
||||
|
||||
var rootFolder = GetItemById(GetNewItemId(rootFolderPath, typeof(AggregateFolder))) as AggregateFolder ?? ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(rootFolderPath))).DeepCopy<Folder, AggregateFolder>();
|
||||
var rootFolder = GetItemById(GetNewItemId(rootFolderPath, typeof(AggregateFolder))) as AggregateFolder ??
|
||||
((Folder) ResolvePath(_fileSystem.GetDirectoryInfo(rootFolderPath), allowIgnorePath: false))
|
||||
.DeepCopy<Folder, AggregateFolder>();
|
||||
|
||||
// In case program data folder was moved
|
||||
if (!string.Equals(rootFolder.Path, rootFolderPath, StringComparison.Ordinal))
|
||||
@@ -734,7 +720,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
// Add in the plug-in folders
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "playlists");
|
||||
var path = Path.Combine(_configurationManager.ApplicationPaths.DataPath, "playlists");
|
||||
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
@@ -786,7 +772,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
if (_userRootFolder == null)
|
||||
{
|
||||
var userRootPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var userRootPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
|
||||
_logger.LogDebug("Creating userRootPath at {path}", userRootPath);
|
||||
Directory.CreateDirectory(userRootPath);
|
||||
@@ -805,7 +791,7 @@ namespace Emby.Server.Implementations.Library
|
||||
if (tmpItem == null)
|
||||
{
|
||||
_logger.LogDebug("Creating new userRootFolder with DeepCopy");
|
||||
tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath))).DeepCopy<Folder, UserRootFolder>();
|
||||
tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath), allowIgnorePath: false)).DeepCopy<Folder, UserRootFolder>();
|
||||
}
|
||||
|
||||
// In case program data folder was moved
|
||||
@@ -980,7 +966,7 @@ namespace Emby.Server.Implementations.Library
|
||||
where T : BaseItem, new()
|
||||
{
|
||||
var path = getPathFn(name);
|
||||
var forceCaseInsensitiveId = ConfigurationManager.Configuration.EnableNormalizedItemByNameIds;
|
||||
var forceCaseInsensitiveId = _configurationManager.Configuration.EnableNormalizedItemByNameIds;
|
||||
return GetNewItemIdInternal(path, typeof(T), forceCaseInsensitiveId);
|
||||
}
|
||||
|
||||
@@ -994,7 +980,7 @@ namespace Emby.Server.Implementations.Library
|
||||
public Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
// Ensure the location is available.
|
||||
Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath);
|
||||
Directory.CreateDirectory(_configurationManager.ApplicationPaths.PeoplePath);
|
||||
|
||||
return new PeopleValidator(this, _logger, _fileSystem).ValidatePeople(cancellationToken, progress);
|
||||
}
|
||||
@@ -1031,7 +1017,7 @@ namespace Emby.Server.Implementations.Library
|
||||
public async Task ValidateMediaLibraryInternal(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
IsScanRunning = true;
|
||||
_libraryMonitorFactory().Stop();
|
||||
LibraryMonitor.Stop();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1039,7 +1025,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
finally
|
||||
{
|
||||
_libraryMonitorFactory().Start();
|
||||
LibraryMonitor.Start();
|
||||
IsScanRunning = false;
|
||||
}
|
||||
}
|
||||
@@ -1148,7 +1134,7 @@ namespace Emby.Server.Implementations.Library
|
||||
progress.Report(percent * 100);
|
||||
}
|
||||
|
||||
ItemRepository.UpdateInheritedValues(cancellationToken);
|
||||
_itemRepository.UpdateInheritedValues(cancellationToken);
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
@@ -1168,9 +1154,9 @@ namespace Emby.Server.Implementations.Library
|
||||
var topLibraryFolders = GetUserRootFolder().Children.ToList();
|
||||
|
||||
_logger.LogDebug("Getting refreshQueue");
|
||||
var refreshQueue = includeRefreshState ? _providerManagerFactory().GetRefreshQueue() : null;
|
||||
var refreshQueue = includeRefreshState ? ProviderManager.GetRefreshQueue() : null;
|
||||
|
||||
return _fileSystem.GetDirectoryPaths(ConfigurationManager.ApplicationPaths.DefaultUserViewsPath)
|
||||
return _fileSystem.GetDirectoryPaths(_configurationManager.ApplicationPaths.DefaultUserViewsPath)
|
||||
.Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders, refreshQueue))
|
||||
.ToList();
|
||||
}
|
||||
@@ -1245,7 +1231,7 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new ArgumentException("Guid can't be empty", nameof(id));
|
||||
}
|
||||
|
||||
if (LibraryItemsCache.TryGetValue(id, out BaseItem item))
|
||||
if (_libraryItemsCache.TryGetValue(id, out BaseItem item))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
@@ -1276,7 +1262,7 @@ namespace Emby.Server.Implementations.Library
|
||||
AddUserToQuery(query, query.User, allowExternalContent);
|
||||
}
|
||||
|
||||
return ItemRepository.GetItemList(query);
|
||||
return _itemRepository.GetItemList(query);
|
||||
}
|
||||
|
||||
public List<BaseItem> GetItemList(InternalItemsQuery query)
|
||||
@@ -1300,7 +1286,7 @@ namespace Emby.Server.Implementations.Library
|
||||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
return ItemRepository.GetCount(query);
|
||||
return _itemRepository.GetCount(query);
|
||||
}
|
||||
|
||||
public List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents)
|
||||
@@ -1315,7 +1301,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
return ItemRepository.GetItemList(query);
|
||||
return _itemRepository.GetItemList(query);
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
|
||||
@@ -1327,12 +1313,12 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (query.EnableTotalRecordCount)
|
||||
{
|
||||
return ItemRepository.GetItems(query);
|
||||
return _itemRepository.GetItems(query);
|
||||
}
|
||||
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
Items = ItemRepository.GetItemList(query).ToArray()
|
||||
Items = _itemRepository.GetItemList(query).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1343,7 +1329,7 @@ namespace Emby.Server.Implementations.Library
|
||||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
return ItemRepository.GetItemIdsList(query);
|
||||
return _itemRepository.GetItemIdsList(query);
|
||||
}
|
||||
|
||||
public QueryResult<(BaseItem, ItemCounts)> GetStudios(InternalItemsQuery query)
|
||||
@@ -1354,7 +1340,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
SetTopParentOrAncestorIds(query);
|
||||
return ItemRepository.GetStudios(query);
|
||||
return _itemRepository.GetStudios(query);
|
||||
}
|
||||
|
||||
public QueryResult<(BaseItem, ItemCounts)> GetGenres(InternalItemsQuery query)
|
||||
@@ -1365,7 +1351,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
SetTopParentOrAncestorIds(query);
|
||||
return ItemRepository.GetGenres(query);
|
||||
return _itemRepository.GetGenres(query);
|
||||
}
|
||||
|
||||
public QueryResult<(BaseItem, ItemCounts)> GetMusicGenres(InternalItemsQuery query)
|
||||
@@ -1376,7 +1362,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
SetTopParentOrAncestorIds(query);
|
||||
return ItemRepository.GetMusicGenres(query);
|
||||
return _itemRepository.GetMusicGenres(query);
|
||||
}
|
||||
|
||||
public QueryResult<(BaseItem, ItemCounts)> GetAllArtists(InternalItemsQuery query)
|
||||
@@ -1387,7 +1373,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
SetTopParentOrAncestorIds(query);
|
||||
return ItemRepository.GetAllArtists(query);
|
||||
return _itemRepository.GetAllArtists(query);
|
||||
}
|
||||
|
||||
public QueryResult<(BaseItem, ItemCounts)> GetArtists(InternalItemsQuery query)
|
||||
@@ -1398,7 +1384,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
SetTopParentOrAncestorIds(query);
|
||||
return ItemRepository.GetArtists(query);
|
||||
return _itemRepository.GetArtists(query);
|
||||
}
|
||||
|
||||
private void SetTopParentOrAncestorIds(InternalItemsQuery query)
|
||||
@@ -1439,7 +1425,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
SetTopParentOrAncestorIds(query);
|
||||
return ItemRepository.GetAlbumArtists(query);
|
||||
return _itemRepository.GetAlbumArtists(query);
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query)
|
||||
@@ -1460,10 +1446,10 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (query.EnableTotalRecordCount)
|
||||
{
|
||||
return ItemRepository.GetItems(query);
|
||||
return _itemRepository.GetItems(query);
|
||||
}
|
||||
|
||||
var list = ItemRepository.GetItemList(query);
|
||||
var list = _itemRepository.GetItemList(query);
|
||||
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
@@ -1509,7 +1495,7 @@ namespace Emby.Server.Implementations.Library
|
||||
string.IsNullOrEmpty(query.SeriesPresentationUniqueKey) &&
|
||||
query.ItemIds.Length == 0)
|
||||
{
|
||||
var userViews = _userviewManager().GetUserViews(new UserViewQuery
|
||||
var userViews = UserViewManager.GetUserViews(new UserViewQuery
|
||||
{
|
||||
UserId = user.Id,
|
||||
IncludeHidden = true,
|
||||
@@ -1809,7 +1795,7 @@ namespace Emby.Server.Implementations.Library
|
||||
// Don't iterate multiple times
|
||||
var itemsList = items.ToList();
|
||||
|
||||
ItemRepository.SaveItems(itemsList, cancellationToken);
|
||||
_itemRepository.SaveItems(itemsList, cancellationToken);
|
||||
|
||||
foreach (var item in itemsList)
|
||||
{
|
||||
@@ -1844,10 +1830,90 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateImages(BaseItem item)
|
||||
private bool ImageNeedsRefresh(ItemImageInfo image)
|
||||
{
|
||||
ItemRepository.SaveImages(item);
|
||||
if (image.Path != null && image.IsLocalFile)
|
||||
{
|
||||
if (image.Width == 0 || image.Height == 0 || string.IsNullOrEmpty(image.BlurHash))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return _fileSystem.GetLastWriteTimeUtc(image.Path) != image.DateModified;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Cannot get file info for {0}", image.Path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return image.Path != null && !image.IsLocalFile;
|
||||
}
|
||||
|
||||
public void UpdateImages(BaseItem item, bool forceUpdate = false)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
var outdated = forceUpdate ? item.ImageInfos.Where(i => i.Path != null).ToArray() : item.ImageInfos.Where(ImageNeedsRefresh).ToArray();
|
||||
if (outdated.Length == 0)
|
||||
{
|
||||
RegisterItem(item);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var img in outdated)
|
||||
{
|
||||
var image = img;
|
||||
if (!img.IsLocalFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
var index = item.GetImageIndex(img);
|
||||
image = ConvertImageToLocal(item, img, index).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
_logger.LogWarning("Cannot get image index for {0}", img.Path);
|
||||
continue;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
_logger.LogWarning("Cannot fetch image from {0}", img.Path);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ImageDimensions size = _imageProcessor.GetImageDimensions(item, image);
|
||||
image.Width = size.Width;
|
||||
image.Height = size.Height;
|
||||
|
||||
try
|
||||
{
|
||||
image.BlurHash = _imageProcessor.GetImageBlurHash(image.Path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Cannot compute blurhash for {0}", image.Path);
|
||||
image.BlurHash = string.Empty;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
image.DateModified = _fileSystem.GetLastWriteTimeUtc(image.Path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Cannot update DateModified for {0}", image.Path);
|
||||
}
|
||||
}
|
||||
|
||||
_itemRepository.SaveImages(item);
|
||||
RegisterItem(item);
|
||||
}
|
||||
|
||||
@@ -1863,15 +1929,15 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
if (item.IsFileProtocol)
|
||||
{
|
||||
_providerManagerFactory().SaveMetadata(item, updateReason);
|
||||
ProviderManager.SaveMetadata(item, updateReason);
|
||||
}
|
||||
|
||||
item.DateLastSaved = DateTime.UtcNow;
|
||||
|
||||
RegisterItem(item);
|
||||
UpdateImages(item, updateReason >= ItemUpdateType.ImageUpdate);
|
||||
}
|
||||
|
||||
ItemRepository.SaveItems(itemsList, cancellationToken);
|
||||
_itemRepository.SaveItems(itemsList, cancellationToken);
|
||||
|
||||
if (ItemUpdated != null)
|
||||
{
|
||||
@@ -1947,7 +2013,7 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <returns>BaseItem.</returns>
|
||||
public BaseItem RetrieveItem(Guid id)
|
||||
{
|
||||
return ItemRepository.RetrieveItem(id);
|
||||
return _itemRepository.RetrieveItem(id);
|
||||
}
|
||||
|
||||
public List<Folder> GetCollectionFolders(BaseItem item)
|
||||
@@ -2066,7 +2132,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
private string GetContentTypeOverride(string path, bool inherit)
|
||||
{
|
||||
var nameValuePair = ConfigurationManager.Configuration.ContentTypes
|
||||
var nameValuePair = _configurationManager.Configuration.ContentTypes
|
||||
.FirstOrDefault(i => _fileSystem.AreEqual(i.Name, path)
|
||||
|| (inherit && !string.IsNullOrEmpty(i.Name)
|
||||
&& _fileSystem.ContainsSubPath(i.Name, path)));
|
||||
@@ -2115,7 +2181,7 @@ namespace Emby.Server.Implementations.Library
|
||||
string sortName)
|
||||
{
|
||||
var path = Path.Combine(
|
||||
ConfigurationManager.ApplicationPaths.InternalMetadataPath,
|
||||
_configurationManager.ApplicationPaths.InternalMetadataPath,
|
||||
"views",
|
||||
_fileSystem.GetValidFilename(viewType));
|
||||
|
||||
@@ -2147,7 +2213,7 @@ namespace Emby.Server.Implementations.Library
|
||||
if (refresh)
|
||||
{
|
||||
item.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None);
|
||||
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions(new DirectoryService(_fileSystem)), RefreshPriority.Normal);
|
||||
ProviderManager.QueueRefresh(item.Id, new MetadataRefreshOptions(new DirectoryService(_fileSystem)), RefreshPriority.Normal);
|
||||
}
|
||||
|
||||
return item;
|
||||
@@ -2165,7 +2231,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var id = GetNewItemId(idValues, typeof(UserView));
|
||||
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N", CultureInfo.InvariantCulture));
|
||||
var path = Path.Combine(_configurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N", CultureInfo.InvariantCulture));
|
||||
|
||||
var item = GetItemById(id) as UserView;
|
||||
|
||||
@@ -2202,7 +2268,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
_providerManagerFactory().QueueRefresh(
|
||||
ProviderManager.QueueRefresh(
|
||||
item.Id,
|
||||
new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
||||
{
|
||||
@@ -2269,7 +2335,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
_providerManagerFactory().QueueRefresh(
|
||||
ProviderManager.QueueRefresh(
|
||||
item.Id,
|
||||
new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
||||
{
|
||||
@@ -2303,7 +2369,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var id = GetNewItemId(idValues, typeof(UserView));
|
||||
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N", CultureInfo.InvariantCulture));
|
||||
var path = Path.Combine(_configurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N", CultureInfo.InvariantCulture));
|
||||
|
||||
var item = GetItemById(id) as UserView;
|
||||
|
||||
@@ -2346,7 +2412,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
_providerManagerFactory().QueueRefresh(
|
||||
ProviderManager.QueueRefresh(
|
||||
item.Id,
|
||||
new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
||||
{
|
||||
@@ -2675,8 +2741,8 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
var metadataPath = ConfigurationManager.Configuration.MetadataPath;
|
||||
var metadataNetworkPath = ConfigurationManager.Configuration.MetadataNetworkPath;
|
||||
var metadataPath = _configurationManager.Configuration.MetadataPath;
|
||||
var metadataNetworkPath = _configurationManager.Configuration.MetadataNetworkPath;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(metadataPath) && !string.IsNullOrWhiteSpace(metadataNetworkPath))
|
||||
{
|
||||
@@ -2687,7 +2753,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var map in ConfigurationManager.Configuration.PathSubstitutions)
|
||||
foreach (var map in _configurationManager.Configuration.PathSubstitutions)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(map.From))
|
||||
{
|
||||
@@ -2756,7 +2822,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public List<PersonInfo> GetPeople(InternalPeopleQuery query)
|
||||
{
|
||||
return ItemRepository.GetPeople(query);
|
||||
return _itemRepository.GetPeople(query);
|
||||
}
|
||||
|
||||
public List<PersonInfo> GetPeople(BaseItem item)
|
||||
@@ -2779,7 +2845,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public List<Person> GetPeopleItems(InternalPeopleQuery query)
|
||||
{
|
||||
return ItemRepository.GetPeopleNames(query).Select(i =>
|
||||
return _itemRepository.GetPeopleNames(query).Select(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2796,7 +2862,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
public List<string> GetPeopleNames(InternalPeopleQuery query)
|
||||
{
|
||||
return ItemRepository.GetPeopleNames(query);
|
||||
return _itemRepository.GetPeopleNames(query);
|
||||
}
|
||||
|
||||
public void UpdatePeople(BaseItem item, List<PersonInfo> people)
|
||||
@@ -2806,7 +2872,7 @@ namespace Emby.Server.Implementations.Library
|
||||
return;
|
||||
}
|
||||
|
||||
ItemRepository.UpdatePeople(item.Id, people);
|
||||
_itemRepository.UpdatePeople(item.Id, people);
|
||||
}
|
||||
|
||||
public async Task<ItemImageInfo> ConvertImageToLocal(BaseItem item, ItemImageInfo image, int imageIndex)
|
||||
@@ -2817,7 +2883,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
_logger.LogDebug("ConvertImageToLocal item {0} - image url: {1}", item.Id, url);
|
||||
|
||||
await _providerManagerFactory().SaveImage(item, url, image.Type, imageIndex, CancellationToken.None).ConfigureAwait(false);
|
||||
await ProviderManager.SaveImage(item, url, image.Type, imageIndex, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
item.UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None);
|
||||
|
||||
@@ -2850,7 +2916,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
name = _fileSystem.GetValidFilename(name);
|
||||
|
||||
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
|
||||
var virtualFolderPath = Path.Combine(rootFolderPath, name);
|
||||
while (Directory.Exists(virtualFolderPath))
|
||||
@@ -2869,7 +2935,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
_libraryMonitorFactory().Stop();
|
||||
LibraryMonitor.Stop();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -2904,7 +2970,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
// Need to add a delay here or directory watchers may still pick up the changes
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
_libraryMonitorFactory().Start();
|
||||
LibraryMonitor.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2964,7 +3030,7 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new FileNotFoundException("The network path does not exist.");
|
||||
}
|
||||
|
||||
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
|
||||
|
||||
var shortcutFilename = Path.GetFileNameWithoutExtension(path);
|
||||
@@ -3007,7 +3073,7 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new FileNotFoundException("The network path does not exist.");
|
||||
}
|
||||
|
||||
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
|
||||
|
||||
var libraryOptions = CollectionFolder.GetLibraryOptions(virtualFolderPath);
|
||||
@@ -3060,7 +3126,7 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
|
||||
var path = Path.Combine(rootFolderPath, name);
|
||||
|
||||
@@ -3069,7 +3135,7 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new FileNotFoundException("The media folder does not exist");
|
||||
}
|
||||
|
||||
_libraryMonitorFactory().Stop();
|
||||
LibraryMonitor.Stop();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -3089,7 +3155,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
// Need to add a delay here or directory watchers may still pick up the changes
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
_libraryMonitorFactory().Start();
|
||||
LibraryMonitor.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3103,7 +3169,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
var removeList = new List<NameValuePair>();
|
||||
|
||||
foreach (var contentType in ConfigurationManager.Configuration.ContentTypes)
|
||||
foreach (var contentType in _configurationManager.Configuration.ContentTypes)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(contentType.Name))
|
||||
{
|
||||
@@ -3118,11 +3184,11 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (removeList.Count > 0)
|
||||
{
|
||||
ConfigurationManager.Configuration.ContentTypes = ConfigurationManager.Configuration.ContentTypes
|
||||
_configurationManager.Configuration.ContentTypes = _configurationManager.Configuration.ContentTypes
|
||||
.Except(removeList)
|
||||
.ToArray();
|
||||
.ToArray();
|
||||
|
||||
ConfigurationManager.SaveConfiguration();
|
||||
_configurationManager.SaveConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3133,7 +3199,7 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new ArgumentNullException(nameof(mediaPath));
|
||||
}
|
||||
|
||||
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
|
||||
|
||||
if (!Directory.Exists(virtualFolderPath))
|
||||
|
||||
@@ -33,13 +33,13 @@ namespace Emby.Server.Implementations.Library
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILogger<MediaSourceManager> _logger;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
private readonly ILocalizationManager _localizationManager;
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
|
||||
private IMediaSourceProvider[] _providers;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
private readonly Func<IMediaEncoder> _mediaEncoder;
|
||||
private ILocalizationManager _localizationManager;
|
||||
private IApplicationPaths _appPaths;
|
||||
|
||||
public MediaSourceManager(
|
||||
IItemRepository itemRepo,
|
||||
@@ -47,16 +47,16 @@ namespace Emby.Server.Implementations.Library
|
||||
ILocalizationManager localizationManager,
|
||||
IUserManager userManager,
|
||||
ILibraryManager libraryManager,
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<MediaSourceManager> logger,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IFileSystem fileSystem,
|
||||
IUserDataManager userDataManager,
|
||||
Func<IMediaEncoder> mediaEncoder)
|
||||
IMediaEncoder mediaEncoder)
|
||||
{
|
||||
_itemRepo = itemRepo;
|
||||
_userManager = userManager;
|
||||
_libraryManager = libraryManager;
|
||||
_logger = loggerFactory.CreateLogger(nameof(MediaSourceManager));
|
||||
_logger = logger;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_fileSystem = fileSystem;
|
||||
_userDataManager = userDataManager;
|
||||
@@ -496,7 +496,7 @@ namespace Emby.Server.Implementations.Library
|
||||
// hack - these two values were taken from LiveTVMediaSourceProvider
|
||||
string cacheKey = request.OpenToken;
|
||||
|
||||
await new LiveStreamHelper(_mediaEncoder(), _logger, _jsonSerializer, _appPaths)
|
||||
await new LiveStreamHelper(_mediaEncoder, _logger, _jsonSerializer, _appPaths)
|
||||
.AddMediaInfoWithProbe(mediaSource, isAudio, cacheKey, true, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
@@ -521,11 +521,7 @@ namespace Emby.Server.Implementations.Library
|
||||
SetDefaultAudioAndSubtitleStreamIndexes(item, clone, user);
|
||||
}
|
||||
|
||||
return new Tuple<LiveStreamResponse, IDirectStreamProvider>(new LiveStreamResponse
|
||||
{
|
||||
MediaSource = clone
|
||||
|
||||
}, liveStream as IDirectStreamProvider);
|
||||
return new Tuple<LiveStreamResponse, IDirectStreamProvider>(new LiveStreamResponse(clone), liveStream as IDirectStreamProvider);
|
||||
}
|
||||
|
||||
private static void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio)
|
||||
@@ -621,7 +617,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (liveStreamInfo is IDirectStreamProvider)
|
||||
{
|
||||
var info = await _mediaEncoder().GetMediaInfo(new MediaInfoRequest
|
||||
var info = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
|
||||
{
|
||||
MediaSource = mediaSource,
|
||||
ExtractChapters = false,
|
||||
@@ -674,7 +670,7 @@ namespace Emby.Server.Implementations.Library
|
||||
mediaSource.AnalyzeDurationMs = 3000;
|
||||
}
|
||||
|
||||
mediaInfo = await _mediaEncoder().GetMediaInfo(new MediaInfoRequest
|
||||
mediaInfo = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
|
||||
{
|
||||
MediaSource = mediaSource,
|
||||
MediaType = isAudio ? DlnaProfileType.Audio : DlnaProfileType.Video,
|
||||
|
||||
@@ -35,7 +35,8 @@ namespace Emby.Server.Implementations.Library
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int? GetDefaultSubtitleStreamIndex(List<MediaStream> streams,
|
||||
public static int? GetDefaultSubtitleStreamIndex(
|
||||
List<MediaStream> streams,
|
||||
string[] preferredLanguages,
|
||||
SubtitlePlaybackMode mode,
|
||||
string audioTrackLanguage)
|
||||
@@ -115,7 +116,8 @@ namespace Emby.Server.Implementations.Library
|
||||
.ThenBy(i => i.Index);
|
||||
}
|
||||
|
||||
public static void SetSubtitleStreamScores(List<MediaStream> streams,
|
||||
public static void SetSubtitleStreamScores(
|
||||
List<MediaStream> streams,
|
||||
string[] preferredLanguages,
|
||||
SubtitlePlaybackMode mode,
|
||||
string audioTrackLanguage)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -12,24 +14,24 @@ namespace Emby.Server.Implementations.Library
|
||||
/// Gets the attribute value.
|
||||
/// </summary>
|
||||
/// <param name="str">The STR.</param>
|
||||
/// <param name="attrib">The attrib.</param>
|
||||
/// <param name="attribute">The attrib.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
/// <exception cref="ArgumentNullException">attrib</exception>
|
||||
public static string GetAttributeValue(this string str, string attrib)
|
||||
/// <exception cref="ArgumentException"><paramref name="str" /> or <paramref name="attribute" /> is empty.</exception>
|
||||
public static string? GetAttributeValue(this string str, string attribute)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
if (str.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(str));
|
||||
throw new ArgumentException("String can't be empty.", nameof(str));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(attrib))
|
||||
if (attribute.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attrib));
|
||||
throw new ArgumentException("String can't be empty.", nameof(attribute));
|
||||
}
|
||||
|
||||
string srch = "[" + attrib + "=";
|
||||
string srch = "[" + attribute + "=";
|
||||
int start = str.IndexOf(srch, StringComparison.OrdinalIgnoreCase);
|
||||
if (start > -1)
|
||||
if (start != -1)
|
||||
{
|
||||
start += srch.Length;
|
||||
int end = str.IndexOf(']', start);
|
||||
@@ -37,7 +39,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
// for imdbid we also accept pattern matching
|
||||
if (string.Equals(attrib, "imdbid", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(attribute, "imdbid", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var m = Regex.Match(str, "tt([0-9]{7,8})", RegexOptions.IgnoreCase);
|
||||
return m.Success ? m.Value : null;
|
||||
|
||||
@@ -118,10 +118,12 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fileSystem));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
if (args == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(args));
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
public class MusicAlbumResolver : ItemResolver<MusicAlbum>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<MusicAlbumResolver> _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
public MusicAlbumResolver(ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager)
|
||||
public MusicAlbumResolver(ILogger<MusicAlbumResolver> logger, IFileSystem fileSystem, ILibraryManager libraryManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
@@ -109,7 +109,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
IEnumerable<FileSystemMetadata> list,
|
||||
bool allowSubfolders,
|
||||
IDirectoryService directoryService,
|
||||
ILogger logger,
|
||||
ILogger<MusicAlbumResolver> logger,
|
||||
IFileSystem fileSystem,
|
||||
ILibraryManager libraryManager)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
/// </summary>
|
||||
public class MusicArtistResolver : ItemResolver<MusicArtist>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<MusicAlbumResolver> _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
@@ -23,12 +23,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MusicArtistResolver"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="logger">The logger for the created <see cref="MusicAlbumResolver"/> instances.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="config">The configuration manager.</param>
|
||||
public MusicArtistResolver(
|
||||
ILogger<MusicArtistResolver> logger,
|
||||
ILogger<MusicAlbumResolver> logger,
|
||||
IFileSystem fileSystem,
|
||||
ILibraryManager libraryManager,
|
||||
IServerConfigurationManager config)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
|
||||
{
|
||||
public class BookResolver : MediaBrowser.Controller.Resolvers.ItemResolver<Book>
|
||||
{
|
||||
private readonly string[] _validExtensions = { ".pdf", ".epub", ".mobi", ".cbr", ".cbz", ".azw3" };
|
||||
private readonly string[] _validExtensions = { ".azw", ".azw3", ".cb7", ".cbr", ".cbt", ".cbz", ".epub", ".mobi", ".opf", ".pdf" };
|
||||
|
||||
protected override Book Resolve(ItemResolveArgs args)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tmdb, id);
|
||||
item.SetProviderId(MetadataProvider.Tmdb, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tmdbid))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tmdb, tmdbid);
|
||||
item.SetProviderId(MetadataProvider.Tmdb, tmdbid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(imdbid))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Imdb, imdbid);
|
||||
item.SetProviderId(MetadataProvider.Imdb, imdbid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<SeasonResolver> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SeasonResolver"/> class.
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||
public class SeriesResolver : FolderResolver<Series>
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<SeriesResolver> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
@@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||
IEnumerable<FileSystemMetadata> fileSystemChildren,
|
||||
IDirectoryService directoryService,
|
||||
IFileSystem fileSystem,
|
||||
ILogger logger,
|
||||
ILogger<SeriesResolver> logger,
|
||||
ILibraryManager libraryManager,
|
||||
bool isTvContentType)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
|
||||
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tvdb, id);
|
||||
item.SetProviderId(MetadataProvider.Tvdb, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,15 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
public class SearchEngine : ISearchEngine
|
||||
{
|
||||
private readonly ILogger<SearchEngine> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public SearchEngine(ILoggerFactory loggerFactory, ILibraryManager libraryManager, IUserManager userManager)
|
||||
public SearchEngine(ILogger<SearchEngine> logger, ILibraryManager libraryManager, IUserManager userManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
_userManager = userManager;
|
||||
|
||||
_logger = loggerFactory.CreateLogger("SearchEngine");
|
||||
}
|
||||
|
||||
public QueryResult<SearchHintInfo> GetSearchHints(SearchQuery query)
|
||||
|
||||
@@ -26,27 +26,26 @@ namespace Emby.Server.Implementations.Library
|
||||
private readonly ConcurrentDictionary<string, UserItemData> _userData =
|
||||
new ConcurrentDictionary<string, UserItemData>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<UserDataManager> _logger;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IUserDataRepository _repository;
|
||||
|
||||
private Func<IUserManager> _userManager;
|
||||
|
||||
public UserDataManager(ILoggerFactory loggerFactory, IServerConfigurationManager config, Func<IUserManager> userManager)
|
||||
public UserDataManager(
|
||||
ILogger<UserDataManager> logger,
|
||||
IServerConfigurationManager config,
|
||||
IUserManager userManager,
|
||||
IUserDataRepository repository)
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_logger = loggerFactory.CreateLogger(GetType().Name);
|
||||
_userManager = userManager;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the repository.
|
||||
/// </summary>
|
||||
/// <value>The repository.</value>
|
||||
public IUserDataRepository Repository { get; set; }
|
||||
|
||||
public void SaveUserData(Guid userId, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = _userManager().GetUserById(userId);
|
||||
var user = _userManager.GetUserById(userId);
|
||||
|
||||
SaveUserData(user, item, userData, reason, cancellationToken);
|
||||
}
|
||||
@@ -71,7 +70,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
foreach (var key in keys)
|
||||
{
|
||||
Repository.SaveUserData(userId, key, userData, cancellationToken);
|
||||
_repository.SaveUserData(userId, key, userData, cancellationToken);
|
||||
}
|
||||
|
||||
var cacheKey = GetCacheKey(userId, item.Id);
|
||||
@@ -96,9 +95,9 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <returns></returns>
|
||||
public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = _userManager().GetUserById(userId);
|
||||
var user = _userManager.GetUserById(userId);
|
||||
|
||||
Repository.SaveAllUserData(user.InternalId, userData, cancellationToken);
|
||||
_repository.SaveAllUserData(user.InternalId, userData, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,14 +107,14 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <returns></returns>
|
||||
public List<UserItemData> GetAllUserData(Guid userId)
|
||||
{
|
||||
var user = _userManager().GetUserById(userId);
|
||||
var user = _userManager.GetUserById(userId);
|
||||
|
||||
return Repository.GetAllUserData(user.InternalId);
|
||||
return _repository.GetAllUserData(user.InternalId);
|
||||
}
|
||||
|
||||
public UserItemData GetUserData(Guid userId, Guid itemId, List<string> keys)
|
||||
{
|
||||
var user = _userManager().GetUserById(userId);
|
||||
var user = _userManager.GetUserById(userId);
|
||||
|
||||
return GetUserData(user, itemId, keys);
|
||||
}
|
||||
@@ -131,7 +130,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
private UserItemData GetUserDataInternal(long internalUserId, List<string> keys)
|
||||
{
|
||||
var userData = Repository.GetUserData(internalUserId, keys);
|
||||
var userData = _repository.GetUserData(internalUserId, keys);
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
@@ -241,7 +240,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
// Enforce MinResumeDuration
|
||||
var durationSeconds = TimeSpan.FromTicks(runtimeTicks).TotalSeconds;
|
||||
if (durationSeconds < _config.Configuration.MinResumeDurationSeconds)
|
||||
if (durationSeconds < _config.Configuration.MinResumeDurationSeconds && !(item is Book))
|
||||
{
|
||||
positionTicks = 0;
|
||||
data.Played = playedToCompletion = true;
|
||||
|
||||
@@ -20,6 +20,7 @@ using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -44,22 +45,14 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
private readonly object _policySyncLock = new object();
|
||||
private readonly object _configSyncLock = new object();
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the active user repository.
|
||||
/// </summary>
|
||||
/// <value>The user repository.</value>
|
||||
private readonly ILogger<UserManager> _logger;
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly IXmlSerializer _xmlSerializer;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly INetworkManager _networkManager;
|
||||
|
||||
private readonly Func<IImageProcessor> _imageProcessorFactory;
|
||||
private readonly Func<IDtoService> _dtoServiceFactory;
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
private readonly Lazy<IDtoService> _dtoServiceFactory;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ICryptoProvider _cryptoProvider;
|
||||
@@ -74,13 +67,15 @@ namespace Emby.Server.Implementations.Library
|
||||
private IPasswordResetProvider[] _passwordResetProviders;
|
||||
private DefaultPasswordResetProvider _defaultPasswordResetProvider;
|
||||
|
||||
private IDtoService DtoService => _dtoServiceFactory.Value;
|
||||
|
||||
public UserManager(
|
||||
ILogger<UserManager> logger,
|
||||
IUserRepository userRepository,
|
||||
IXmlSerializer xmlSerializer,
|
||||
INetworkManager networkManager,
|
||||
Func<IImageProcessor> imageProcessorFactory,
|
||||
Func<IDtoService> dtoServiceFactory,
|
||||
IImageProcessor imageProcessor,
|
||||
Lazy<IDtoService> dtoServiceFactory,
|
||||
IServerApplicationHost appHost,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IFileSystem fileSystem,
|
||||
@@ -90,7 +85,7 @@ namespace Emby.Server.Implementations.Library
|
||||
_userRepository = userRepository;
|
||||
_xmlSerializer = xmlSerializer;
|
||||
_networkManager = networkManager;
|
||||
_imageProcessorFactory = imageProcessorFactory;
|
||||
_imageProcessor = imageProcessor;
|
||||
_dtoServiceFactory = dtoServiceFactory;
|
||||
_appHost = appHost;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
@@ -131,7 +126,7 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <param name="user">The user.</param>
|
||||
private void OnUserUpdated(User user)
|
||||
{
|
||||
UserUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
UserUpdated?.Invoke(this, new GenericEventArgs<User>(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -140,7 +135,7 @@ namespace Emby.Server.Implementations.Library
|
||||
/// <param name="user">The user.</param>
|
||||
private void OnUserDeleted(User user)
|
||||
{
|
||||
UserDeleted?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
UserDeleted?.Invoke(this, new GenericEventArgs<User>(user));
|
||||
}
|
||||
|
||||
public NameIdPair[] GetAuthenticationProviders()
|
||||
@@ -327,23 +322,19 @@ namespace Emby.Server.Implementations.Library
|
||||
if (user.Policy.IsDisabled)
|
||||
{
|
||||
_logger.LogInformation("Authentication request for {UserName} has been denied because this account is currently disabled (IP: {IP}).", username, remoteEndPoint);
|
||||
throw new AuthenticationException(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"The {0} account is currently disabled. Please consult with your administrator.",
|
||||
user.Name));
|
||||
throw new SecurityException($"The {user.Name} account is currently disabled. Please consult with your administrator.");
|
||||
}
|
||||
|
||||
if (!user.Policy.EnableRemoteAccess && !_networkManager.IsInLocalNetwork(remoteEndPoint))
|
||||
{
|
||||
_logger.LogInformation("Authentication request for {UserName} forbidden: remote access disabled and user not in local network (IP: {IP}).", username, remoteEndPoint);
|
||||
throw new AuthenticationException("Forbidden.");
|
||||
throw new SecurityException("Forbidden.");
|
||||
}
|
||||
|
||||
if (!user.IsParentalScheduleAllowed())
|
||||
{
|
||||
_logger.LogInformation("Authentication request for {UserName} is not allowed at this time due parental restrictions (IP: {IP}).", username, remoteEndPoint);
|
||||
throw new AuthenticationException("User is not allowed access at this time.");
|
||||
throw new SecurityException("User is not allowed access at this time.");
|
||||
}
|
||||
|
||||
// Update LastActivityDate and LastLoginDate, then save
|
||||
@@ -605,7 +596,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
try
|
||||
{
|
||||
_dtoServiceFactory().AttachPrimaryImageAspectRatio(dto, user);
|
||||
DtoService.AttachPrimaryImageAspectRatio(dto, user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -630,7 +621,7 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
return _imageProcessorFactory().GetImageCacheTag(item, image);
|
||||
return _imageProcessor.GetImageCacheTag(item, image);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -760,7 +751,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
_userRepository.CreateUser(user);
|
||||
|
||||
EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User> { Argument = user }, _logger);
|
||||
EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs<User>(user), _logger);
|
||||
|
||||
return user;
|
||||
}
|
||||
@@ -985,7 +976,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (fireEvent)
|
||||
{
|
||||
UserPolicyUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
UserPolicyUpdated?.Invoke(this, new GenericEventArgs<User>(user));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1055,7 +1046,7 @@ namespace Emby.Server.Implementations.Library
|
||||
|
||||
if (fireEvent)
|
||||
{
|
||||
UserConfigurationUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
UserConfigurationUpdated?.Invoke(this, new GenericEventArgs<User>(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// The _library manager.
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<ArtistsValidator> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
/// <summary>
|
||||
@@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public ArtistsPostScanTask(
|
||||
ILibraryManager libraryManager,
|
||||
ILogger<ArtistsPostScanTask> logger,
|
||||
ILogger<ArtistsValidator> logger,
|
||||
IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<ArtistsValidator> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public ArtistsValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
|
||||
public ArtistsValidator(ILibraryManager libraryManager, ILogger<ArtistsValidator> logger, IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// The _library manager.
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<GenresValidator> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
/// <summary>
|
||||
@@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public GenresPostScanTask(
|
||||
ILibraryManager libraryManager,
|
||||
ILogger<GenresPostScanTask> logger,
|
||||
ILogger<GenresValidator> logger,
|
||||
IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<GenresValidator> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GenresValidator"/> class.
|
||||
@@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public GenresValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
|
||||
public GenresValidator(ILibraryManager libraryManager, ILogger<GenresValidator> logger, IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// The library manager.
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<MusicGenresValidator> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
/// <summary>
|
||||
@@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public MusicGenresPostScanTask(
|
||||
ILibraryManager libraryManager,
|
||||
ILogger<MusicGenresPostScanTask> logger,
|
||||
ILogger<MusicGenresValidator> logger,
|
||||
IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<MusicGenresValidator> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public MusicGenresValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
|
||||
public MusicGenresValidator(ILibraryManager libraryManager, ILogger<MusicGenresValidator> logger, IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<StudiosValidator> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
/// <summary>
|
||||
@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public StudiosPostScanTask(
|
||||
ILibraryManager libraryManager,
|
||||
ILogger<StudiosPostScanTask> logger,
|
||||
ILogger<StudiosValidator> logger,
|
||||
IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <summary>
|
||||
/// The logger.
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<StudiosValidator> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StudiosValidator" /> class.
|
||||
@@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Library.Validators
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="itemRepo">The item repository.</param>
|
||||
public StudiosValidator(ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
|
||||
public StudiosValidator(ILibraryManager libraryManager, ILogger<StudiosValidator> logger, IItemRepository itemRepo)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
private const int TunerDiscoveryDurationMs = 3000;
|
||||
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<EmbyTV> _logger;
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
@@ -140,11 +140,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
|
||||
private async void OnNamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
|
||||
{
|
||||
if (string.Equals(e.Key, "livetv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
OnRecordingFoldersChanged();
|
||||
await CreateRecordingFolders().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,11 +155,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
return CreateRecordingFolders();
|
||||
}
|
||||
|
||||
private async void OnRecordingFoldersChanged()
|
||||
{
|
||||
await CreateRecordingFolders().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal async Task CreateRecordingFolders()
|
||||
{
|
||||
try
|
||||
@@ -1059,7 +1054,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
var stream = new MediaSourceInfo
|
||||
{
|
||||
EncoderPath = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveRecordings/" + info.Id + "/stream",
|
||||
EncoderPath = _appHost.GetLoopbackHttpApiUrl() + "/LiveTv/LiveRecordings/" + info.Id + "/stream",
|
||||
EncoderProtocol = MediaProtocol.Http,
|
||||
Path = info.Path,
|
||||
Protocol = MediaProtocol.File,
|
||||
@@ -1334,7 +1329,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
await CreateRecordingFolders().ConfigureAwait(false);
|
||||
|
||||
TriggerRefresh(recordPath);
|
||||
EnforceKeepUpTo(timer, seriesPath);
|
||||
await EnforceKeepUpTo(timer, seriesPath).ConfigureAwait(false);
|
||||
};
|
||||
|
||||
await recorder.Record(directStreamProvider, mediaStreamInfo, recordPath, duration, onStarted, activeRecordingInfo.CancellationTokenSource.Token).ConfigureAwait(false);
|
||||
@@ -1494,7 +1489,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
return item;
|
||||
}
|
||||
|
||||
private async void EnforceKeepUpTo(TimerInfo timer, string seriesPath)
|
||||
private async Task EnforceKeepUpTo(TimerInfo timer, string seriesPath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(timer.SeriesTimerId))
|
||||
{
|
||||
@@ -1898,22 +1893,22 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
writer.WriteStartDocument(true);
|
||||
writer.WriteStartElement("tvshow");
|
||||
string id;
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id))
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(), out id))
|
||||
{
|
||||
writer.WriteElementString("id", id);
|
||||
}
|
||||
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id))
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Imdb.ToString(), out id))
|
||||
{
|
||||
writer.WriteElementString("imdb_id", id);
|
||||
}
|
||||
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Tmdb.ToString(), out id))
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tmdb.ToString(), out id))
|
||||
{
|
||||
writer.WriteElementString("tmdbid", id);
|
||||
}
|
||||
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Zap2It.ToString(), out id))
|
||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Zap2It.ToString(), out id))
|
||||
{
|
||||
writer.WriteElementString("zap2itid", id);
|
||||
}
|
||||
@@ -2080,14 +2075,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
writer.WriteElementString("credits", person);
|
||||
}
|
||||
|
||||
var tmdbCollection = item.GetProviderId(MetadataProviders.TmdbCollection);
|
||||
var tmdbCollection = item.GetProviderId(MetadataProvider.TmdbCollection);
|
||||
|
||||
if (!string.IsNullOrEmpty(tmdbCollection))
|
||||
{
|
||||
writer.WriteElementString("collectionnumber", tmdbCollection);
|
||||
}
|
||||
|
||||
var imdb = item.GetProviderId(MetadataProviders.Imdb);
|
||||
var imdb = item.GetProviderId(MetadataProvider.Imdb);
|
||||
if (!string.IsNullOrEmpty(imdb))
|
||||
{
|
||||
if (!isSeriesEpisode)
|
||||
@@ -2101,7 +2096,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
lockData = false;
|
||||
}
|
||||
|
||||
var tvdb = item.GetProviderId(MetadataProviders.Tvdb);
|
||||
var tvdb = item.GetProviderId(MetadataProvider.Tvdb);
|
||||
if (!string.IsNullOrEmpty(tvdb))
|
||||
{
|
||||
writer.WriteElementString("tvdbid", tvdb);
|
||||
@@ -2110,7 +2105,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
lockData = false;
|
||||
}
|
||||
|
||||
var tmdb = item.GetProviderId(MetadataProviders.Tmdb);
|
||||
var tmdb = item.GetProviderId(MetadataProvider.Tmdb);
|
||||
if (!string.IsNullOrEmpty(tmdb))
|
||||
{
|
||||
writer.WriteElementString("tmdbid", tmdb);
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
onStarted();
|
||||
|
||||
// Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
|
||||
StartStreamingLog(_process.StandardError.BaseStream, _logFileStream);
|
||||
_ = StartStreamingLog(_process.StandardError.BaseStream, _logFileStream);
|
||||
|
||||
_logger.LogInformation("ffmpeg recording process started for {0}", _targetPath);
|
||||
|
||||
@@ -321,7 +321,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
}
|
||||
}
|
||||
|
||||
private async void StartStreamingLog(Stream source, Stream target)
|
||||
private async Task StartStreamingLog(Stream source, Stream target)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
if (startDate < now)
|
||||
{
|
||||
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo> { Argument = item });
|
||||
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(item));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase));
|
||||
if (timer != null)
|
||||
{
|
||||
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo> { Argument = timer });
|
||||
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(timer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
{
|
||||
public class SchedulesDirect : IListingsProvider
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<SchedulesDirect> _logger;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly SemaphoreSlim _tokenSemaphore = new SemaphoreSlim(1, 1);
|
||||
@@ -342,7 +342,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
{
|
||||
info.SeriesId = programId.Substring(0, 10);
|
||||
|
||||
info.SeriesProviderIds[MetadataProviders.Zap2It.ToString()] = info.SeriesId;
|
||||
info.SeriesProviderIds[MetadataProvider.Zap2It.ToString()] = info.SeriesId;
|
||||
|
||||
if (details.metadata != null)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<XmlTvListingsProvider> _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IZipClient _zipClient;
|
||||
|
||||
|
||||
@@ -26,9 +26,8 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
private const string ServiceName = "Emby";
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<LiveTvDtoService> _logger;
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly IApplicationHost _appHost;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
@@ -10,10 +10,8 @@ using Emby.Server.Implementations.Library;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
@@ -46,32 +44,27 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
private const string EtagKey = "ProgramEtag";
|
||||
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<LiveTvManager> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ITaskManager _taskManager;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly Func<IChannelManager> _channelManager;
|
||||
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly LiveTvDtoService _tvDtoService;
|
||||
|
||||
private ILiveTvService[] _services = Array.Empty<ILiveTvService>();
|
||||
|
||||
private ITunerHost[] _tunerHosts = Array.Empty<ITunerHost>();
|
||||
private IListingsProvider[] _listingProviders = Array.Empty<IListingsProvider>();
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public LiveTvManager(
|
||||
IServerApplicationHost appHost,
|
||||
IServerConfigurationManager config,
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<LiveTvManager> logger,
|
||||
IItemRepository itemRepo,
|
||||
IImageProcessor imageProcessor,
|
||||
IUserDataManager userDataManager,
|
||||
IDtoService dtoService,
|
||||
IUserManager userManager,
|
||||
@@ -80,10 +73,11 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
ILocalizationManager localization,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IFileSystem fileSystem,
|
||||
Func<IChannelManager> channelManager)
|
||||
IChannelManager channelManager,
|
||||
LiveTvDtoService liveTvDtoService)
|
||||
{
|
||||
_config = config;
|
||||
_logger = loggerFactory.CreateLogger(nameof(LiveTvManager));
|
||||
_logger = logger;
|
||||
_itemRepo = itemRepo;
|
||||
_userManager = userManager;
|
||||
_libraryManager = libraryManager;
|
||||
@@ -94,8 +88,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
_dtoService = dtoService;
|
||||
_userDataManager = userDataManager;
|
||||
_channelManager = channelManager;
|
||||
|
||||
_tvDtoService = new LiveTvDtoService(dtoService, imageProcessor, loggerFactory.CreateLogger<LiveTvDtoService>(), appHost, _libraryManager);
|
||||
_tvDtoService = liveTvDtoService;
|
||||
}
|
||||
|
||||
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCancelled;
|
||||
@@ -153,27 +146,18 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
{
|
||||
var timerId = e.Argument;
|
||||
|
||||
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
Id = timerId
|
||||
}
|
||||
});
|
||||
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>(new TimerEventInfo(timerId)));
|
||||
}
|
||||
|
||||
private void OnEmbyTvTimerCreated(object sender, GenericEventArgs<TimerInfo> e)
|
||||
{
|
||||
var timer = e.Argument;
|
||||
|
||||
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>(
|
||||
new TimerEventInfo(timer.Id)
|
||||
{
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(timer.ProgramId),
|
||||
Id = timer.Id
|
||||
}
|
||||
});
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(timer.ProgramId)
|
||||
}));
|
||||
}
|
||||
|
||||
public List<NameIdPair> GetTunerHostTypes()
|
||||
@@ -793,22 +777,12 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
if (query.OrderBy.Count == 0)
|
||||
{
|
||||
if (query.IsAiring ?? false)
|
||||
|
||||
// Unless something else was specified, order by start date to take advantage of a specialized index
|
||||
query.OrderBy = new[]
|
||||
{
|
||||
// Unless something else was specified, order by start date to take advantage of a specialized index
|
||||
query.OrderBy = new[]
|
||||
{
|
||||
(ItemSortBy.StartDate, SortOrder.Ascending)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unless something else was specified, order by start date to take advantage of a specialized index
|
||||
query.OrderBy = new[]
|
||||
{
|
||||
(ItemSortBy.StartDate, SortOrder.Ascending)
|
||||
};
|
||||
}
|
||||
(ItemSortBy.StartDate, SortOrder.Ascending)
|
||||
};
|
||||
}
|
||||
|
||||
RemoveFields(options);
|
||||
@@ -1739,13 +1713,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
if (!(service is EmbyTV.EmbyTV))
|
||||
{
|
||||
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
Id = id
|
||||
}
|
||||
});
|
||||
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>(new TimerEventInfo(id)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1762,13 +1730,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
SeriesTimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
Id = id
|
||||
}
|
||||
});
|
||||
SeriesTimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>(new TimerEventInfo(id)));
|
||||
}
|
||||
|
||||
public async Task<TimerInfoDto> GetTimer(string id, CancellationToken cancellationToken)
|
||||
@@ -2087,14 +2049,11 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
if (!(service is EmbyTV.EmbyTV))
|
||||
{
|
||||
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>(
|
||||
new TimerEventInfo(newTimerId)
|
||||
{
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId),
|
||||
Id = newTimerId
|
||||
}
|
||||
});
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId)
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2119,14 +2078,11 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
await service.CreateSeriesTimerAsync(info, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
SeriesTimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
SeriesTimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>(
|
||||
new TimerEventInfo(newTimerId)
|
||||
{
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId),
|
||||
Id = newTimerId
|
||||
}
|
||||
});
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId)
|
||||
}));
|
||||
}
|
||||
|
||||
public async Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken)
|
||||
@@ -2496,7 +2452,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
.OrderBy(i => i.SortName)
|
||||
.ToList();
|
||||
|
||||
folders.AddRange(_channelManager().GetChannelsInternal(new MediaBrowser.Model.Channels.ChannelQuery
|
||||
folders.AddRange(_channelManager.GetChannelsInternal(new MediaBrowser.Model.Channels.ChannelQuery
|
||||
{
|
||||
UserId = user.Id,
|
||||
IsRecordingsFolder = true,
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
private const string StreamIdDelimeterString = "_";
|
||||
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<LiveTvMediaSourceProvider> _logger;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||
public abstract class BaseTunerHost
|
||||
{
|
||||
protected readonly IServerConfigurationManager Config;
|
||||
protected readonly ILogger Logger;
|
||||
protected readonly ILogger<BaseTunerHost> Logger;
|
||||
protected IJsonSerializer JsonSerializer;
|
||||
protected readonly IFileSystem FileSystem;
|
||||
|
||||
private readonly ConcurrentDictionary<string, ChannelCache> _channelCache =
|
||||
new ConcurrentDictionary<string, ChannelCache>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
protected BaseTunerHost(IServerConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IFileSystem fileSystem)
|
||||
protected BaseTunerHost(IServerConfigurationManager config, ILogger<BaseTunerHost> logger, IJsonSerializer jsonSerializer, IFileSystem fileSystem)
|
||||
{
|
||||
Config = config;
|
||||
Logger = logger;
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||
//OpenedMediaSource.Path = tempFile;
|
||||
//OpenedMediaSource.ReadAtNativeFramerate = true;
|
||||
|
||||
MediaSource.Path = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";
|
||||
MediaSource.Path = _appHost.GetLoopbackHttpApiUrl() + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";
|
||||
MediaSource.Protocol = MediaProtocol.Http;
|
||||
//OpenedMediaSource.SupportsDirectPlay = false;
|
||||
//OpenedMediaSource.SupportsDirectStream = true;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||
public M3UTunerHost(
|
||||
IServerConfigurationManager config,
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
ILogger logger,
|
||||
ILogger<M3UTunerHost> logger,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IFileSystem fileSystem,
|
||||
IHttpClient httpClient,
|
||||
@@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||
return Task.FromResult(list);
|
||||
}
|
||||
|
||||
private static readonly string[] _disallowedSharedStreamExtensions = new string[]
|
||||
private static readonly string[] _disallowedSharedStreamExtensions =
|
||||
{
|
||||
".mkv",
|
||||
".mp4",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
@@ -106,7 +107,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||
//OpenedMediaSource.Path = tempFile;
|
||||
//OpenedMediaSource.ReadAtNativeFramerate = true;
|
||||
|
||||
MediaSource.Path = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";
|
||||
MediaSource.Path = _appHost.GetLoopbackHttpApiUrl() + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";
|
||||
MediaSource.Protocol = MediaProtocol.Http;
|
||||
|
||||
//OpenedMediaSource.Path = TempFilePath;
|
||||
@@ -118,6 +119,17 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||
//OpenedMediaSource.SupportsDirectStream = true;
|
||||
//OpenedMediaSource.SupportsTranscoding = true;
|
||||
await taskCompletionSource.Task.ConfigureAwait(false);
|
||||
if (taskCompletionSource.Task.Exception != null)
|
||||
{
|
||||
// Error happened while opening the stream so raise the exception again to inform the caller
|
||||
throw taskCompletionSource.Task.Exception;
|
||||
}
|
||||
|
||||
if (!taskCompletionSource.Task.Result)
|
||||
{
|
||||
Logger.LogWarning("Zero bytes copied from stream {0} to {1} but no exception raised", GetType().Name, TempFilePath);
|
||||
throw new EndOfStreamException(String.Format(CultureInfo.InvariantCulture, "Zero bytes copied from stream {0}", GetType().Name));
|
||||
}
|
||||
}
|
||||
|
||||
private Task StartStreaming(HttpResponseInfo response, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)
|
||||
@@ -139,14 +151,19 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
Logger.LogInformation("Copying of {0} to {1} was canceled", GetType().Name, TempFilePath);
|
||||
openTaskCompletionSource.TrySetException(ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error copying live stream.");
|
||||
Logger.LogError(ex, "Error copying live stream {0} to {1}.", GetType().Name, TempFilePath);
|
||||
openTaskCompletionSource.TrySetException(ex);
|
||||
}
|
||||
|
||||
openTaskCompletionSource.TrySetResult(false);
|
||||
|
||||
EnableStreamSharing = false;
|
||||
await DeleteTempFiles(new List<string> { TempFilePath }).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Folders": "Fouers",
|
||||
"Favorites": "Gunstelinge",
|
||||
"HeaderFavoriteShows": "Gunsteling Vertonings",
|
||||
"ValueSpecialEpisodeName": "Spesiaal - {0}",
|
||||
"ValueSpecialEpisodeName": "Spesiale - {0}",
|
||||
"HeaderAlbumArtists": "Album Kunstenaars",
|
||||
"Books": "Boeke",
|
||||
"HeaderNextUp": "Volgende",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"Channels": "القنوات",
|
||||
"ChapterNameValue": "الفصل {0}",
|
||||
"Collections": "مجموعات",
|
||||
"DeviceOfflineWithName": "قُطِع الاتصال بـ{0}",
|
||||
"DeviceOfflineWithName": "قُطِع الاتصال ب{0}",
|
||||
"DeviceOnlineWithName": "{0} متصل",
|
||||
"FailedLoginAttemptWithUserName": "عملية تسجيل الدخول فشلت من {0}",
|
||||
"Favorites": "المفضلة",
|
||||
|
||||
@@ -91,5 +91,14 @@
|
||||
"HeaderNextUp": "এরপরে আসছে",
|
||||
"HeaderLiveTV": "লাইভ টিভি",
|
||||
"HeaderFavoriteSongs": "প্রিয় গানগুলো",
|
||||
"HeaderFavoriteShows": "প্রিয় শোগুলো"
|
||||
"HeaderFavoriteShows": "প্রিয় শোগুলো",
|
||||
"TasksLibraryCategory": "গ্রন্থাগার",
|
||||
"TasksMaintenanceCategory": "রক্ষণাবেক্ষণ",
|
||||
"TaskRefreshLibrary": "স্ক্যান মিডিয়া লাইব্রেরি",
|
||||
"TaskRefreshChapterImagesDescription": "অধ্যায়গুলিতে থাকা ভিডিওগুলির জন্য থাম্বনেইল তৈরি ।",
|
||||
"TaskRefreshChapterImages": "অধ্যায়ের চিত্রগুলি বের করুন",
|
||||
"TaskCleanCacheDescription": "সিস্টেমে আর প্রয়োজন নেই ক্যাশ, ফাইলগুলি মুছে ফেলুন।",
|
||||
"TaskCleanCache": "ক্লিন ক্যাশ ডিরেক্টরি",
|
||||
"TasksChannelsCategory": "ইন্টারনেট চ্যানেল",
|
||||
"TasksApplicationCategory": "আবেদন"
|
||||
}
|
||||
|
||||
@@ -92,5 +92,27 @@
|
||||
"UserStoppedPlayingItemWithValues": "{0} ha parat de reproduir {1}",
|
||||
"ValueHasBeenAddedToLibrary": "{0} ha sigut afegit a la teva llibreria",
|
||||
"ValueSpecialEpisodeName": "Especial - {0}",
|
||||
"VersionNumber": "Versió {0}"
|
||||
"VersionNumber": "Versió {0}",
|
||||
"TaskDownloadMissingSubtitlesDescription": "Cerca a internet els subtítols que faltin a partir de la configuració de metadades.",
|
||||
"TaskDownloadMissingSubtitles": "Descarrega els subtítols que faltin",
|
||||
"TaskRefreshChannelsDescription": "Actualitza la informació dels canals d'internet.",
|
||||
"TaskRefreshChannels": "Actualitza Canals",
|
||||
"TaskCleanTranscodeDescription": "Elimina els arxius temporals de transcodificacions que tinguin més d'un dia.",
|
||||
"TaskCleanTranscode": "Neteja les transcodificacions",
|
||||
"TaskUpdatePluginsDescription": "Actualitza les extensions que estan configurades per actualitzar-se automàticament.",
|
||||
"TaskUpdatePlugins": "Actualitza les extensions",
|
||||
"TaskRefreshPeopleDescription": "Actualitza les metadades dels actors i directors de la teva mediateca.",
|
||||
"TaskRefreshPeople": "Actualitza Persones",
|
||||
"TaskCleanLogsDescription": "Esborra els logs que tinguin més de {0} dies.",
|
||||
"TaskCleanLogs": "Neteja els registres",
|
||||
"TaskRefreshLibraryDescription": "Escaneja la mediateca buscant fitxers nous i refresca les metadades.",
|
||||
"TaskRefreshLibrary": "Escaneja la biblioteca de mitjans",
|
||||
"TaskRefreshChapterImagesDescription": "Crea les miniatures dels vídeos que tinguin capítols.",
|
||||
"TaskRefreshChapterImages": "Extreure les imatges dels capítols",
|
||||
"TaskCleanCacheDescription": "Elimina els arxius temporals que ja no són necessaris per al servidor.",
|
||||
"TaskCleanCache": "Elimina arxius temporals",
|
||||
"TasksChannelsCategory": "Canals d'internet",
|
||||
"TasksApplicationCategory": "Aplicació",
|
||||
"TasksLibraryCategory": "Biblioteca",
|
||||
"TasksMaintenanceCategory": "Manteniment"
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"HeaderFavoriteEpisodes": "Oblíbené epizody",
|
||||
"HeaderFavoriteShows": "Oblíbené seriály",
|
||||
"HeaderFavoriteSongs": "Oblíbená hudba",
|
||||
"HeaderLiveTV": "Živá TV",
|
||||
"HeaderLiveTV": "Televize",
|
||||
"HeaderNextUp": "Nadcházející",
|
||||
"HeaderRecordingGroups": "Skupiny nahrávek",
|
||||
"HomeVideos": "Domáci videa",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Albums": "Άλμπουμ",
|
||||
"Albums": "Άλμπουμς",
|
||||
"AppDeviceValues": "Εφαρμογή: {0}, Συσκευή: {1}",
|
||||
"Application": "Εφαρμογή",
|
||||
"Artists": "Καλλιτέχνες",
|
||||
@@ -92,5 +92,27 @@
|
||||
"UserStoppedPlayingItemWithValues": "{0} τελείωσε να παίζει {1} σε {2}",
|
||||
"ValueHasBeenAddedToLibrary": "{0} προστέθηκαν στη βιβλιοθήκη πολυμέσων σας",
|
||||
"ValueSpecialEpisodeName": "Σπέσιαλ - {0}",
|
||||
"VersionNumber": "Έκδοση {0}"
|
||||
"VersionNumber": "Έκδοση {0}",
|
||||
"TaskRefreshPeople": "Ανανέωση Ατόμων",
|
||||
"TaskCleanLogsDescription": "Διαγράφει τα αρχεία καταγραφής που είναι άνω των {0} ημερών.",
|
||||
"TaskCleanLogs": "Καθαρισμός Καταλόγου Καταγραφής",
|
||||
"TaskRefreshLibraryDescription": "Σαρώνει την βιβλιοθήκη πολυμέσων σας για νέα αρχεία και αναζωογονεί τα μεταδεδομένα.",
|
||||
"TaskRefreshLibrary": "Βιβλιοθήκη Σάρωσης Πολυμέσων",
|
||||
"TaskRefreshChapterImagesDescription": "Δημιουργεί μικρογραφίες για βίντεο με κεφάλαια.",
|
||||
"TaskRefreshChapterImages": "Εξαγωγή Εικόνων Κεφαλαίου",
|
||||
"TaskCleanCacheDescription": "Τα διαγραμμένα αρχεία προσωρινής μνήμης που δεν χρειάζονται πλέον από το σύστημα.",
|
||||
"TaskCleanCache": "Καθαρισμός Καταλόγου Προσωρινής Μνήμης",
|
||||
"TasksChannelsCategory": "Κανάλια Διαδικτύου",
|
||||
"TasksApplicationCategory": "Εφαρμογή",
|
||||
"TasksLibraryCategory": "Βιβλιοθήκη",
|
||||
"TasksMaintenanceCategory": "Συντήρηση",
|
||||
"TaskDownloadMissingSubtitlesDescription": "Αναζητήσεις στο διαδίκτυο όπου λείπουν υπότιτλους με βάση τη διαμόρφωση μεταδεδομένων.",
|
||||
"TaskDownloadMissingSubtitles": "Λήψη υπότιτλων που λείπουν",
|
||||
"TaskRefreshChannelsDescription": "Ανανεώνει τις πληροφορίες καναλιού στο διαδικτύου.",
|
||||
"TaskRefreshChannels": "Ανανέωση Καναλιών",
|
||||
"TaskCleanTranscodeDescription": "Διαγράφει αρχείου διακωδικοποιητή περισσότερο από μία ημέρα.",
|
||||
"TaskCleanTranscode": "Καθαρισμός Kαταλόγου Διακωδικοποιητή",
|
||||
"TaskUpdatePluginsDescription": "Κατεβάζει και εγκαθιστά ενημερώσεις για τις προσθήκες που έχουν ρυθμιστεί για αυτόματη ενημέρωση.",
|
||||
"TaskUpdatePlugins": "Ενημέρωση Προσθηκών",
|
||||
"TaskRefreshPeopleDescription": "Ενημερώνει μεταδεδομένα για ηθοποιούς και σκηνοθέτες στην βιβλιοθήκη των πολυμέσων σας."
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"HeaderFavoriteShows": "Programas favoritos",
|
||||
"HeaderFavoriteSongs": "Canciones favoritas",
|
||||
"HeaderLiveTV": "TV en vivo",
|
||||
"HeaderNextUp": "A Continuación",
|
||||
"HeaderNextUp": "Siguiente",
|
||||
"HeaderRecordingGroups": "Grupos de grabación",
|
||||
"HomeVideos": "Videos caseros",
|
||||
"Inherit": "Heredar",
|
||||
@@ -44,7 +44,7 @@
|
||||
"NameInstallFailed": "{0} instalación fallida",
|
||||
"NameSeasonNumber": "Temporada {0}",
|
||||
"NameSeasonUnknown": "Temporada desconocida",
|
||||
"NewVersionIsAvailable": "Una nueva versión del Servidor Jellyfin está disponible para descargar.",
|
||||
"NewVersionIsAvailable": "Una nueva versión del servidor Jellyfin está disponible para descargar.",
|
||||
"NotificationOptionApplicationUpdateAvailable": "Actualización de la aplicación disponible",
|
||||
"NotificationOptionApplicationUpdateInstalled": "Actualización de la aplicación instalada",
|
||||
"NotificationOptionAudioPlayback": "Se inició la reproducción de audio",
|
||||
@@ -56,7 +56,7 @@
|
||||
"NotificationOptionPluginInstalled": "Complemento instalado",
|
||||
"NotificationOptionPluginUninstalled": "Complemento desinstalado",
|
||||
"NotificationOptionPluginUpdateInstalled": "Actualización de complemento instalada",
|
||||
"NotificationOptionServerRestartRequired": "Se necesita reiniciar el Servidor",
|
||||
"NotificationOptionServerRestartRequired": "Se necesita reiniciar el servidor",
|
||||
"NotificationOptionTaskFailed": "Falla de tarea programada",
|
||||
"NotificationOptionUserLockedOut": "Usuario bloqueado",
|
||||
"NotificationOptionVideoPlayback": "Se inició la reproducción de video",
|
||||
@@ -71,7 +71,7 @@
|
||||
"ScheduledTaskFailedWithName": "{0} falló",
|
||||
"ScheduledTaskStartedWithName": "{0} iniciado",
|
||||
"ServerNameNeedsToBeRestarted": "{0} necesita ser reiniciado",
|
||||
"Shows": "Series",
|
||||
"Shows": "Programas",
|
||||
"Songs": "Canciones",
|
||||
"StartupEmbyServerIsLoading": "El servidor Jellyfin se está cargando. Vuelve a intentarlo en breve.",
|
||||
"SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}",
|
||||
@@ -94,25 +94,25 @@
|
||||
"ValueSpecialEpisodeName": "Especial - {0}",
|
||||
"VersionNumber": "Versión {0}",
|
||||
"TaskDownloadMissingSubtitlesDescription": "Busca en internet los subtítulos que falten basándose en la configuración de los metadatos.",
|
||||
"TaskDownloadMissingSubtitles": "Descargar subtítulos extraviados",
|
||||
"TaskDownloadMissingSubtitles": "Descargar subtítulos faltantes",
|
||||
"TaskRefreshChannelsDescription": "Actualizar información de canales de internet.",
|
||||
"TaskRefreshChannels": "Actualizar canales",
|
||||
"TaskCleanTranscodeDescription": "Eliminar archivos transcodificados con mas de un día de antigüedad.",
|
||||
"TaskCleanTranscode": "Limpiar directorio de Transcodificado",
|
||||
"TaskCleanTranscode": "Limpiar directorio de transcodificación",
|
||||
"TaskUpdatePluginsDescription": "Descargar e instalar actualizaciones para complementos que estén configurados en actualizar automáticamente.",
|
||||
"TaskUpdatePlugins": "Actualizar complementos",
|
||||
"TaskRefreshPeopleDescription": "Actualizar metadatos de actores y directores en su librería multimedia.",
|
||||
"TaskRefreshPeopleDescription": "Actualizar metadatos de actores y directores en su biblioteca multimedia.",
|
||||
"TaskRefreshPeople": "Actualizar personas",
|
||||
"TaskCleanLogsDescription": "Eliminar archivos de registro que tengan mas de {0} días de antigüedad.",
|
||||
"TaskCleanLogs": "Limpiar directorio de registros",
|
||||
"TaskRefreshLibraryDescription": "Escanear su librería multimedia por nuevos archivos y refrescar metadatos.",
|
||||
"TaskRefreshLibrary": "Escanear librería multimedia",
|
||||
"TaskRefreshLibraryDescription": "Escanear su biblioteca multimedia por nuevos archivos y refrescar metadatos.",
|
||||
"TaskRefreshLibrary": "Escanear biblioteca multimedia",
|
||||
"TaskRefreshChapterImagesDescription": "Crear miniaturas de videos que tengan capítulos.",
|
||||
"TaskRefreshChapterImages": "Extraer imágenes de capitulo",
|
||||
"TaskCleanCacheDescription": "Eliminar archivos de cache que no se necesiten en el sistema.",
|
||||
"TaskCleanCache": "Limpiar directorio Cache",
|
||||
"TasksChannelsCategory": "Canales de Internet",
|
||||
"TasksApplicationCategory": "Solicitud",
|
||||
"TaskRefreshChapterImages": "Extraer imágenes de capítulo",
|
||||
"TaskCleanCacheDescription": "Eliminar archivos de caché que no se necesiten en el sistema.",
|
||||
"TaskCleanCache": "Limpiar directorio caché",
|
||||
"TasksChannelsCategory": "Canales de internet",
|
||||
"TasksApplicationCategory": "Aplicación",
|
||||
"TasksLibraryCategory": "Biblioteca",
|
||||
"TasksMaintenanceCategory": "Mantenimiento"
|
||||
}
|
||||
|
||||
@@ -11,21 +11,21 @@
|
||||
"Collections": "Colecciones",
|
||||
"DeviceOfflineWithName": "{0} se ha desconectado",
|
||||
"DeviceOnlineWithName": "{0} está conectado",
|
||||
"FailedLoginAttemptWithUserName": "Intento fallido de inicio de sesión de {0}",
|
||||
"FailedLoginAttemptWithUserName": "Intento fallido de inicio de sesión desde {0}",
|
||||
"Favorites": "Favoritos",
|
||||
"Folders": "Carpetas",
|
||||
"Genres": "Géneros",
|
||||
"HeaderAlbumArtists": "Artistas del álbum",
|
||||
"HeaderCameraUploads": "Subidos desde Camara",
|
||||
"HeaderContinueWatching": "Continuar Viendo",
|
||||
"HeaderCameraUploads": "Subidas desde la cámara",
|
||||
"HeaderContinueWatching": "Continuar viendo",
|
||||
"HeaderFavoriteAlbums": "Álbumes favoritos",
|
||||
"HeaderFavoriteArtists": "Artistas favoritos",
|
||||
"HeaderFavoriteEpisodes": "Episodios favoritos",
|
||||
"HeaderFavoriteShows": "Programas favoritos",
|
||||
"HeaderFavoriteSongs": "Canciones favoritas",
|
||||
"HeaderLiveTV": "TV en Vivo",
|
||||
"HeaderNextUp": "A Continuación",
|
||||
"HeaderRecordingGroups": "Grupos de Grabaciones",
|
||||
"HeaderLiveTV": "TV en vivo",
|
||||
"HeaderNextUp": "A continuación",
|
||||
"HeaderRecordingGroups": "Grupos de grabación",
|
||||
"HomeVideos": "Videos caseros",
|
||||
"Inherit": "Heredar",
|
||||
"ItemAddedWithName": "{0} fue agregado a la biblioteca",
|
||||
@@ -41,12 +41,12 @@
|
||||
"Movies": "Películas",
|
||||
"Music": "Música",
|
||||
"MusicVideos": "Videos musicales",
|
||||
"NameInstallFailed": "{0} instalación fallida",
|
||||
"NameInstallFailed": "Falló la instalación de {0}",
|
||||
"NameSeasonNumber": "Temporada {0}",
|
||||
"NameSeasonUnknown": "Temporada Desconocida",
|
||||
"NameSeasonUnknown": "Temporada desconocida",
|
||||
"NewVersionIsAvailable": "Una nueva versión del Servidor Jellyfin está disponible para descargar.",
|
||||
"NotificationOptionApplicationUpdateAvailable": "Actualización de aplicación disponible",
|
||||
"NotificationOptionApplicationUpdateInstalled": "Actualización de aplicación instalada",
|
||||
"NotificationOptionApplicationUpdateAvailable": "Actualización de la aplicación disponible",
|
||||
"NotificationOptionApplicationUpdateInstalled": "Actualización de la aplicación instalada",
|
||||
"NotificationOptionAudioPlayback": "Reproducción de audio iniciada",
|
||||
"NotificationOptionAudioPlaybackStopped": "Reproducción de audio detenida",
|
||||
"NotificationOptionCameraImageUploaded": "Imagen de la cámara subida",
|
||||
@@ -56,7 +56,7 @@
|
||||
"NotificationOptionPluginInstalled": "Complemento instalado",
|
||||
"NotificationOptionPluginUninstalled": "Complemento desinstalado",
|
||||
"NotificationOptionPluginUpdateInstalled": "Actualización de complemento instalada",
|
||||
"NotificationOptionServerRestartRequired": "Se necesita reiniciar el Servidor",
|
||||
"NotificationOptionServerRestartRequired": "Se necesita reiniciar el servidor",
|
||||
"NotificationOptionTaskFailed": "Falla de tarea programada",
|
||||
"NotificationOptionUserLockedOut": "Usuario bloqueado",
|
||||
"NotificationOptionVideoPlayback": "Reproducción de video iniciada",
|
||||
@@ -69,48 +69,48 @@
|
||||
"PluginUpdatedWithName": "{0} fue actualizado",
|
||||
"ProviderValue": "Proveedor: {0}",
|
||||
"ScheduledTaskFailedWithName": "{0} falló",
|
||||
"ScheduledTaskStartedWithName": "{0} Iniciado",
|
||||
"ScheduledTaskStartedWithName": "{0} iniciado",
|
||||
"ServerNameNeedsToBeRestarted": "{0} debe ser reiniciado",
|
||||
"Shows": "Programas",
|
||||
"Songs": "Canciones",
|
||||
"StartupEmbyServerIsLoading": "El servidor Jellyfin esta cargando. Por favor intente de nuevo dentro de poco.",
|
||||
"StartupEmbyServerIsLoading": "El servidor Jellyfin está cargando. Por favor, intente de nuevo pronto.",
|
||||
"SubtitleDownloadFailureForItem": "Falló la descarga de subtítulos para {0}",
|
||||
"SubtitleDownloadFailureFromForItem": "Falló la descarga de subtitulos desde {0} para {1}",
|
||||
"SubtitleDownloadFailureFromForItem": "Falló la descarga de subtítulos desde {0} para {1}",
|
||||
"Sync": "Sincronizar",
|
||||
"System": "Sistema",
|
||||
"TvShows": "Programas de TV",
|
||||
"User": "Usuario",
|
||||
"UserCreatedWithName": "Se ha creado el usuario {0}",
|
||||
"UserDeletedWithName": "Se ha eliminado el usuario {0}",
|
||||
"UserDownloadingItemWithValues": "{0} esta descargando {1}",
|
||||
"UserCreatedWithName": "El usuario {0} ha sido creado",
|
||||
"UserDeletedWithName": "El usuario {0} ha sido eliminado",
|
||||
"UserDownloadingItemWithValues": "{0} está descargando {1}",
|
||||
"UserLockedOutWithName": "El usuario {0} ha sido bloqueado",
|
||||
"UserOfflineFromDevice": "{0} se ha desconectado desde {1}",
|
||||
"UserOnlineFromDevice": "{0} está en línea desde {1}",
|
||||
"UserPasswordChangedWithName": "Se ha cambiado la contraseña para el usuario {0}",
|
||||
"UserPolicyUpdatedWithName": "Las política de usuario ha sido actualizada por {0}",
|
||||
"UserStartedPlayingItemWithValues": "{0} está reproduciéndose {1} en {2}",
|
||||
"UserStoppedPlayingItemWithValues": "{0} ha terminado de reproducirse {1} en {2}",
|
||||
"ValueHasBeenAddedToLibrary": "{0} se han añadido a su biblioteca de medios",
|
||||
"UserPolicyUpdatedWithName": "La política de usuario ha sido actualizada para {0}",
|
||||
"UserStartedPlayingItemWithValues": "{0} está reproduciendo {1} en {2}",
|
||||
"UserStoppedPlayingItemWithValues": "{0} ha terminado de reproducir {1} en {2}",
|
||||
"ValueHasBeenAddedToLibrary": "{0} se ha añadido a tu biblioteca de medios",
|
||||
"ValueSpecialEpisodeName": "Especial - {0}",
|
||||
"VersionNumber": "Versión {0}",
|
||||
"TaskDownloadMissingSubtitlesDescription": "Buscar subtítulos de internet basado en configuración de metadatos.",
|
||||
"TaskDownloadMissingSubtitles": "Descargar subtítulos perdidos",
|
||||
"TaskRefreshChannelsDescription": "Refrescar información de canales de internet.",
|
||||
"TaskDownloadMissingSubtitlesDescription": "Busca subtítulos faltantes en Internet basándose en la configuración de metadatos.",
|
||||
"TaskDownloadMissingSubtitles": "Descargar subtítulos faltantes",
|
||||
"TaskRefreshChannelsDescription": "Actualiza la información de canales de Internet.",
|
||||
"TaskRefreshChannels": "Actualizar canales",
|
||||
"TaskCleanTranscodeDescription": "Eliminar archivos transcodificados que tengan mas de un día.",
|
||||
"TaskCleanTranscodeDescription": "Elimina archivos transcodificados que tengan más de un día.",
|
||||
"TaskCleanTranscode": "Limpiar directorio de transcodificado",
|
||||
"TaskUpdatePluginsDescription": "Descargar y actualizar complementos que están configurados para actualizarse automáticamente.",
|
||||
"TaskUpdatePluginsDescription": "Descarga e instala actualizaciones para complementos que están configurados para actualizarse automáticamente.",
|
||||
"TaskUpdatePlugins": "Actualizar complementos",
|
||||
"TaskRefreshPeopleDescription": "Actualizar datos de actores y directores en su librería multimedia.",
|
||||
"TaskRefreshPeople": "Refrescar persona",
|
||||
"TaskCleanLogsDescription": "Eliminar archivos de registro con mas de {0} días.",
|
||||
"TaskCleanLogs": "Directorio de logo limpio",
|
||||
"TaskRefreshLibraryDescription": "Escanear su librería multimedia para nuevos archivos y refrescar metadatos.",
|
||||
"TaskRefreshLibrary": "Escanear librería multimerdia",
|
||||
"TaskRefreshChapterImagesDescription": "Crear miniaturas para videos con capítulos.",
|
||||
"TaskRefreshChapterImages": "Extraer imágenes de capítulos",
|
||||
"TaskCleanCacheDescription": "Eliminar archivos cache que ya no se necesiten por el sistema.",
|
||||
"TaskCleanCache": "Limpiar directorio cache",
|
||||
"TaskRefreshPeopleDescription": "Actualiza metadatos de actores y directores en tu biblioteca de medios.",
|
||||
"TaskRefreshPeople": "Actualizar personas",
|
||||
"TaskCleanLogsDescription": "Elimina archivos de registro con más de {0} días de antigüedad.",
|
||||
"TaskCleanLogs": "Limpiar directorio de registros",
|
||||
"TaskRefreshLibraryDescription": "Escanea tu biblioteca de medios por archivos nuevos y actualiza los metadatos.",
|
||||
"TaskRefreshLibrary": "Escanear biblioteca de medios",
|
||||
"TaskRefreshChapterImagesDescription": "Crea miniaturas para videos que tienen capítulos.",
|
||||
"TaskRefreshChapterImages": "Extraer imágenes de los capítulos",
|
||||
"TaskCleanCacheDescription": "Elimina archivos caché que ya no son necesarios para el sistema.",
|
||||
"TaskCleanCache": "Limpiar directorio caché",
|
||||
"TasksChannelsCategory": "Canales de Internet",
|
||||
"TasksApplicationCategory": "Aplicación",
|
||||
"TasksLibraryCategory": "Biblioteca",
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
"ScheduledTaskFailedWithName": "{0} falló",
|
||||
"ScheduledTaskStartedWithName": "{0} iniciada",
|
||||
"ServerNameNeedsToBeRestarted": "{0} necesita ser reiniciado",
|
||||
"Shows": "Series",
|
||||
"Shows": "Mostrar",
|
||||
"Songs": "Canciones",
|
||||
"StartupEmbyServerIsLoading": "Jellyfin Server se está cargando. Vuelve a intentarlo en breve.",
|
||||
"SubtitleDownloadFailureForItem": "Error al descargar subtítulos para {0}",
|
||||
|
||||
117
Emby.Server.Implementations/Localization/Core/es_419.json
Normal file
117
Emby.Server.Implementations/Localization/Core/es_419.json
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"LabelRunningTimeValue": "Duración: {0}",
|
||||
"ValueSpecialEpisodeName": "Especial - {0}",
|
||||
"Sync": "Sincronizar",
|
||||
"Songs": "Canciones",
|
||||
"Shows": "Programas",
|
||||
"Playlists": "Listas de reproducción",
|
||||
"Photos": "Fotos",
|
||||
"Movies": "Películas",
|
||||
"HeaderNextUp": "A continuación",
|
||||
"HeaderLiveTV": "TV en vivo",
|
||||
"HeaderFavoriteSongs": "Canciones favoritas",
|
||||
"HeaderFavoriteArtists": "Artistas favoritos",
|
||||
"HeaderFavoriteAlbums": "Álbumes favoritos",
|
||||
"HeaderFavoriteEpisodes": "Episodios favoritos",
|
||||
"HeaderFavoriteShows": "Programas favoritos",
|
||||
"HeaderContinueWatching": "Continuar viendo",
|
||||
"HeaderAlbumArtists": "Artistas del álbum",
|
||||
"Genres": "Géneros",
|
||||
"Folders": "Carpetas",
|
||||
"Favorites": "Favoritos",
|
||||
"Collections": "Colecciones",
|
||||
"Channels": "Canales",
|
||||
"Books": "Libros",
|
||||
"Artists": "Artistas",
|
||||
"Albums": "Álbumes",
|
||||
"TaskDownloadMissingSubtitlesDescription": "Busca subtítulos faltantes en Internet basándose en la configuración de metadatos.",
|
||||
"TaskDownloadMissingSubtitles": "Descargar subtítulos faltantes",
|
||||
"TaskRefreshChannelsDescription": "Actualiza la información de canales de Internet.",
|
||||
"TaskRefreshChannels": "Actualizar canales",
|
||||
"TaskCleanTranscodeDescription": "Elimina archivos transcodificados que tengan más de un día.",
|
||||
"TaskCleanTranscode": "Limpiar directorio de transcodificado",
|
||||
"TaskUpdatePluginsDescription": "Descarga e instala actualizaciones para complementos que están configurados para actualizarse automáticamente.",
|
||||
"TaskUpdatePlugins": "Actualizar complementos",
|
||||
"TaskRefreshPeopleDescription": "Actualiza metadatos de actores y directores en tu biblioteca de medios.",
|
||||
"TaskRefreshPeople": "Actualizar personas",
|
||||
"TaskCleanLogsDescription": "Elimina archivos de registro con más de {0} días de antigüedad.",
|
||||
"TaskCleanLogs": "Limpiar directorio de registros",
|
||||
"TaskRefreshLibraryDescription": "Escanea tu biblioteca de medios por archivos nuevos y actualiza los metadatos.",
|
||||
"TaskRefreshLibrary": "Escanear biblioteca de medios",
|
||||
"TaskRefreshChapterImagesDescription": "Crea miniaturas para videos que tienen capítulos.",
|
||||
"TaskRefreshChapterImages": "Extraer imágenes de los capítulos",
|
||||
"TaskCleanCacheDescription": "Elimina archivos caché que ya no son necesarios para el sistema.",
|
||||
"TaskCleanCache": "Limpiar directorio caché",
|
||||
"TasksChannelsCategory": "Canales de Internet",
|
||||
"TasksApplicationCategory": "Aplicación",
|
||||
"TasksLibraryCategory": "Biblioteca",
|
||||
"TasksMaintenanceCategory": "Mantenimiento",
|
||||
"VersionNumber": "Versión {0}",
|
||||
"ValueHasBeenAddedToLibrary": "{0} se ha añadido a tu biblioteca de medios",
|
||||
"UserStoppedPlayingItemWithValues": "{0} ha terminado de reproducir {1} en {2}",
|
||||
"UserStartedPlayingItemWithValues": "{0} está reproduciendo {1} en {2}",
|
||||
"UserPolicyUpdatedWithName": "La política de usuario ha sido actualizada para {0}",
|
||||
"UserPasswordChangedWithName": "Se ha cambiado la contraseña para el usuario {0}",
|
||||
"UserOnlineFromDevice": "{0} está en línea desde {1}",
|
||||
"UserOfflineFromDevice": "{0} se ha desconectado desde {1}",
|
||||
"UserLockedOutWithName": "El usuario {0} ha sido bloqueado",
|
||||
"UserDownloadingItemWithValues": "{0} está descargando {1}",
|
||||
"UserDeletedWithName": "El usuario {0} ha sido eliminado",
|
||||
"UserCreatedWithName": "El usuario {0} ha sido creado",
|
||||
"User": "Usuario",
|
||||
"TvShows": "Programas de TV",
|
||||
"System": "Sistema",
|
||||
"SubtitleDownloadFailureFromForItem": "Falló la descarga de subtítulos desde {0} para {1}",
|
||||
"StartupEmbyServerIsLoading": "El servidor Jellyfin está cargando. Por favor, intente de nuevo pronto.",
|
||||
"ServerNameNeedsToBeRestarted": "{0} debe ser reiniciado",
|
||||
"ScheduledTaskStartedWithName": "{0} iniciado",
|
||||
"ScheduledTaskFailedWithName": "{0} falló",
|
||||
"ProviderValue": "Proveedor: {0}",
|
||||
"PluginUpdatedWithName": "{0} fue actualizado",
|
||||
"PluginUninstalledWithName": "{0} fue desinstalado",
|
||||
"PluginInstalledWithName": "{0} fue instalado",
|
||||
"Plugin": "Complemento",
|
||||
"NotificationOptionVideoPlaybackStopped": "Reproducción de video detenida",
|
||||
"NotificationOptionVideoPlayback": "Reproducción de video iniciada",
|
||||
"NotificationOptionUserLockedOut": "Usuario bloqueado",
|
||||
"NotificationOptionTaskFailed": "Falla de tarea programada",
|
||||
"NotificationOptionServerRestartRequired": "Se necesita reiniciar el servidor",
|
||||
"NotificationOptionPluginUpdateInstalled": "Actualización de complemento instalada",
|
||||
"NotificationOptionPluginUninstalled": "Complemento desinstalado",
|
||||
"NotificationOptionPluginInstalled": "Complemento instalado",
|
||||
"NotificationOptionPluginError": "Falla de complemento",
|
||||
"NotificationOptionNewLibraryContent": "Nuevo contenido agregado",
|
||||
"NotificationOptionInstallationFailed": "Falla de instalación",
|
||||
"NotificationOptionCameraImageUploaded": "Imagen de la cámara subida",
|
||||
"NotificationOptionAudioPlaybackStopped": "Reproducción de audio detenida",
|
||||
"NotificationOptionAudioPlayback": "Reproducción de audio iniciada",
|
||||
"NotificationOptionApplicationUpdateInstalled": "Actualización de la aplicación instalada",
|
||||
"NotificationOptionApplicationUpdateAvailable": "Actualización de la aplicación disponible",
|
||||
"NewVersionIsAvailable": "Una nueva versión del Servidor Jellyfin está disponible para descargar.",
|
||||
"NameSeasonUnknown": "Temporada desconocida",
|
||||
"NameSeasonNumber": "Temporada {0}",
|
||||
"NameInstallFailed": "Falló la instalación de {0}",
|
||||
"MusicVideos": "Videos musicales",
|
||||
"Music": "Música",
|
||||
"MixedContent": "Contenido mezclado",
|
||||
"MessageServerConfigurationUpdated": "Se ha actualizado la configuración del servidor",
|
||||
"MessageNamedServerConfigurationUpdatedWithValue": "Se ha actualizado la sección {0} de la configuración del servidor",
|
||||
"MessageApplicationUpdatedTo": "El servidor Jellyfin ha sido actualizado a {0}",
|
||||
"MessageApplicationUpdated": "El servidor Jellyfin ha sido actualizado",
|
||||
"Latest": "Recientes",
|
||||
"LabelIpAddressValue": "Dirección IP: {0}",
|
||||
"ItemRemovedWithName": "{0} fue removido de la biblioteca",
|
||||
"ItemAddedWithName": "{0} fue agregado a la biblioteca",
|
||||
"Inherit": "Heredar",
|
||||
"HomeVideos": "Videos caseros",
|
||||
"HeaderRecordingGroups": "Grupos de grabación",
|
||||
"HeaderCameraUploads": "Subidas desde la cámara",
|
||||
"FailedLoginAttemptWithUserName": "Intento fallido de inicio de sesión desde {0}",
|
||||
"DeviceOnlineWithName": "{0} está conectado",
|
||||
"DeviceOfflineWithName": "{0} se ha desconectado",
|
||||
"ChapterNameValue": "Capítulo {0}",
|
||||
"CameraImageUploadedFrom": "Una nueva imagen de cámara ha sido subida desde {0}",
|
||||
"AuthenticationSucceededWithUserName": "{0} autenticado con éxito",
|
||||
"Application": "Aplicación",
|
||||
"AppDeviceValues": "App: {0}, Dispositivo: {1}"
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user