mirror of
https://github.com/metatube-community/jellyfin-plugin-metatube.git
synced 2026-07-11 16:05:38 +08:00
Add GenreSubstitution option
This commit is contained in:
@@ -59,6 +59,8 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
#endregion
|
||||
|
||||
#region Genre
|
||||
|
||||
public bool EnableGenreSubstitution { get; set; } = true;
|
||||
|
||||
public string GenreSubstitutionTable { get; set; } = DefaultGenreSubstitutionTable;
|
||||
|
||||
|
||||
@@ -94,6 +94,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkboxContainer checkboxContainer-withDescripton">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="chkEnableGenreSubstitution" is="emby-checkbox" name="chkEnableGenreSubstitution" type="checkbox"/>
|
||||
<span>Enable Genre Substitution</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabel-float inputLabelUnfocused" for="txtGenreSubstitutionTable">Genre substitution table:</label>
|
||||
<textarea class="emby-input" id="txtGenreSubstitutionTable" is="emby-input" name="txtGenreSubstitutionTable" rows="10" type="text"></textarea>
|
||||
@@ -148,6 +155,7 @@
|
||||
$('#txtBaiduAppId', page).val(config.BaiduAppId).change();
|
||||
$('#txtBaiduAppKey', page).val(config.BaiduAppKey).change();
|
||||
$('#txtGoogleApiKey', page).val(config.GoogleApiKey).change();
|
||||
page.querySelector('#chkEnableGenreSubstitution').checked = config.EnableGenreSubstitution;
|
||||
$('#txtGenreSubstitutionTable', page).val(config.GenreSubstitutionTable).change();
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
@@ -167,6 +175,7 @@
|
||||
config.BaiduAppId = $('#txtBaiduAppId', form).val();
|
||||
config.BaiduAppKey = $('#txtBaiduAppKey', form).val();
|
||||
config.GoogleApiKey = $('#txtGoogleApiKey', form).val();
|
||||
config.EnableGenreSubstitution = $('#chkEnableGenreSubstitution').prop('checked');
|
||||
config.GenreSubstitutionTable = $('#txtGenreSubstitutionTable', form).val();
|
||||
ApiClient.updatePluginConfiguration(JavTubePluginConfig.pluginUniqueId, config).then(
|
||||
Dashboard.processPluginConfigurationUpdateResult);
|
||||
|
||||
@@ -80,19 +80,22 @@ public class OrganizeGenresTask : IScheduledTask
|
||||
|
||||
var genres = item.Genres?.ToList() ?? new List<string>();
|
||||
|
||||
// Deserialize Text to Substitution Table.
|
||||
var substitutionTable = GenreHelper.DeserializeSubstitutionTable(
|
||||
Plugin.Instance.Configuration.GenreSubstitutionTable);
|
||||
|
||||
// Replace Genres.
|
||||
foreach (var genre in genres.Where(genre =>
|
||||
substitutionTable.ContainsKey(genre)).ToArray())
|
||||
if (Plugin.Instance.Configuration.EnableGenreSubstitution)
|
||||
{
|
||||
var value = substitutionTable[genre];
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
genres.Remove(genre); // should just be removed.
|
||||
else
|
||||
genres[genres.IndexOf(genre)] = value; // replace.
|
||||
// Deserialize Text to Substitution Table.
|
||||
var substitutionTable = GenreHelper.DeserializeSubstitutionTable(
|
||||
Plugin.Instance.Configuration.GenreSubstitutionTable);
|
||||
|
||||
// Replace Genres.
|
||||
foreach (var genre in genres.Where(genre =>
|
||||
substitutionTable.ContainsKey(genre)).ToArray())
|
||||
{
|
||||
var value = substitutionTable[genre];
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
genres.Remove(genre); // should just be removed.
|
||||
else
|
||||
genres[genres.IndexOf(genre)] = value; // replace.
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user