diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48a004c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist-newstyle diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7e27a59 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2021 depsterr + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..df9a3fa --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,64 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Main where + +import qualified Database.Redis as R +import qualified Data.Text.Lazy as TL +import Web.Scotty +import System.Posix.Process (executeFile) + +data Resolution + = P144 + | P240 + | P360 + | P480 + | P720 + | P1080 + | PMAX + | PMIN + deriving (Eq, Show) + +getRes :: String -> Maybe Resolution +getRes ("144p") = P144 +getRes ("240p") = P240 +getRes ("360p") = P360 +getRes ("480p") = P480 +getRes ("720p") = P720 +getRes ("1080p") = P1080 +getRes ("min") = PMAX +getRes ("max") = PMIN + +downloadVideo :: String -> Resolution -> IO Filepath +downloadVideo url res = do + undefined + +downloadAudio :: String -> IO Filepath +downloadAudio url = do + undefined + +getIndex :: IO String +getIndex = readFile "views/index.html" + +app :: R.Connection -> ScottyM () +app rConn = do + get "/" $ do + setHeader "Content-Type" "text/html;charset=utf-8" + file "views/index.html" + + post "/" $ do + setHeader "Content-Type" "text/html;charset=utf-8" + file "views/loading.html" + url <- param "url" + res <- param "resolution" + -- set redis stuff and id here + redirect '/':id + + get "/:id" $ do + -- grab id and process video if not already done + id <- param "id" + +main :: IO () +main = do + -- todo: parse connection config + rConn <- R.connect R.defaultConnectInfo + scotty 3000 (app rConn) diff --git a/todo b/todo new file mode 100644 index 0000000..a80dc44 --- /dev/null +++ b/todo @@ -0,0 +1,3 @@ +bindings to python youtube-dl library, avoid invoking it as a program at all costs + +configuration for scotty and redis diff --git a/viddl.cabal b/viddl.cabal new file mode 100644 index 0000000..96f9b45 --- /dev/null +++ b/viddl.cabal @@ -0,0 +1,28 @@ +cabal-version: 2.0 +name: viddl +version: 0.1.0.0 +synopsis: A web interface to youtube-dl +-- description: +homepage: +-- bug-reports: +license: ISC +license-file: LICENSE +author: depsterr +maintainer: depsterr@protonmail.com +category: Web +build-type: Simple +extra-source-files: CHANGELOG.md + +executable viddl + main-is: Main.hs + -- other-modules: + -- other-extensions: + ghc-options: -Wall -O2 + build-depends: base ^>=4.14.1.0 + , scotty + , hedis + , transformers + , text + , unix + hs-source-dirs: src + default-language: Haskell2010 diff --git a/views/index.html b/views/index.html index a688e6d..9b1e71e 100644 --- a/views/index.html +++ b/views/index.html @@ -7,7 +7,7 @@

viddl

-

Download videos from sources such as youtube, vimeo, video, and more!

+

Download videos from sources such as youtube, twitter, vimeo and more!

@@ -16,7 +16,7 @@
+
+

viddl is free open source software and is powered by youtube-dl.

diff --git a/views/loading.html b/views/loading.html index 7d93022..1a39321 100644 --- a/views/loading.html +++ b/views/loading.html @@ -8,5 +8,7 @@

viddl

Your request is being processed... Please wait...

+
+

viddl is free open source software and is powered by youtube-dl.