Skip to content

Commit 3ab8bfb

Browse files
committed
added the option to ignore subtitles with captions, added rate limit configuration options
1 parent 89fb4fc commit 3ab8bfb

File tree

17 files changed

+1568
-156
lines changed

17 files changed

+1568
-156
lines changed

Lingarr.Client/src/components/features/settings/ServicesSettings.vue

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,14 @@
1515
v-if="serviceConfigComponent"
1616
@save="saveNotification?.show()" />
1717
</div>
18-
<div
19-
v-if="
20-
[
21-
SERVICE_TYPE.ANTHROPIC,
22-
SERVICE_TYPE.GEMINI,
23-
SERVICE_TYPE.LOCALAI,
24-
SERVICE_TYPE.OPENAI
25-
].includes(serviceType as 'openai' | 'anthropic' | 'localai' | 'gemini')
26-
"
27-
class="flex flex-col space-y-4">
28-
<div class="flex flex-col space-x-2">
29-
<span class="font-semibold">
30-
{{ translate('settings.subtitle.useBatchTranslation') }}
31-
</span>
32-
{{ translate('settings.subtitle.useBatchTranslationDescription') }}
33-
</div>
34-
<ToggleButton v-model="useBatchTranslation">
35-
<span class="text-primary-content text-sm font-medium">
36-
{{
37-
useBatchTranslation == 'true'
38-
? translate('common.enabled')
39-
: translate('common.disabled')
40-
}}
41-
</span>
42-
</ToggleButton>
43-
<InputComponent
44-
v-if="useBatchTranslation == 'true'"
45-
v-model="maxBatchSize"
46-
validation-type="number"
47-
:label="translate('settings.subtitle.maxBatchSize')"
48-
@update:validation="(val) => (isValid.maxBatchSize = val)" />
49-
</div>
5018

5119
<SourceAndTarget @save="saveNotification?.show()" />
5220
</template>
5321
</CardComponent>
5422
</template>
5523

5624
<script setup lang="ts">
57-
import { computed, ref, reactive } from 'vue'
25+
import { computed, ref } from 'vue'
5826
import { useSettingStore } from '@/store/setting'
5927
import { SETTINGS, SERVICE_TYPE } from '@/ts'
6028
import CardComponent from '@/components/common/CardComponent.vue'
@@ -69,14 +37,9 @@ import LocalAiConfig from '@/components/features/settings/services/LocalAiConfig
6937
import GeminiConfig from '@/components/features/settings/services/GeminiConfig.vue'
7038
import DeepSeekConfig from '@/components/features/settings/services/DeepSeekConfig.vue'
7139
import SourceAndTarget from '@/components/features/settings/SourceAndTarget.vue'
72-
import ToggleButton from '@/components/common/ToggleButton.vue'
73-
import InputComponent from '@/components/common/InputComponent.vue'
7440
7541
const saveNotification = ref<InstanceType<typeof SaveNotification> | null>(null)
7642
const settingsStore = useSettingStore()
77-
const isValid = reactive({
78-
maxBatchSize: true
79-
})
8043
8144
const serviceType = computed({
8245
get: () => settingsStore.getSetting(SETTINGS.SERVICE_TYPE) as string,
@@ -125,20 +88,4 @@ const serviceConfigComponent = computed(() => {
12588
return null
12689
}
12790
})
128-
129-
const useBatchTranslation = computed({
130-
get: (): string => settingsStore.getSetting(SETTINGS.USE_BATCH_TRANSLATION) as string,
131-
set: (newValue: string): void => {
132-
settingsStore.updateSetting(SETTINGS.USE_BATCH_TRANSLATION, newValue, true)
133-
saveNotification.value?.show()
134-
}
135-
})
136-
137-
const maxBatchSize = computed({
138-
get: (): string => settingsStore.getSetting(SETTINGS.MAX_BATCH_SIZE) as string,
139-
set: (newValue: string): void => {
140-
settingsStore.updateSetting(SETTINGS.MAX_BATCH_SIZE, newValue, true)
141-
saveNotification.value?.show()
142-
}
143-
})
14491
</script>

Lingarr.Client/src/components/features/settings/SubtitleSettings.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66
<template #content>
77
<div class="flex flex-col space-y-4">
88
<SaveNotification ref="saveNotification" />
9+
<div class="flex flex-col space-x-2">
10+
<span class="font-semibold">
11+
{{ translate('settings.subtitle.ignoreCaptions') }}
12+
</span>
13+
{{ translate('settings.subtitle.ignoreCaptionsDescription') }}
14+
</div>
15+
<ToggleButton v-model="ignoreCaptions">
16+
<span class="text-primary-content text-sm font-medium">
17+
{{
18+
ignoreCaptions == 'true'
19+
? translate('common.enabled')
20+
: translate('common.disabled')
21+
}}
22+
</span>
23+
</ToggleButton>
24+
925
<div class="flex flex-col space-x-2">
1026
<span class="font-semibold">
1127
{{ translate('settings.subtitle.fixOverlappingSubtitles') }}
@@ -82,6 +98,14 @@ const isValid = reactive({
8298
subtitleTag: true
8399
})
84100
101+
const ignoreCaptions = computed({
102+
get: (): string => settingsStore.getSetting(SETTINGS.IGNORE_CAPTIONS) as string,
103+
set: (newValue: string): void => {
104+
settingsStore.updateSetting(SETTINGS.IGNORE_CAPTIONS, newValue, true)
105+
saveNotification.value?.show()
106+
}
107+
})
108+
85109
const fixOverlappingSubtitles = computed({
86110
get: (): string => settingsStore.getSetting(SETTINGS.FIX_OVERLAPPING_SUBTITLES) as string,
87111
set: (newValue: string): void => {
@@ -109,7 +133,7 @@ const useSubtitleTagging = computed({
109133
const subtitleTag = computed({
110134
get: (): string => settingsStore.getSetting(SETTINGS.SUBTITLE_TAG) as string,
111135
set: (newValue: string): void => {
112-
settingsStore.updateSetting(SETTINGS.SUBTITLE_TAG, newValue, true)
136+
settingsStore.updateSetting(SETTINGS.SUBTITLE_TAG, newValue, isValid.subtitleTag)
113137
saveNotification.value?.show()
114138
}
115139
})
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<template>
2+
<CardComponent :title="translate('settings.translation.title')">
3+
<template #description>
4+
{{ translate('settings.translation.description') }}
5+
</template>
6+
<template #content>
7+
<SaveNotification ref="saveNotification" />
8+
9+
<div class="flex flex-col space-x-2">
10+
<span class="font-semibold">
11+
{{ translate('settings.translation.useBatchTranslation') }}
12+
</span>
13+
{{ translate('settings.translation.useBatchTranslationDescription') }}
14+
</div>
15+
<ToggleButton v-model="useBatchTranslation">
16+
<span class="text-primary-content text-sm font-medium">
17+
{{
18+
useBatchTranslation == 'true'
19+
? translate('common.enabled')
20+
: translate('common.disabled')
21+
}}
22+
</span>
23+
</ToggleButton>
24+
<InputComponent
25+
v-if="useBatchTranslation == 'true'"
26+
v-model="maxBatchSize"
27+
validation-type="number"
28+
@update:validation="(val) => (isValid.maxBatchSize = val)" />
29+
30+
<div class="flex flex-col space-x-2">
31+
<span class="font-semibold">
32+
{{ translate('settings.translation.maxRetries') }}
33+
</span>
34+
{{ translate('settings.translation.maxRetriesDescription') }}
35+
</div>
36+
<InputComponent
37+
v-model="maxRetries"
38+
validation-type="number"
39+
@update:validation="(val) => (isValid.maxRetries = val)" />
40+
41+
<div class="flex flex-col space-x-2">
42+
<span class="font-semibold">
43+
{{ translate('settings.translation.retryDelay') }}
44+
</span>
45+
{{ translate('settings.translation.retryDelayDescription') }}
46+
</div>
47+
<InputComponent
48+
v-model="retryDelay"
49+
validation-type="number"
50+
@update:validation="(val) => (isValid.retryDelay = val)" />
51+
52+
<div class="flex flex-col space-x-2">
53+
<span class="font-semibold">
54+
{{ translate('settings.translation.retryDelayMultiplier') }}
55+
</span>
56+
{{ translate('settings.translation.retryDelayMultiplierDescription') }}
57+
</div>
58+
<InputComponent
59+
v-model="retryDelayMultiplier"
60+
validation-type="number"
61+
@update:validation="(val) => (isValid.retryDelayMultiplier = val)" />
62+
</template>
63+
</CardComponent>
64+
</template>
65+
66+
<script setup lang="ts">
67+
import { computed, ref, reactive } from 'vue'
68+
import { useSettingStore } from '@/store/setting'
69+
import { SETTINGS } from '@/ts'
70+
import CardComponent from '@/components/common/CardComponent.vue'
71+
import SaveNotification from '@/components/common/SaveNotification.vue'
72+
import InputComponent from '@/components/common/InputComponent.vue'
73+
import ToggleButton from '@/components/common/ToggleButton.vue'
74+
75+
const saveNotification = ref<InstanceType<typeof SaveNotification> | null>(null)
76+
const settingsStore = useSettingStore()
77+
const isValid = reactive({
78+
maxBatchSize: true,
79+
maxRetries: true,
80+
retryDelay: true,
81+
retryDelayMultiplier: true
82+
})
83+
84+
const useBatchTranslation = computed({
85+
get: (): string => settingsStore.getSetting(SETTINGS.USE_BATCH_TRANSLATION) as string,
86+
set: (newValue: string): void => {
87+
settingsStore.updateSetting(SETTINGS.USE_BATCH_TRANSLATION, newValue, true)
88+
saveNotification.value?.show()
89+
}
90+
})
91+
92+
const maxBatchSize = computed({
93+
get: (): string => settingsStore.getSetting(SETTINGS.MAX_BATCH_SIZE) as string,
94+
set: (newValue: string): void => {
95+
settingsStore.updateSetting(SETTINGS.MAX_BATCH_SIZE, newValue, isValid.maxBatchSize)
96+
saveNotification.value?.show()
97+
}
98+
})
99+
100+
const maxRetries = computed({
101+
get: (): string => settingsStore.getSetting(SETTINGS.MAX_RETRIES) as string,
102+
set: (newValue: string): void => {
103+
settingsStore.updateSetting(SETTINGS.MAX_RETRIES, newValue, isValid.maxRetries)
104+
saveNotification.value?.show()
105+
}
106+
})
107+
108+
const retryDelay = computed({
109+
get: (): string => settingsStore.getSetting(SETTINGS.RETRY_DELAY) as string,
110+
set: (newValue: string): void => {
111+
settingsStore.updateSetting(SETTINGS.RETRY_DELAY, newValue, isValid.retryDelay)
112+
saveNotification.value?.show()
113+
}
114+
})
115+
116+
const retryDelayMultiplier = computed({
117+
get: (): string => settingsStore.getSetting(SETTINGS.RETRY_DELAY_MULTIPLIER) as string,
118+
set: (newValue: string): void => {
119+
settingsStore.updateSetting(
120+
SETTINGS.RETRY_DELAY_MULTIPLIER,
121+
newValue,
122+
isValid.retryDelayMultiplier
123+
)
124+
saveNotification.value?.show()
125+
}
126+
})
127+
</script>

Lingarr.Client/src/pages/settings/ServicesPage.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
serviceType as 'openai' | 'anthropic' | 'localai' | 'gemini' | 'deepseek'
1515
)
1616
" />
17+
<TranslationSettings
18+
v-if="
19+
[
20+
SERVICE_TYPE.ANTHROPIC,
21+
SERVICE_TYPE.DEEPSEEK,
22+
SERVICE_TYPE.GEMINI,
23+
SERVICE_TYPE.LOCALAI,
24+
SERVICE_TYPE.OPENAI
25+
].includes(
26+
serviceType as 'openai' | 'anthropic' | 'localai' | 'gemini' | 'deepseek'
27+
)
28+
" />
1729
<CustomAiParameters
1830
v-if="
1931
[
@@ -36,6 +48,7 @@ import { useSettingStore } from '@/store/setting'
3648
import ServicesSettings from '@/components/features/settings/ServicesSettings.vue'
3749
import CustomAiParameters from '@/components/features/settings/CustomAiParameters.vue'
3850
import PromptSettings from '@/components/features/settings/PromptSettings.vue'
51+
import TranslationSettings from '@/components/features/settings/TranslationSettings.vue'
3952
4053
const settingsStore = useSettingStore()
4154

Lingarr.Client/src/ts/setting.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ export const SETTINGS = {
5252
USE_BATCH_TRANSLATION: 'use_batch_translation',
5353
MAX_BATCH_SIZE: 'max_batch_size',
5454
USE_SUBTITLE_TAGGING: 'use_subtitle_tagging',
55-
SUBTITLE_TAG: 'subtitle_tag'
55+
SUBTITLE_TAG: 'subtitle_tag',
56+
IGNORE_CAPTIONS: 'ignore_captions',
57+
MAX_RETRIES: 'max_retries',
58+
RETRY_DELAY: 'retry_delay',
59+
RETRY_DELAY_MULTIPLIER: 'retry_delay_multiplier'
5660
} as const
5761

5862
export interface ISettings {
@@ -107,6 +111,10 @@ export interface ISettings {
107111
max_batch_size: string
108112
use_subtitle_tagging: string
109113
subtitle_tag: string
114+
ignore_captions: string
115+
max_retries: string
116+
retry_delay: string
117+
retry_delay_multiplier: string
110118
}
111119

112120
export interface ICustomAiParams {

Lingarr.Core/Configuration/SettingKeys.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public static class LibreTranslate
7373
public const string MaxBatchSize = "max_batch_size";
7474
public const string UseSubtitleTagging = "use_subtitle_tagging";
7575
public const string SubtitleTag = "subtitle_tag";
76+
public const string IgnoreCaptions = "ignore_captions";
77+
public const string RequestTimeout = "request_timeout";
78+
public const string MaxRetries = "max_retries";
79+
public const string RetryDelay = "retry_delay";
80+
public const string RetryDelayMultiplier = "retry_delay_multiplier";
7681
}
7782

7883
public static class Automation

0 commit comments

Comments
 (0)