mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-15 10:43:30 +01:00
Remove custom Json serializer from Emby.Server.Implementations
This commit is contained in:
@@ -6,12 +6,14 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Json;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
@@ -23,7 +25,6 @@ using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.Library
|
||||
@@ -36,7 +37,6 @@ namespace Emby.Server.Implementations.Library
|
||||
private readonly IItemRepository _itemRepo;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILogger<MediaSourceManager> _logger;
|
||||
private readonly IUserDataManager _userDataManager;
|
||||
@@ -56,7 +56,6 @@ namespace Emby.Server.Implementations.Library
|
||||
IUserManager userManager,
|
||||
ILibraryManager libraryManager,
|
||||
ILogger<MediaSourceManager> logger,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IFileSystem fileSystem,
|
||||
IUserDataManager userDataManager,
|
||||
IMediaEncoder mediaEncoder)
|
||||
@@ -65,7 +64,6 @@ namespace Emby.Server.Implementations.Library
|
||||
_userManager = userManager;
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_fileSystem = fileSystem;
|
||||
_userDataManager = userDataManager;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
@@ -504,7 +502,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, _appPaths)
|
||||
.AddMediaInfoWithProbe(mediaSource, isAudio, cacheKey, true, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
@@ -516,9 +514,9 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
// TODO: @bond Fix
|
||||
var json = _jsonSerializer.SerializeToString(mediaSource);
|
||||
var json = JsonSerializer.Serialize(mediaSource, JsonDefaults.GetOptions());
|
||||
_logger.LogInformation("Live stream opened: " + json);
|
||||
var clone = _jsonSerializer.DeserializeFromString<MediaSourceInfo>(json);
|
||||
var clone = JsonSerializer.Deserialize<MediaSourceInfo>(json, JsonDefaults.GetOptions());
|
||||
|
||||
if (!request.UserId.Equals(Guid.Empty))
|
||||
{
|
||||
@@ -643,7 +641,8 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
mediaInfo = _jsonSerializer.DeserializeFromFile<MediaInfo>(cacheFilePath);
|
||||
var json = await File.ReadAllTextAsync(cacheFilePath, cancellationToken).ConfigureAwait(false);
|
||||
mediaInfo = JsonSerializer.Deserialize<MediaInfo>(json, JsonDefaults.GetOptions());
|
||||
|
||||
// _logger.LogDebug("Found cached media info");
|
||||
}
|
||||
@@ -679,7 +678,8 @@ namespace Emby.Server.Implementations.Library
|
||||
if (cacheFilePath != null)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
|
||||
_jsonSerializer.SerializeToFile(mediaInfo, cacheFilePath);
|
||||
await using FileStream createStream = File.Create(cacheFilePath);
|
||||
await JsonSerializer.SerializeAsync(createStream, mediaInfo, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// _logger.LogDebug("Saved media info to {0}", cacheFilePath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user