mirror of
https://github.com/Crunchy-DL/Crunchy-Downloader.git
synced 2026-04-20 16:32:07 +00:00
Add - Added **hardware acceleration options** for sync timings Add - Added an **icon for episodes removed from Crunchyroll** or moved to a different season Add - Added **highlighting for selected dubs/subs** in history Add - Added **highlighting of episode titles** when all selected dubs/subs are available Add - Added option to **set history series to inactive** Add - Added **filter for Active and Inactive** series in history Add - Added **download retry options** to settings, making retry variables editable Chg - Changed **Sonarr missing filter** to respect the "Skip Unmonitored" setting Chg - Changed to **show an error** if an episode wasn't added to the queue Chg - Changed to show **dates for episodes** in the history Chg - Changed **sync timings algorithm** to improve overall performance Chg - Changed **sync timings algorithm** to more accurately synchronize dubs Chg - Changed **series/season refresh messages** to indicate failure or success more clearly Chg - Changed **error display frequency** to reduce repeated popups for the same message Fix - Fixed **movie detection** to properly verify if the ID corresponds to a movie Fix - Fixed **long option hiding remove buttons** for FFmpeg and MKVMerge additional options Fix - Fixed **toast message timer** not updating correctly Fix - Fixed **path length error** Fix - Fixed a **rare crash when navigating history**
38 lines
No EOL
1.4 KiB
C#
38 lines
No EOL
1.4 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using System.Runtime.Serialization;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace CRD.Utils.JsonConv;
|
|
|
|
public class LocaleConverter : JsonConverter{
|
|
public override bool CanConvert(Type objectType){
|
|
return objectType == typeof(Locale);
|
|
}
|
|
|
|
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer){
|
|
if (reader.TokenType == JsonToken.Null)
|
|
return Locale.Unknown;
|
|
|
|
var value = reader.Value?.ToString();
|
|
|
|
foreach (Locale locale in Enum.GetValues(typeof(Locale))){
|
|
FieldInfo fi = typeof(Locale).GetField(locale.ToString());
|
|
EnumMemberAttribute[] attributes = (EnumMemberAttribute[])fi.GetCustomAttributes(typeof(EnumMemberAttribute), false);
|
|
if (attributes.Length > 0 && attributes[0].Value == value)
|
|
return locale;
|
|
}
|
|
|
|
return Locale.Unknown;
|
|
}
|
|
|
|
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer){
|
|
FieldInfo? fi = value?.GetType().GetField(value.ToString() ?? string.Empty);
|
|
EnumMemberAttribute[] attributes = (EnumMemberAttribute[])fi.GetCustomAttributes(typeof(EnumMemberAttribute), false);
|
|
|
|
if (attributes.Length > 0 && !string.IsNullOrEmpty(attributes[0].Value))
|
|
writer.WriteValue(attributes[0].Value);
|
|
else
|
|
writer.WriteValue(value?.ToString());
|
|
}
|
|
} |