From 2f515cc2075599c6b2589948b332ceadb2c50400 Mon Sep 17 00:00:00 2001 From: mfcar Date: Sat, 4 May 2024 20:50:18 +0100 Subject: [PATCH] Add support to recognize srt and vtt as subtitles formats on the file table --- client/plugins/constants.js | 5 +++-- server/objects/files/LibraryFile.js | 3 ++- server/utils/globals.js | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/plugins/constants.js b/client/plugins/constants.js index f001f6ced0..8b95887f1b 100644 --- a/client/plugins/constants.js +++ b/client/plugins/constants.js @@ -4,7 +4,8 @@ const SupportedFileTypes = { ebook: ['epub', 'pdf', 'mobi', 'azw3', 'cbr', 'cbz'], info: ['nfo'], text: ['txt'], - metadata: ['opf', 'abs', 'xml', 'json'] + metadata: ['opf', 'abs', 'xml', 'json'], + subtitle: ['srt', 'vtt'] } const DownloadStatus = { @@ -82,4 +83,4 @@ export default ({ app }, inject) => { inject('constants', Constants) inject('keynames', KeyNames) inject('hotkeys', Hotkeys) -} \ No newline at end of file +} diff --git a/server/objects/files/LibraryFile.js b/server/objects/files/LibraryFile.js index 395e11cc1b..e024fb4e4d 100644 --- a/server/objects/files/LibraryFile.js +++ b/server/objects/files/LibraryFile.js @@ -46,6 +46,7 @@ class LibraryFile { if (globals.SupportedVideoTypes.includes(this.metadata.format)) return 'video' if (globals.TextFileTypes.includes(this.metadata.format)) return 'text' if (globals.MetadataFileTypes.includes(this.metadata.format)) return 'metadata' + if (globals.SubtitleFileTypes.includes(this.metadata.format)) return 'subtitle' return 'unknown' } @@ -75,4 +76,4 @@ class LibraryFile { this.updatedAt = Date.now() } } -module.exports = LibraryFile \ No newline at end of file +module.exports = LibraryFile diff --git a/server/utils/globals.js b/server/utils/globals.js index b24fc76d04..04c9bbe612 100644 --- a/server/utils/globals.js +++ b/server/utils/globals.js @@ -4,7 +4,8 @@ const globals = { SupportedEbookTypes: ['epub', 'pdf', 'mobi', 'azw3', 'cbr', 'cbz'], SupportedVideoTypes: ['mp4'], TextFileTypes: ['txt', 'nfo'], - MetadataFileTypes: ['opf', 'abs', 'xml', 'json'] + MetadataFileTypes: ['opf', 'abs', 'xml', 'json'], + SubtitleFileTypes: ['srt', 'vtt'] } module.exports = globals