Skip to content

Commit

Permalink
Add support to recognize srt and vtt as subtitles formats on the file…
Browse files Browse the repository at this point in the history
… table
  • Loading branch information
mfcar committed May 4, 2024
1 parent 1a9aaf1 commit 2f515cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions client/plugins/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -82,4 +83,4 @@ export default ({ app }, inject) => {
inject('constants', Constants)
inject('keynames', KeyNames)
inject('hotkeys', Hotkeys)
}
}
3 changes: 2 additions & 1 deletion server/objects/files/LibraryFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down Expand Up @@ -75,4 +76,4 @@ class LibraryFile {
this.updatedAt = Date.now()
}
}
module.exports = LibraryFile
module.exports = LibraryFile
3 changes: 2 additions & 1 deletion server/utils/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2f515cc

Please sign in to comment.