From 2ee3d94d3e5fc90a03e94394ff919314c1f33d0b Mon Sep 17 00:00:00 2001 From: horhik Date: Thu, 10 Feb 2022 11:15:38 +0300 Subject: [PATCH] print meta to file for each new timecode-generator start --- .gitignore | 3 ++- src/Main.hs | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e71ea75..cc252e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ dist-newstyle/ -timecodes.md +*.md +*.txt diff --git a/src/Main.hs b/src/Main.hs index 114953e..6cc76e8 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -39,11 +39,16 @@ showRunning html = IsRunning myFormatDiffTime :: (UTCTime, UTCTime) -> String myFormatDiffTime (a,b)= formatTime defaultTimeLocale "%H:%M:%S" . posixSecondsToUTCTime $ diffUTCTime a b +appendToFile :: String -> String -> IO() +appendToFile filename str = do + file <- openFile filename AppendMode + hPutStrLn file str + hClose file + -- Printing changes is they exsists genOutput :: Maybe String -> String -> String -> IO () genOutput (Just changes) time timecodeFile= do - file <- openFile timecodeFile AppendMode - hPutStrLn file $ time ++ "\n " ++ changes + appendToFile timecodeFile $ time ++ "\n " ++ changes genOutput Nothing _ _ = return() -- Returning fetched url as a string separated by \n @@ -79,6 +84,8 @@ main = do let url:timecodeFile:xs = args time <- getCurrentTime file <- fetchFile url + appendToFile timecodeFile $ "New Timecodes starts here \n " + appendToFile timecodeFile $ show time timecodeGenerator IsRunning file time url timecodeFile --let url = "https://hd.socks.town/s/h0jnEJQWy/download"