From: Greg Burri Date: Wed, 15 Apr 2009 20:53:17 +0000 (+0200) Subject: ADD beginning of the XML parsing X-Git-Url: http://git.euphorik.ch/?p=pompage.git;a=commitdiff_plain;h=6d8562993900c1db38b837a4242dbc955e959e22 ADD beginning of the XML parsing --- diff --git a/src/Pompage.hs b/src/Pompage.hs index 6cf4349..e3066f2 100644 --- a/src/Pompage.hs +++ b/src/Pompage.hs @@ -13,21 +13,21 @@ import Control.Monad (foldM) 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 + movieFiles :: [FilePath] + , movieId :: Int + , movieTitle :: String + , movieYear :: Maybe Int + , movieDirectors :: [String] + , movieActors :: [String] + , movieCountries :: [String] + , movieLength :: Maybe Int + , movieUserRating :: Maybe Int + , moviePressRating :: Maybe Int + , movieGenres :: [String] + , movieSynopsis :: String + , movieBudget :: Int + , movieBudgetUnit :: String + , movieUrl :: String } deriving (Show) data Arg = XML | MovieDir deriving (Show, Eq) @@ -46,6 +46,7 @@ main = do print movies print paths +coversDir = "../img/covers" movieExtenstions = ["avi", "mkv", "rmvb", "ogm", "divx"] usage = "Usage : %s -d -x \n" @@ -98,12 +99,26 @@ filePaths predicat baseDir = do readXMLFile :: FilePath -> IO Movies -readXMLFile file = undefined +readXMLFile file = do + content <- readFile file + let Just root = parseXMLDoc content + return $ + foldl (\acc elem -> + case elementXMLToMovie elem of + Nothing -> acc + Just movie -> movie : acc) + [] + (elChildren root) + +elementXMLToMovie :: Element -> Maybe Movie +elementXMLToMovie elem = undefined {- - file <- readFile "../xml/test.xml" - --print $ parseXMLDoc file +findAttr (QName "id" Nothing Nothing) elem of + Nothing -> acc + Just id -> -} + writeXMLFile :: Movies -> FilePath -> IO () writeXMLFile movies file = undefined diff --git a/start.sh b/start.sh index 00a5415..a501312 100755 --- a/start.sh +++ b/start.sh @@ -4,4 +4,4 @@ # -d -x # cd src -runhaskell Pompage.hs -d /home/gburri/mininux/fat/Films -x ../xml/divx.xml \ No newline at end of file +runhaskell Pompage.hs -d /home/gburri/mininux/fat/Films -x ../xml/test.xml \ No newline at end of file