aboutsummaryrefslogtreecommitdiff
path: root/src/Parser/Detail.hs
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-04-18 11:03:56 +0200
committerJoris Guyonvarch2015-04-18 11:03:56 +0200
commita14b3c3d4447cbeb77e4146fba7e0d31393e625e (patch)
treea325de340e88df4706925dd166aefa985f085a06 /src/Parser/Detail.hs
parent3eff27c41a0501d07586b90c8bbb835a3ec86b84 (diff)
downloadad-listener-a14b3c3d4447cbeb77e4146fba7e0d31393e625e.tar.gz
ad-listener-a14b3c3d4447cbeb77e4146fba7e0d31393e625e.tar.bz2
ad-listener-a14b3c3d4447cbeb77e4146fba7e0d31393e625e.zip
Parsing images in detail and show URLs in notifications
Diffstat (limited to 'src/Parser/Detail.hs')
-rw-r--r--src/Parser/Detail.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Parser/Detail.hs b/src/Parser/Detail.hs
index 4144964..3a91ac2 100644
--- a/src/Parser/Detail.hs
+++ b/src/Parser/Detail.hs
@@ -14,12 +14,16 @@ import Parser.Utils
parseDetail :: Text -> Detail
parseDetail page =
let tags = parseTags page
- descriptionTags = getTagsBetween "<div itemprop=description>" "</div>" tags
- description =
- if null descriptionTags
- then
- Nothing
- else
- let replaceBr = map (\tag -> if tag ~== "<br>" then TagText (T.pack "\n") else tag)
- in Just . T.strip . renderTags . replaceBr $ descriptionTags
- in Detail { description = description }
+ description = parseDescription tags
+ images = getTagAttributes "<meta itemprop=image>" (T.pack "content") tags
+ in Detail { description = description, images = images }
+
+parseDescription :: [Tag Text] -> Maybe Text
+parseDescription tags =
+ let descriptionTags = getTagsBetween "<div itemprop=description>" "</div>" tags
+ in if null descriptionTags
+ then
+ Nothing
+ else
+ let replaceBr = map (\tag -> if tag ~== "<br>" then TagText (T.pack "\n") else tag)
+ in Just . T.strip . renderTags . replaceBr $ descriptionTags