add url property to fetchFile
This commit is contained in:
parent
e03153780b
commit
6969f8db3f
23
src/Main.hs
23
src/Main.hs
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue