module HBooru.Parsers.Ichijou where
import Data.List
import HBooru.Parsers.FieldParsers
import HBooru.Types
import Text.XML.HXT.Core hiding (mkName)
data Ichijou = Ichijou deriving (Show, Eq)
type IchijouPost = PR
'[ "creator_id"
, "md5"
, "status"
, "preview_height"
, "has_notes"
, "author"
, "source"
, "score"
, "file_size"
, "sample_width"
, "width"
, "file_url"
, "sample_height"
, "has_children"
, "tags"
, "change"
, "preview_url"
, "has_comments"
, "id"
, "sample_url"
, "rating"
, "created_at"
, "preview_width"
, "parent_id"
, "height"
]
parsePost ∷ (Functor (cat XmlTree), ArrowXml cat) ⇒ cat XmlTree IchijouPost
parsePost = hasName "post"
>>> creator_idA <:+> md5A <:+> statusA <:+> preview_heightA <:+> has_notesA
<:+> authorA <:+> sourceA <:+> scoreA <:+> file_sizeA <:+> sample_widthA
<:+> widthA <:+> file_urlA <:+> sample_heightA <:+> has_childrenA <:+> tagsA
<:+> changeA <:+> preview_urlA <:+> has_commentsA <:+> idA <:+> sample_urlA
<:+> ratingA <:+> created_atA <:+> preview_widthA <:+> parent_idA <:+> heightA
instance Postable Ichijou XML where
postUrl _ _ ts =
let tags' = intercalate "+" ts
in "http://ichijou.org/post/index.xml?tags=" ++ tags'
hardLimit _ _ = Limit 1000
instance PostablePaged Ichijou XML where
postUrlPaged s r ts i = postUrl s r ts ++ "&page=" ++ show (i + 1)
instance Site Ichijou where
instance PostParser Ichijou XML where
type ImageTy Ichijou XML = IchijouPost
parseResponse _ = runLA (xreadDoc /> parsePost) . getResponse
instance Counted Ichijou XML where
parseCount _ = read . head . runLA (xreadDoc >>> hasName "posts"
>>> getAttrValue "count") . getResponse