diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..685ceaa --- /dev/null +++ b/default.nix @@ -0,0 +1,32 @@ +let + compilerVersion = "ghc8107"; + compilerSet = pkgs.haskell.packages."${compilerVersion}"; + + + pkgs = import { inherit config; }; + gitIgnore = pkgs.nix-gitignore.gitignoreSourcePure; + + config = { + packageOverrides = super: let self = super.pkgs; in rec { + haskell = super.haskell // { + packageOverrides = self: super: { + haskell-nix = super.callCabal2nix "timecode-generator" (gitIgnore [./.gitignore] ./.) {}; + }; + }; + }; + }; + +in { + inherit pkgs; + shell = compilerSet.shellFor { + packages = p: [p.haskell-nix]; + buildInputs = with pkgs; [ + compilerSet.cabal-install + haskellPackages.tagsoup + haskellPackages.HTTP + haskellPackages.zlib + zlib + ]; + }; +} + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..af299aa --- /dev/null +++ b/shell.nix @@ -0,0 +1 @@ +(import ./default.nix).shell diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..6558cbe --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,39 @@ +module Main where + +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 + +data GeneratorState = IsRunning | IsFinished + deriving (Eq) + +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 $ getDiff body text + + threadDelay 1000000 + if showRunning body == IsRunning then + timecodeGenerator IsRunning body time + else + timecodeGenerator IsFinished body time + + + + +main :: IO () +main = do + time <- getCurrentTime + timecodeGenerator IsRunning [""] time diff --git a/timecode-generator.cabal b/timecode-generator.cabal new file mode 100644 index 0000000..ac9142e --- /dev/null +++ b/timecode-generator.cabal @@ -0,0 +1,20 @@ +cabal-version: >= 2.0 +name: timecode-generator +version: 0.1.0 +build-type: Simple + +executable timecode-generator + hs-source-dirs: src + main-is: Main.hs + default-language: Haskell2010 + build-depends: + base >= 4.14.3, + bytestring, + aeson, + time, + split, + HTTP >= 4000, + http-client>= 0.6.4.1, + http-conduit >= 2.3.8, + tagsoup >= 0.14.6, + Diff