Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Allow large video files to enter the upload queue (use audio-only-mode size limit unconditionally for video extensions) so the Keep audio only toggle can become visible, and add an amber inline warning when VIDEO_RETENTION is on and a queued video exceeds the regular limit but the toggle is off, telling the user to enable it
Murtaza Nasir7e2d1306f72d
diff --git a/static/js/modules/composables/upload.js b/static/js/modules/composables/upload.jsindex 6b256031..2be5e5be 100644--- a/static/js/modules/composables/upload.js+++ b/static/js/modules/composables/upload.js@@ -194,22 +194,27 @@ export function useUpload(state, utils) {);if (isAudioFile) {- // Per-file effective size limit. A video file uploaded in- // audio-only mode (toggle on, or VIDEO_RETENTION off at- // the server) uses the larger limit, since only the- // extracted audio is stored. Everything else uses the- // regular limit.+ // Per-file effective size limit. Audio files always use+ // the regular limit. Video files use the audio-only-mode+ // limit unconditionally at the precheck so the file can+ // land in the queue and the "Keep audio only" toggle+ // becomes visible. Three reasons:+ // 1. With VIDEO_RETENTION=off, the server always+ // extracts audio, so the larger limit is the right+ // ceiling anyway.+ // 2. With VIDEO_RETENTION=on and the toggle off, the+ // backend would still 413 a file over the regular+ // limit; we surface that with an inline warning+ // below rather than blocking the file at the door.+ // 3. The toggle component only renders once a video+ // is already in the queue, so blocking video files+ // at precheck creates a chicken-and-egg loop.const isVideoExt = /\.(mp4|mov|mkv|avi|webm|m4v|wmv|flv|ts|mts)$/i.test(fileObject.name);- const audioOnlyForThisFile = (- (videoRetentionEnabled && videoRetentionEnabled.value)- ? (keepAudioOnly && keepAudioOnly.value)- : true- );- const effectiveLimitMB = (isVideoExt && audioOnlyForThisFile && maxAudioOnlyVideoSizeMB)- ? maxAudioOnlyVideoSizeMB.value+ const effectiveLimitMB = isVideoExt+ ? (maxAudioOnlyVideoSizeMB && maxAudioOnlyVideoSizeMB.value) || maxFileSizeMB.value: maxFileSizeMB.value;if (fileObject.size > effectiveLimitMB * 1024 * 1024) {- const errKey = (isVideoExt && audioOnlyForThisFile)+ const errKey = isVideoExt? 'upload.videoExceedsAudioOnlyMaxSize': 'upload.fileExceedsMaxSize';setGlobalError(t(errKey, { name: fileObject.name, size: effectiveLimitMB }));diff --git a/static/locales/de.json b/static/locales/de.jsonindex e8d31d2e..2cc58bdc 100644--- a/static/locales/de.json+++ b/static/locales/de.json@@ -1537,7 +1537,8 @@"videoExceedsAudioOnlyMaxSize": "Video „{{name}}“ überschreitet das Audio-only-Limit von {{size}} MB und wurde übersprungen.","keepAudioOnlySubtitleOff": "Videostream verwerfen","keepAudioOnlySubtitleOn": "Video verworfen",- "keepAudioOnlyLargerAllowed": "Größere Uploads erlaubt"+ "keepAudioOnlyLargerAllowed": "Größere Uploads erlaubt",+ "enableKeepAudioOnlyForLargeVideo": "Über dem normalen Limit von {{regular}} MB. Aktiviere unten „Nur Audio behalten\", um dieses Video hochzuladen."},"uploadProgress": {"title": "Upload-Fortschritt"diff --git a/static/locales/en.json b/static/locales/en.jsonindex 3d1b450c..c987d2ed 100644--- a/static/locales/en.json+++ b/static/locales/en.json@@ -1546,7 +1546,8 @@"videoExceedsAudioOnlyMaxSize": "Video \"{{name}}\" exceeds the audio-only maximum of {{size}} MB and was skipped.","keepAudioOnlySubtitleOff": "Drop video stream","keepAudioOnlySubtitleOn": "Video dropped",- "keepAudioOnlyLargerAllowed": "Larger uploads allowed"+ "keepAudioOnlyLargerAllowed": "Larger uploads allowed",+ "enableKeepAudioOnlyForLargeVideo": "Over the {{regular}} MB regular limit. Enable \"Keep audio only\" below to upload this video."},"uploadProgress": {"title": "Upload Progress"diff --git a/static/locales/es.json b/static/locales/es.jsonindex 29c20100..b41d0be3 100644--- a/static/locales/es.json+++ b/static/locales/es.json@@ -1537,7 +1537,8 @@"videoExceedsAudioOnlyMaxSize": "El vídeo «{{name}}» supera el máximo de solo audio de {{size}} MB y se omitió.","keepAudioOnlySubtitleOff": "Descartar el vídeo","keepAudioOnlySubtitleOn": "Vídeo descartado",- "keepAudioOnlyLargerAllowed": "Se permiten subidas más grandes"+ "keepAudioOnlyLargerAllowed": "Se permiten subidas más grandes",+ "enableKeepAudioOnlyForLargeVideo": "Supera el límite habitual de {{regular}} MB. Activa «Conservar solo el audio» abajo para subir este vídeo."},"uploadProgress": {"title": "Progreso de Carga"diff --git a/static/locales/fr.json b/static/locales/fr.jsonindex 627d4d0d..2ad2bcbf 100644--- a/static/locales/fr.json+++ b/static/locales/fr.json@@ -1537,7 +1537,8 @@"videoExceedsAudioOnlyMaxSize": "La vidéo « {{name}} » dépasse le maximum audio uniquement de {{size}} Mo et a été ignorée.","keepAudioOnlySubtitleOff": "Supprimer le flux vidéo","keepAudioOnlySubtitleOn": "Vidéo supprimée",- "keepAudioOnlyLargerAllowed": "Envois plus volumineux autorisés"+ "keepAudioOnlyLargerAllowed": "Envois plus volumineux autorisés",+ "enableKeepAudioOnlyForLargeVideo": "Dépasse la limite normale de {{regular}} Mo. Activez « Conserver uniquement l’audio » ci-dessous pour envoyer cette vidéo."},"uploadProgress": {"title": "Progression du Téléchargement"diff --git a/static/locales/pt-BR.json b/static/locales/pt-BR.jsonindex 2d1ce46c..97eaa86d 100644--- a/static/locales/pt-BR.json+++ b/static/locales/pt-BR.json@@ -1537,7 +1537,8 @@"videoExceedsAudioOnlyMaxSize": "O vídeo “{{name}}” excede o máximo apenas-áudio de {{size}} MB e foi ignorado.","keepAudioOnlySubtitleOff": "Descartar o vídeo","keepAudioOnlySubtitleOn": "Vídeo descartado",- "keepAudioOnlyLargerAllowed": "Envios maiores permitidos"+ "keepAudioOnlyLargerAllowed": "Envios maiores permitidos",+ "enableKeepAudioOnlyForLargeVideo": "Excede o limite habitual de {{regular}} MB. Ative “Manter apenas o áudio” abaixo para enviar este vídeo."},"uploadProgress": {"title": "Progresso do Envio"diff --git a/static/locales/ru.json b/static/locales/ru.jsonindex 4f9c36ef..9ad36b23 100644--- a/static/locales/ru.json+++ b/static/locales/ru.json@@ -1537,7 +1537,8 @@"videoExceedsAudioOnlyMaxSize": "Видео «{{name}}» превышает лимит только для аудио в {{size}} МБ и было пропущено.","keepAudioOnlySubtitleOff": "Отбросить видео","keepAudioOnlySubtitleOn": "Видео отброшено",- "keepAudioOnlyLargerAllowed": "Допустимы более крупные загрузки"+ "keepAudioOnlyLargerAllowed": "Допустимы более крупные загрузки",+ "enableKeepAudioOnlyForLargeVideo": "Превышает обычный лимит в {{regular}} МБ. Включите «Сохранить только аудио» ниже, чтобы загрузить это видео."},"uploadProgress": {"title": "Прогресс загрузки"diff --git a/static/locales/zh.json b/static/locales/zh.jsonindex 75c4dd24..fa477ecc 100644--- a/static/locales/zh.json+++ b/static/locales/zh.json@@ -1537,7 +1537,8 @@"videoExceedsAudioOnlyMaxSize": "视频 “{{name}}” 超出仅音频上限 {{size}} MB,已跳过。","keepAudioOnlySubtitleOff": "丢弃视频流","keepAudioOnlySubtitleOn": "已丢弃视频",- "keepAudioOnlyLargerAllowed": "允许更大文件"+ "keepAudioOnlyLargerAllowed": "允许更大文件",+ "enableKeepAudioOnlyForLargeVideo": "超过 {{regular}} MB 的常规限制。请在下方启用“仅保留音频”后再上传此视频。"},"uploadProgress": {"title": "上传进度"diff --git a/templates/components/upload-view.html b/templates/components/upload-view.htmlindex 9138aa8f..3930203f 100644--- a/templates/components/upload-view.html+++ b/templates/components/upload-view.html@@ -51,6 +51,20 @@<i class="fas fa-volume-up"></i><span>${ t('upload.videoAudioOnlyAuto') }</span></div>+ <!-- Inline WARNING when the file is a video over+ the regular size limit and the user has+ VIDEO_RETENTION on without "Keep audio only"+ toggled. Without the toggle the server will+ reject the upload; tell the user up front+ rather than after they click upload. -->+ <div v-if="videoRetentionEnabled+ && !keepAudioOnly+ && /\.(mp4|mov|mkv|avi|webm|m4v|wmv|flv|ts|mts)$/i.test(item.file.name)+ && item.file.size > maxFileSizeMB * 1024 * 1024"+ class="flex items-center gap-1 pl-5 text-[10px] text-amber-700 dark:text-amber-400">+ <i class="fas fa-exclamation-triangle"></i>+ <span>${ t('upload.enableKeepAudioOnlyForLargeVideo', { regular: maxFileSizeMB }) }</span>+ </div></div></div>