add url property to fetchFile

This commit is contained in:
horhik 2022-02-10 10:09:44 +03:00
parent e03153780b
commit 6969f8db3f
1 changed files with 12 additions and 11 deletions

View File

@ -47,16 +47,16 @@ genOutput (Just changes) time = do
genOutput Nothing _ = return() genOutput Nothing _ = return()
fetchFile :: IO [String] fetchFile :: String -> IO [String]
fetchFile = do fetchFile url = do
html <- simpleHttp "https://hd.socks.town/s/h0jnEJQWy/download" html <- simpleHttp url
return $ (splitOn ("\n")) . toString $ html return $ (splitOn ("\n")) . toString $ html
-- Main Loop -- Main Loop
timecodeGenerator :: GeneratorState -> [String] -> UTCTime -> IO () timecodeGenerator :: GeneratorState -> [String] -> UTCTime -> String -> IO ()
timecodeGenerator IsFinished _ _ = return () timecodeGenerator IsFinished _ _ _ = return ()
timecodeGenerator IsRunning prevFile time = do timecodeGenerator IsRunning prevFile time url = do
newFile <- fetchFile newFile <- fetchFile url
currTime <- getCurrentTime currTime <- getCurrentTime
let changes = getChanges newFile prevFile let changes = getChanges newFile prevFile
let diffTime = myFormatDiffTime (currTime, time) let diffTime = myFormatDiffTime (currTime, time)
@ -66,12 +66,13 @@ timecodeGenerator IsRunning prevFile time = do
threadDelay 10000 threadDelay 10000
-- Creating a loop until `IsFinished` -- Creating a loop until `IsFinished`
if showRunning newFile == IsRunning then if showRunning newFile == IsRunning then
timecodeGenerator IsRunning newFile time timecodeGenerator IsRunning newFile time url
else else
timecodeGenerator IsFinished newFile time timecodeGenerator IsFinished newFile time url
main :: IO () main :: IO ()
main = do main = do
let url = "https://hd.socks.town/s/h0jnEJQWy/download"
time <- getCurrentTime time <- getCurrentTime
file <- fetchFile file <- fetchFile url
timecodeGenerator IsRunning file time timecodeGenerator IsRunning file time url