diff options
author | Joris | 2018-06-18 23:15:12 +0200 |
---|---|---|
committer | Joris | 2018-06-18 23:15:12 +0200 |
commit | 318292532a877c308403c45795d229fad659d900 (patch) | |
tree | 16e4695cc316a28bff4f0a9ae42e779ecce82a31 /src/executable/haskell/Service | |
parent | 96bbdbbe9b22b3c3e96998cc18a3b68c9db66da9 (diff) |
Add seLoger parser
Diffstat (limited to 'src/executable/haskell/Service')
-rw-r--r-- | src/executable/haskell/Service/AdListener.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/executable/haskell/Service/AdListener.hs b/src/executable/haskell/Service/AdListener.hs index 1025166..f0adbb8 100644 --- a/src/executable/haskell/Service/AdListener.hs +++ b/src/executable/haskell/Service/AdListener.hs @@ -16,6 +16,7 @@ import Model.Mail (Mail (Mail)) import Model.URL (URL) import qualified Parser.LeboncoinParser as LeboncoinParser import qualified Parser.OuestFranceParser as OuestFranceParser +import qualified Parser.SeLogerParser as SeLogerParser import qualified Service.MailService as MailService import qualified Utils.HTTP as HTTP import qualified Utils.Time as TimeUtils @@ -50,7 +51,8 @@ fetchAds :: Conf -> IO [Ad] fetchAds conf = do leboncoinAds <- getLeboncoinAds conf ouestFranceAds <- getOuestFranceAds conf - let results = leboncoinAds ++ ouestFranceAds + seLogerAds <- getSeLogerAds conf + let results = leboncoinAds ++ ouestFranceAds ++ seLogerAds if null results then T.putStrLn "Parsed 0 results!" else return () @@ -72,6 +74,14 @@ getOuestFranceAds conf = . Conf.ouestFranceUrls $ conf +getSeLogerAds :: Conf -> IO [Ad] +getSeLogerAds conf = + fmap (concat . map SeLogerParser.parse . rights) + . sequence + . map (HTTP.get T.decodeUtf8) + . Conf.seLogerUrls + $ conf + sendMail :: Conf -> [Ad] -> IO () sendMail conf ads = let (title, plainBody) = Ad.renderAds ads |