Move EmbedParser to Common
This commit is contained in:
parent
66e8d902c5
commit
d94ac758ed
|
@ -84,7 +84,7 @@ executable chandlr
|
||||||
Common.AttachmentType
|
Common.AttachmentType
|
||||||
Parsing.BodyParser
|
Parsing.BodyParser
|
||||||
Common.Parsing.QuoteLinkParser
|
Common.Parsing.QuoteLinkParser
|
||||||
Parsing.EmbedParser
|
Common.Parsing.EmbedParser
|
||||||
Common.Parsing.PostPartType
|
Common.Parsing.PostPartType
|
||||||
Common.Component.TimeControl
|
Common.Component.TimeControl
|
||||||
Component.Search
|
Component.Search
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0e5547e7475679cd5a3a449b6f09f0f6d063244e
|
Subproject commit c33593ec634d42eeead0dbbad90c36efc2f5fe54
|
|
@ -25,7 +25,7 @@ import Miso.String (toMisoString, MisoString)
|
||||||
|
|
||||||
import Common.Network.CatalogPostType (CatalogPost)
|
import Common.Network.CatalogPostType (CatalogPost)
|
||||||
import qualified Common.Network.CatalogPostType as CatalogPost
|
import qualified Common.Network.CatalogPostType as CatalogPost
|
||||||
import Parsing.EmbedParser (extractVideoId)
|
import Common.Parsing.EmbedParser (extractVideoId)
|
||||||
|
|
||||||
data Model = Model
|
data Model = Model
|
||||||
{ display_items :: [ CatalogPost ]
|
{ display_items :: [ CatalogPost ]
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
module Parsing.EmbedParser
|
|
||||||
( extractVideoId
|
|
||||||
)
|
|
||||||
where
|
|
||||||
|
|
||||||
import Text.Parsec
|
|
||||||
import Text.Parsec.String
|
|
||||||
|
|
||||||
-- Parser to extract the video ID
|
|
||||||
videoIdParser :: Parser String
|
|
||||||
videoIdParser = do
|
|
||||||
-- Look for the data-video attribute
|
|
||||||
_ <- manyTill anyChar (try (string "data-video=\"") <|> string "href=\"https://youtu.be/")
|
|
||||||
-- Capture the video ID
|
|
||||||
videoId <- manyTill anyChar (try (char '\"') <|> (char '"' >> char ' '))
|
|
||||||
-- Return the captured ID
|
|
||||||
return videoId
|
|
||||||
|
|
||||||
-- Function to apply the parser and extract the video ID
|
|
||||||
extractVideoId :: String -> Either ParseError String
|
|
||||||
extractVideoId input = parse videoIdParser "" input
|
|
Loading…
Reference in New Issue