module Vimeta.UI.Common.Movie
( tagMovie,
)
where
import qualified Data.Text as Text
import Network.API.TheMovieDB
import Vimeta.Core
tagMovie :: (MonadIO m) => FilePath -> Movie -> Vimeta m ()
tagMovie filename movie = do
context <- ask
let format = configFormatMovie (ctxConfig context)
tmdbCfg = ctxTMDBCfg context
withArtwork (moviePosterURLs tmdbCfg movie) $ \artwork ->
case fromFormatString (formatMap artwork) "config.cmd_movie" format of
Left e -> throwError e
Right cmd -> tagFile cmd
where
formatMap :: Maybe FilePath -> FormatTable
formatMap artwork =
fromList
[ ('Y', formatFullDate $ movieReleaseDate movie),
('a', toText <$> artwork),
('d', Just (Text.take 255 $ movieOverview movie)),
('g', genreName <$> listToMaybe (movieGenres movie)),
('t', Just $ movieTitle movie),
('y', formatYear $ movieReleaseDate movie),
('f', Just $ toText filename)
]