module FFProbe.Data.Format (Format (..)) where
import Data.Aeson.Types
import FFProbe.Data.Tags
import FFProbe.Data.Tags.Internal
import FFProbe.Internal (parseReadable)
data Format = Format
{ Format -> String
filename :: String,
Format -> Integer
streamsCount :: Integer,
Format -> Integer
programsCount :: Integer,
Format -> Integer
streamGroupsCount :: Integer,
Format -> String
formatName :: String,
Format -> String
formatLongName :: String,
Format -> Float
startTime :: Float,
Format -> Float
duration :: Float,
Format -> Integer
size :: Integer,
Format -> Integer
bitrate :: Integer,
Format -> Integer
probeScore :: Integer,
Format -> TagList
tags :: TagList,
Format -> Object
raw :: Object
}
instance HasTags Format where
getTags :: Format -> TagList
getTags = Format -> TagList
tags
instance FromJSON Format where
parseJSON :: Value -> Parser Format
parseJSON = String -> (Object -> Parser Format) -> Value -> Parser Format
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Format" ((Object -> Parser Format) -> Value -> Parser Format)
-> (Object -> Parser Format) -> Value -> Parser Format
forall a b. (a -> b) -> a -> b
$ \Object
v -> do
let raw :: Object
raw = Object
v
String
filename <- Object
v Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"filename"
Integer
streamsCount <- Object
v Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"nb_streams"
Integer
programsCount <- Object
v Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"nb_programs"
Integer
streamGroupsCount <- Object
v Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"nb_stream_groups"
String
formatName <- Object
v Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"format_name"
String
formatLongName <- Object
v Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"format_long_name"
Float
startTime <- String -> Parser Float
forall a. Read a => String -> Parser a
parseReadable (String -> Parser Float) -> Parser String -> Parser Float
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"start_time"
Float
duration <- String -> Parser Float
forall a. Read a => String -> Parser a
parseReadable (String -> Parser Float) -> Parser String -> Parser Float
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"duration"
Integer
size <- String -> Parser Integer
forall a. Read a => String -> Parser a
parseReadable (String -> Parser Integer) -> Parser String -> Parser Integer
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"size"
Integer
bitrate <- String -> Parser Integer
forall a. Read a => String -> Parser a
parseReadable (String -> Parser Integer) -> Parser String -> Parser Integer
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"bit_rate"
Integer
probeScore <- Object
v Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"probe_score"
TagList
tags <- Value -> Parser TagList
parseTags (Value -> Parser TagList) -> Parser Value -> Parser TagList
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"tags"
Format -> Parser Format
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Format {Float
Integer
String
TagList
Object
filename :: String
streamsCount :: Integer
programsCount :: Integer
streamGroupsCount :: Integer
formatName :: String
formatLongName :: String
startTime :: Float
duration :: Float
size :: Integer
bitrate :: Integer
probeScore :: Integer
tags :: TagList
raw :: Object
raw :: Object
filename :: String
streamsCount :: Integer
programsCount :: Integer
streamGroupsCount :: Integer
formatName :: String
formatLongName :: String
startTime :: Float
duration :: Float
size :: Integer
bitrate :: Integer
probeScore :: Integer
tags :: TagList
..}