ADD Haskell version (not finished yet)
[pompage.git] / src / Pompage.hs
1 import System.IO (readFile, FilePath(..))
2 import System.Environment (getArgs)
3 import Data.List
4 import Text.XML.Light
5
6 type Movies = [Movie]
7
8 data Movie = Movie {
9 files :: [FilePath]
10 , id :: Int
11 , title :: String
12 , year :: Maybe Int
13 , directors :: [String]
14 , actors :: [String]
15 , countries :: [String]
16 , length :: Maybe Int
17 , userRating :: Maybe Int
18 , pressRating :: Maybe Int
19 , genre :: [String]
20 , synopsis :: String
21 , budget :: Int
22 , budgetUnit :: String
23 , url :: String
24 } deriving (Show)
25
26 data Args = Args {
27 xml :: String
28 , moviesDir :: FilePath
29 } deriving (Show)
30
31 test = do
32 args <- getArgs
33 case readArgs args of
34 Left mess -> print mess
35 Right args -> do
36 paths <- moviePaths $ moviesDir args
37 file <- readFile "../xml/test.xml"
38 print $ parseXMLDoc file
39
40 movieExtenstions = ["avi", "mkv", "rmvb", "ogm", "divx"]
41
42 readArgs :: [String] -> Either String Args
43 readArgs plop = undefined
44 {--readArgs (name:value:rest) = case name of
45 "-x" -> { xml = value }
46 "-d" -> { moviesDir = value }--}
47
48 moviePaths :: FilePath -> IO [FilePath]
49 moviePaths dir = undefined
50
51 readXMLFile :: FilePath -> IO Movies
52 readXMLFile file = undefined
53
54
55
56 writeXMLFile :: Movies -> FilePath -> IO ()
57 writeXMLFile movies file = undefined
58
59 filesPath :: FilePath -> IO [FilePath]
60 filesPath basePath = undefined
61
62 movieName :: FilePath -> String
63 movieName = undefined
64
65 -- Int is the module id.
66 data SearchResult = OK (Int, Movie)
67 | Many [(Int, String)] -- String is the name of the movie.
68 | NotFound
69
70 data Module = Module {
71 search :: String -> IO SearchResult
72 -- Int is the module id. FilePath is a path to the image like "../img/4353"
73 , downloadImage :: Int -> FilePath
74 }
75
76 {-
77 Gets a movie by asking the given module to find a movie.
78 A movie is seeked by its the filename.
79 If there is many possibilities then it will ask the user.
80 -}
81 searchAMovie :: String -> Module -> IO SearchResult
82 searchAMovie filename mod = undefined
83
84