initial commit

This commit is contained in:
horhik 2022-02-08 22:20:34 +03:00
parent 632034cbd2
commit 26ce916e80
4 changed files with 92 additions and 0 deletions

32
default.nix Normal file
View File

@ -0,0 +1,32 @@
let
compilerVersion = "ghc8107";
compilerSet = pkgs.haskell.packages."${compilerVersion}";
pkgs = import <nixpkgs> { 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
];
};
}

1
shell.nix Normal file
View File

@ -0,0 +1 @@
(import ./default.nix).shell

39
src/Main.hs Normal file
View File

@ -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

20
timecode-generator.cabal Normal file
View File

@ -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