This commit is contained in:
Norbert Litkowski 2021-04-07 13:19:42 +02:00
parent 15c2e705b1
commit 0442a8c067

View File

@ -8,10 +8,12 @@ import Text.XML.HXT.XPath
import Data.List import Data.List
import Data.List.Utils (replace) import Data.List.Utils (replace)
import Text.Regex.Posix -- import Text.Regex.Posix
import Text.Printf import Text.Printf
import Control.Lens.Regex.Text import Control.Lens.Regex.Text
import Control.Lens.Regex
import Control.Lens
getLinkAndText xpathCondition = proc doc -> do getLinkAndText xpathCondition = proc doc -> do
xpathTrees <- getXPathTrees xpathCondition -< doc xpathTrees <- getXPathTrees xpathCondition -< doc
@ -48,12 +50,7 @@ toShadowItem (((url, releaseTitle), collectionTitle), categoryTitle) =
date = getDate $ releaseTitle date = getDate $ releaseTitle
getDate yearlyTitle = getDate txt = txt ^? [regex|19[0-9][0-9]|20[0-9][0-9]|] . match
case yearlyTitle =~~ "/(19[0-9][0-9]|20[0-9][0-9])/" :: Maybe [[String]] of
Just [[_, year]] -> year
-- otherwise -> error $ "unexpected yearlyTitle: " ++ yearlyTitle
otherwise -> yearlyTitle
main = do main = do
let start = "http://zborbielawa.pl/archiwum/" let start = "http://zborbielawa.pl/archiwum/"