From 516ee7c5599f2c90a636fd9301806bef67830046 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 19 May 2020 21:06:16 +0200 Subject: compiler: add audio and video extensions --- compiler/src/Processors.hs | 24 ++++++++++++++++++++++-- compiler/src/Resource.hs | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'compiler/src') diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs index 2988f83..0efbf6d 100644 --- a/compiler/src/Processors.hs +++ b/compiler/src/Processors.hs @@ -47,8 +47,13 @@ data ProcessingException = ProcessingException FilePath String deriving Show instance Exception ProcessingException --- TODO: handle video, music, markdown... -data Format = PictureFormat | PlainTextFormat | PortableDocumentFormat | Unknown +data Format = + PictureFormat + | PlainTextFormat + | PortableDocumentFormat + | VideoFormat + | AudioFormat + | Unknown formatFromPath :: Path -> Format formatFromPath = @@ -69,6 +74,19 @@ formatFromPath = ".txt" -> PlainTextFormat ".md" -> PlainTextFormat -- TODO: handle markdown separately ".pdf" -> PortableDocumentFormat + ".wav" -> AudioFormat + ".oga" -> AudioFormat + ".ogg" -> AudioFormat + ".spx" -> AudioFormat + ".opus" -> AudioFormat + ".flac" -> AudioFormat + ".m4a" -> AudioFormat + ".mp3" -> AudioFormat + ".ogv" -> VideoFormat + ".ogx" -> VideoFormat + ".webm" -> VideoFormat + ".mkv" -> VideoFormat + ".mp4" -> VideoFormat _ -> Unknown @@ -175,6 +193,8 @@ itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes = processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps) processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText) processorFor PortableDocumentFormat _ = (copyFileProcessor, const $ return . PDF) + processorFor VideoFormat _ = (copyFileProcessor, const $ return . Video) + processorFor AudioFormat _ = (copyFileProcessor, const $ return . Audio) -- TODO: handle video reencoding and others? processorFor Unknown _ = (copyFileProcessor, const $ return . Other) diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs index 129a817..c08677d 100644 --- a/compiler/src/Resource.hs +++ b/compiler/src/Resource.hs @@ -77,6 +77,8 @@ data GalleryItemProps = , resolution :: Resolution } | PlainText { resource :: Resource } | PDF { resource :: Resource } + | Video { resource :: Resource } + | Audio { resource :: Resource } | Other { resource :: Resource } deriving (Generic, Show) -- cgit v1.2.3