mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-02 22:08:27 +01:00
Put json serializer options in private field
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
|
||||
private bool _hasExited;
|
||||
private Stream _logFileStream;
|
||||
private string _targetPath;
|
||||
@@ -93,7 +93,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
|
||||
_logFileStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
||||
|
||||
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(mediaSource, JsonDefaults.GetOptions()) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
|
||||
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(mediaSource, _jsonOptions) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
|
||||
_logFileStream.Write(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length);
|
||||
|
||||
_process = new Process
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
private readonly string _dataPath;
|
||||
private readonly object _fileDataLock = new object();
|
||||
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
|
||||
private T[] _items;
|
||||
|
||||
public ItemDataProvider(
|
||||
@@ -45,7 +46,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
try
|
||||
{
|
||||
var jsonString = File.ReadAllText(_dataPath);
|
||||
_items = JsonSerializer.Deserialize<T[]>(jsonString, JsonDefaults.GetOptions());
|
||||
_items = JsonSerializer.Deserialize<T[]>(jsonString, _jsonOptions);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -61,7 +62,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_dataPath));
|
||||
using FileStream stream = File.OpenWrite(_dataPath);
|
||||
JsonSerializer.SerializeAsync(stream, _items, JsonDefaults.GetOptions());
|
||||
JsonSerializer.SerializeAsync(stream, _items, _jsonOptions);
|
||||
}
|
||||
|
||||
public IReadOnlyList<T> GetAll()
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
|
||||
private readonly ConcurrentDictionary<string, NameValuePair> _tokens = new ConcurrentDictionary<string, NameValuePair>();
|
||||
private DateTime _lastErrorResponse;
|
||||
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.GetOptions();
|
||||
|
||||
public SchedulesDirect(
|
||||
ILogger<SchedulesDirect> logger,
|
||||
@@ -102,9 +103,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
}
|
||||
};
|
||||
|
||||
var jsonOptions = JsonDefaults.GetOptions();
|
||||
|
||||
var requestString = JsonSerializer.Serialize(requestList, jsonOptions);
|
||||
var requestString = JsonSerializer.Serialize(requestList, _jsonOptions);
|
||||
_logger.LogDebug("Request string for schedules is: {RequestString}", requestString);
|
||||
|
||||
using var options = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/schedules");
|
||||
@@ -112,7 +111,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
options.Headers.TryAddWithoutValidation("token", token);
|
||||
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
||||
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
var dailySchedules = await JsonSerializer.DeserializeAsync<List<ScheduleDirect.Day>>(responseStream, jsonOptions).ConfigureAwait(false);
|
||||
var dailySchedules = await JsonSerializer.DeserializeAsync<List<ScheduleDirect.Day>>(responseStream, _jsonOptions).ConfigureAwait(false);
|
||||
_logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
|
||||
|
||||
using var programRequestOptions = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/programs");
|
||||
@@ -123,7 +122,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
|
||||
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
|
||||
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
var programDetails = await JsonSerializer.DeserializeAsync<List<ScheduleDirect.ProgramDetails>>(innerResponseStream, jsonOptions).ConfigureAwait(false);
|
||||
var programDetails = await JsonSerializer.DeserializeAsync<List<ScheduleDirect.ProgramDetails>>(innerResponseStream, _jsonOptions).ConfigureAwait(false);
|
||||
var programDict = programDetails.ToDictionary(p => p.programID, y => y);
|
||||
|
||||
var programIdsWithImages =
|
||||
@@ -479,7 +478,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
{
|
||||
using var innerResponse2 = await Send(message, true, info, cancellationToken).ConfigureAwait(false);
|
||||
await using var response = await innerResponse2.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
return await JsonSerializer.DeserializeAsync<List<ScheduleDirect.ShowImages>>(response, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
return await JsonSerializer.DeserializeAsync<List<ScheduleDirect.ShowImages>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -508,7 +507,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
using var httpResponse = await Send(options, false, info, cancellationToken).ConfigureAwait(false);
|
||||
await using var response = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var root = await JsonSerializer.DeserializeAsync<List<ScheduleDirect.Headends>>(response, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<List<ScheduleDirect.Headends>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (root != null)
|
||||
{
|
||||
@@ -649,7 +648,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
using var response = await Send(options, false, null, cancellationToken).ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<ScheduleDirect.Token>(stream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<ScheduleDirect.Token>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
if (string.Equals(root.message, "OK", StringComparison.Ordinal))
|
||||
{
|
||||
_logger.LogInformation("Authenticated with Schedules Direct token: " + root.token);
|
||||
@@ -705,7 +704,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
using var response = httpResponse.Content;
|
||||
var root = await JsonSerializer.DeserializeAsync<ScheduleDirect.Lineups>(stream, JsonDefaults.GetOptions()).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<ScheduleDirect.Lineups>(stream, _jsonOptions).ConfigureAwait(false);
|
||||
|
||||
return root.lineups.Any(i => string.Equals(info.ListingsId, i.lineup, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
@@ -777,7 +776,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
|
||||
using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
||||
await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<ScheduleDirect.Channel>(stream, JsonDefaults.GetOptions()).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<ScheduleDirect.Channel>(stream, _jsonOptions).ConfigureAwait(false);
|
||||
_logger.LogInformation("Found {ChannelCount} channels on the lineup on ScheduleDirect", root.map.Count);
|
||||
_logger.LogInformation("Mapping Stations to Channel");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user