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)
print movies
print paths
+coversDir = "../img/covers"
movieExtenstions = ["avi", "mkv", "rmvb", "ogm", "divx"]
usage = "Usage : %s -d <Movies dir> -x <XML file>\n"
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