Style change

This commit is contained in:
xjasonlyu
2022-06-29 18:17:26 +08:00
parent 69361ae085
commit c29182c19f
3 changed files with 37 additions and 41 deletions

View File

@@ -18,6 +18,43 @@ public enum TranslationEngine
public class PluginConfiguration : BasePluginConfiguration
{
#region TableSerializer
private class TableSerializer
{
public static Dictionary<string, string> Deserialize(string text)
{
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
var reader = new StringReader(text ?? string.Empty);
while (reader.ReadLine() is { } line)
{
var kvp = line.Split('=', 2).Select(s => s.Trim()).ToList();
if (string.IsNullOrWhiteSpace(kvp.First()))
continue;
dictionary[kvp[0]] = kvp.Count switch
{
1 => null,
2 => kvp[1],
_ => dictionary[kvp[0]]
};
}
return dictionary;
}
public static string Serialize(Dictionary<string, string> table)
{
return table?.Any() != true
? string.Empty
: string.Join('\n',
table.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key))
.Select(kvp => $"{kvp.Key?.Trim()}={kvp.Value?.Trim()}"));
}
}
#endregion
#region General
public string Server { get; set; } = "https://api.javtube.internal";
@@ -87,41 +124,4 @@ public class PluginConfiguration : BasePluginConfiguration
#endregion
#endregion
#region TableSerializer
private class TableSerializer
{
public static Dictionary<string, string> Deserialize(string text)
{
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
var reader = new StringReader(text ?? string.Empty);
while (reader.ReadLine() is { } line)
{
var kvp = line.Split('=', 2).Select(s => s.Trim()).ToList();
if (string.IsNullOrWhiteSpace(kvp.First()))
continue;
dictionary[kvp[0]] = kvp.Count switch
{
1 => null,
2 => kvp[1],
_ => dictionary[kvp[0]]
};
}
return dictionary;
}
public static string Serialize(Dictionary<string, string> table)
{
return table?.Any() != true
? string.Empty
: string.Join('\n',
table.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key))
.Select(kvp => $"{kvp.Key?.Trim()}={kvp.Value?.Trim()}"));
}
}
#endregion
}

View File

@@ -10,9 +10,7 @@ internal static class EnumerableExtensions
public static IEnumerable<string> Substitute(this IEnumerable<string> source, Dictionary<string, string> table)
{
if (table?.Any() != true)
{
return source;
}
var target = new List<string>();

View File

@@ -121,13 +121,11 @@ public class MovieProvider : BaseProvider, IRemoteMetadataProvider<Movie, MovieI
// Add director.
if (!string.IsNullOrWhiteSpace(m.Director))
{
result.AddPerson(new PersonInfo
{
Name = m.Director,
Type = PersonType.Director
});
}
// Add actors.
foreach (var name in m.Actors)