mirror of
https://github.com/metatube-community/jellyfin-plugin-metatube.git
synced 2026-02-02 18:21:48 +08:00
Feature: add openai custom translation support (#436)
This commit is contained in:
@@ -180,6 +180,20 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
#endif
|
||||
public string OpenAiApiKey { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("OpenAI api url")]
|
||||
[Description("Custom OpenAI-compatible api url. (optional)")]
|
||||
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.OpenAi)]
|
||||
#endif
|
||||
public string OpenAiApiUrl { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("OpenAI model")]
|
||||
[Description("Custom OpenAI-compatible api model. (optional)")]
|
||||
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.OpenAi)]
|
||||
#endif
|
||||
public string OpenAiModel { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable title substitution")]
|
||||
#endif
|
||||
|
||||
@@ -217,6 +217,16 @@
|
||||
<input id="txtOpenAiApiKey" is="emby-input" name="txtOpenAiApiKey" type="text"/>
|
||||
<div class="fieldDescription"></div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="txtOpenAiApiUrl">OpenAI api url:</label>
|
||||
<input id="txtOpenAiApiUrl" is="emby-input" name="txtOpenAiApiUrl" required type="text"/>
|
||||
<div class="fieldDescription">Custom OpenAI-compatible api url. (optional)</div>
|
||||
</div>
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="txtOpenAiModel">OpenAI model:</label>
|
||||
<input id="txtOpenAiModel" is="emby-input" name="txtOpenAiModel" type="text"/>
|
||||
<div class="fieldDescription">Custom OpenAI-compatible api model. (optional)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -350,6 +360,8 @@
|
||||
$('#txtDeepLApiKey', page).val(config.DeepLApiKey).change();
|
||||
$('#txtDeepLAltUrl', page).val(config.DeepLAltUrl).change();
|
||||
$('#txtOpenAiApiKey', page).val(config.OpenAiApiKey).change();
|
||||
$('#txtOpenAiApiUrl', page).val(config.OpenAiApiUrl).change();
|
||||
$('#txtOpenAiModel', page).val(config.OpenAiModel).change();
|
||||
page.querySelector('#chkEnableTitleSubstitution').checked = config.EnableTitleSubstitution;
|
||||
$('#txtTitleRawSubstitutionTable', page).val(config.TitleRawSubstitutionTable).change();
|
||||
page.querySelector('#chkEnableActorSubstitution').checked = config.EnableActorSubstitution;
|
||||
@@ -388,6 +400,8 @@
|
||||
config.DeepLApiKey = $('#txtDeepLApiKey', form).val();
|
||||
config.DeepLXAltUrl = $('#txtDeepLAltUrl', form).val();
|
||||
config.OpenAiApiKey = $('#txtOpenAiApiKey', form).val();
|
||||
config.OpenAiApiUrl = $('#txtOpenAiApiUrl', form).val();
|
||||
config.OpenAiModel = $('#txtOpenAiModel', form).val();
|
||||
config.EnableTitleSubstitution = $('#chkEnableTitleSubstitution', form).prop('checked');
|
||||
config.TitleRawSubstitutionTable = $('#txtTitleRawSubstitutionTable', form).val();
|
||||
config.EnableActorSubstitution = $('#chkEnableActorSubstitution', form).prop('checked');
|
||||
|
||||
@@ -51,7 +51,9 @@ public static class TranslationHelper
|
||||
millisecondsDelay = 1000;
|
||||
nv.Add(new NameValueCollection
|
||||
{
|
||||
{ "openai-api-key", Configuration.OpenAiApiKey }
|
||||
{ "openai-api-key", Configuration.OpenAiApiKey },
|
||||
{ "openai-api-url", Configuration.OpenAiApiUrl },
|
||||
{ "openai-model", Configuration.OpenAiModel }
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user