add some comments

This commit is contained in:
horhik 2022-02-09 08:06:36 +03:00
parent bc8b37cfd4
commit 385760778d

View file

@ -4,11 +4,11 @@ import Data.Char
import Control.Concurrent import Control.Concurrent
import System.Environment import System.Environment
import Data.Time.Clock import Data.Time.Clock
import qualified Data.ByteString.Lazy.Char8 as L8
import Network.HTTP.Conduit import Network.HTTP.Conduit
import Data.List.Split import Data.List.Split
import Data.Algorithm.Diff import Data.Algorithm.Diff
import Data.Algorithm.DiffOutput import Data.Algorithm.DiffOutput
import qualified Data.ByteString.Lazy.Char8 as L8
data GeneratorState = IsRunning | IsFinished data GeneratorState = IsRunning | IsFinished
deriving (Eq) deriving (Eq)
@ -17,25 +17,23 @@ getChanges :: Diff f -> Bool
getChanges (First _) = True getChanges (First _) = True
getChanges _ = False getChanges _ = False
-- Should stop the script if there's a checkbox with a keyword `stop`
showRunning :: [String] -> GeneratorState
showRunning html = IsRunning showRunning html = IsRunning
getCheckBoxList html = html
timecodeGenerator :: GeneratorState -> [String] -> UTCTime -> IO () timecodeGenerator :: GeneratorState -> [String] -> UTCTime -> IO ()
timecodeGenerator IsFinished _ _ = return () timecodeGenerator IsFinished _ _ = return ()
timecodeGenerator IsRunning text time = do timecodeGenerator IsRunning text time = do
html <- simpleHttp "https://hd.socks.town/s/h0jnEJQWy/download" html <- simpleHttp "https://hd.socks.town/s/h0jnEJQWy/download"
let body = (splitOn ("\n")) . L8.unpack $ html let body = (splitOn ("\n")) . L8.unpack $ html
print $ filter getChanges $ getDiff body text print $ filter getChanges $ getDiff body text
-- Waiting for 1 second
threadDelay 1000000 threadDelay 1000000
-- Creating a loop until `IsFinished`
if showRunning body == IsRunning then if showRunning body == IsRunning then
timecodeGenerator IsRunning body time timecodeGenerator IsRunning body time
else else
timecodeGenerator IsFinished body time timecodeGenerator IsFinished body time
main :: IO () main :: IO ()
main = do main = do