feat: extended preview for PDF, audio, video via external utilities
Add rich preview support for three new file categories by leveraging external CLI tools with graceful fallback when tools are missing. - PDF: text extraction via pdftotext, page count via pdfinfo - Audio: metadata via ffprobe (duration, bitrate, codec, sample rate, channels) - Video: metadata via ffprobe (duration, bitrate, video/audio codec, resolution) - New PreviewKind constants: PDF, Audio, Video - New Metadata fields for extended preview data - New extension maps and Category() entries for pdf/audio/video - Icons: PDF (), audio (), video () in preview header Closes #5
This commit is contained in:
parent
813c40a41e
commit
a483267bd9
5 changed files with 833 additions and 8 deletions
|
|
@ -56,6 +56,17 @@ var (
|
|||
"png": {}, "jpg": {}, "jpeg": {}, "gif": {}, "webp": {}, "bmp": {}, "svg": {}, "ico": {},
|
||||
"avif": {}, "heic": {}, "heif": {}, "tiff": {}, "tif": {},
|
||||
}
|
||||
pdfExtensions = map[string]struct{}{
|
||||
"pdf": {},
|
||||
}
|
||||
audioExtensions = map[string]struct{}{
|
||||
"mp3": {}, "flac": {}, "ogg": {}, "opus": {}, "wav": {},
|
||||
"aac": {}, "m4a": {}, "wma": {}, "dsf": {}, "ape": {},
|
||||
}
|
||||
videoExtensions = map[string]struct{}{
|
||||
"mp4": {}, "mkv": {}, "mov": {}, "avi": {}, "webm": {},
|
||||
"m4v": {}, "wmv": {}, "flv": {}, "ts": {}, "mts": {},
|
||||
}
|
||||
archiveExtensions = map[string]struct{}{
|
||||
"zip": {}, "tar": {}, "gz": {}, "tgz": {}, "xz": {}, "bz2": {}, "7z": {}, "rar": {},
|
||||
"zst": {}, "lz": {}, "lz4": {}, "lzma": {},
|
||||
|
|
@ -113,6 +124,12 @@ func (e Entry) Category() string {
|
|||
return "image"
|
||||
case hasExt(textExtensions, e.Extension):
|
||||
return "text"
|
||||
case hasExt(pdfExtensions, e.Extension):
|
||||
return "pdf"
|
||||
case hasExt(audioExtensions, e.Extension):
|
||||
return "audio"
|
||||
case hasExt(videoExtensions, e.Extension):
|
||||
return "video"
|
||||
case hasExt(archiveExtensions, e.Extension):
|
||||
return "archive"
|
||||
case hasExt(textFilenames, strings.ToLower(e.Name)):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue