From 385760778d994f552497c040e6bb9055625f2209 Mon Sep 17 00:00:00 2001 From: horhik Date: Wed, 9 Feb 2022 08:06:36 +0300 Subject: [PATCH] add some comments --- src/Main.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 9aa7b01..9876711 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -4,11 +4,11 @@ import Data.Char import Control.Concurrent import System.Environment import Data.Time.Clock -import qualified Data.ByteString.Lazy.Char8 as L8 import Network.HTTP.Conduit import Data.List.Split import Data.Algorithm.Diff import Data.Algorithm.DiffOutput +import qualified Data.ByteString.Lazy.Char8 as L8 data GeneratorState = IsRunning | IsFinished deriving (Eq) @@ -17,25 +17,23 @@ getChanges :: Diff f -> Bool getChanges (First _) = True getChanges _ = False +-- Should stop the script if there's a checkbox with a keyword `stop` +showRunning :: [String] -> GeneratorState showRunning html = IsRunning -getCheckBoxList html = html - timecodeGenerator :: GeneratorState -> [String] -> UTCTime -> IO () timecodeGenerator IsFinished _ _ = return () timecodeGenerator IsRunning text time = do html <- simpleHttp "https://hd.socks.town/s/h0jnEJQWy/download" let body = (splitOn ("\n")) . L8.unpack $ html print $ filter getChanges $ getDiff body text - + -- Waiting for 1 second threadDelay 1000000 + -- Creating a loop until `IsFinished` if showRunning body == IsRunning then timecodeGenerator IsRunning body time else timecodeGenerator IsFinished body time - - - main :: IO () main = do