From: gburri Date: Mon, 6 Apr 2009 19:15:35 +0000 (+0000) Subject: ADD Haskell version (not finished yet) X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=96bf4ef892a3bf6d493a139c4ea49992f51a1ddf;p=pompage.git ADD Haskell version (not finished yet) git-svn-id: svn://euphorik.ch/pompage@79 02bbb61a-6d21-0410-aba0-cb053bdfd66a --- diff --git a/src/Pompage.hs b/src/Pompage.hs new file mode 100644 index 0000000..b986e99 --- /dev/null +++ b/src/Pompage.hs @@ -0,0 +1,84 @@ +import System.IO (readFile, FilePath(..)) +import System.Environment (getArgs) +import Data.List +import Text.XML.Light + +type Movies = [Movie] + +data Movie = Movie { + files :: [FilePath] + , id :: Int + , title :: String + , year :: Maybe Int + , directors :: [String] + , actors :: [String] + , countries :: [String] + , length :: Maybe Int + , userRating :: Maybe Int + , pressRating :: Maybe Int + , genre :: [String] + , synopsis :: String + , budget :: Int + , budgetUnit :: String + , url :: String +} deriving (Show) + +data Args = Args { + xml :: String + , moviesDir :: FilePath +} deriving (Show) + +test = do + args <- getArgs + case readArgs args of + Left mess -> print mess + Right args -> do + paths <- moviePaths $ moviesDir args + file <- readFile "../xml/test.xml" + print $ parseXMLDoc file + +movieExtenstions = ["avi", "mkv", "rmvb", "ogm", "divx"] + +readArgs :: [String] -> Either String Args +readArgs plop = undefined +{--readArgs (name:value:rest) = case name of + "-x" -> { xml = value } + "-d" -> { moviesDir = value }--} + +moviePaths :: FilePath -> IO [FilePath] +moviePaths dir = undefined + +readXMLFile :: FilePath -> IO Movies +readXMLFile file = undefined + + + +writeXMLFile :: Movies -> FilePath -> IO () +writeXMLFile movies file = undefined + +filesPath :: FilePath -> IO [FilePath] +filesPath basePath = undefined + +movieName :: FilePath -> String +movieName = undefined + +-- Int is the module id. +data SearchResult = OK (Int, Movie) + | Many [(Int, String)] -- String is the name of the movie. + | NotFound + +data Module = Module { + search :: String -> IO SearchResult + -- Int is the module id. FilePath is a path to the image like "../img/4353" + , downloadImage :: Int -> FilePath +} + +{- + Gets a movie by asking the given module to find a movie. + A movie is seeked by its the filename. + If there is many possibilities then it will ask the user. +-} +searchAMovie :: String -> Module -> IO SearchResult +searchAMovie filename mod = undefined + +