added some basic server stuff
This commit is contained in:
parent
a1a1401a1d
commit
84897aea9c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
dist-newstyle
|
13
LICENSE
Normal file
13
LICENSE
Normal file
|
@ -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.
|
64
src/Main.hs
Normal file
64
src/Main.hs
Normal file
|
@ -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)
|
3
todo
Normal file
3
todo
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bindings to python youtube-dl library, avoid invoking it as a program at all costs
|
||||||
|
|
||||||
|
configuration for scotty and redis
|
28
viddl.cabal
Normal file
28
viddl.cabal
Normal file
|
@ -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
|
|
@ -7,7 +7,7 @@
|
||||||
<body>
|
<body>
|
||||||
<center>
|
<center>
|
||||||
<h1>viddl</h1>
|
<h1>viddl</h1>
|
||||||
<p>Download videos from sources such as youtube, vimeo, video, <a href="https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md">and more!</a></p>
|
<p>Download videos from sources such as youtube, twitter, vimeo <a href="https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md">and more!</a></p>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<input required name="url" type="text" placeholder="Enter url here"><br>
|
<input required name="url" type="text" placeholder="Enter url here"><br>
|
||||||
<label for="resolution">res</label>
|
<label for="resolution">res</label>
|
||||||
<select required name="resolution">
|
<select required name="resolution">
|
||||||
<option value="max">Smallest Possible</option>
|
<option value="min">Smallest Possible</option>
|
||||||
<option value="144p">144p</option>
|
<option value="144p">144p</option>
|
||||||
<option value="240p">240p</option>
|
<option value="240p">240p</option>
|
||||||
<option value="360p">360p</option>
|
<option value="360p">360p</option>
|
||||||
|
@ -37,5 +37,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<hr>
|
||||||
|
<p>viddl is free <a href="https://github.com/depsterr/viddl">open source</a> software and is powered by <a href="https://yt-dl.org/">youtube-dl</a>.</p>
|
||||||
</center>
|
</center>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -8,5 +8,7 @@
|
||||||
<center>
|
<center>
|
||||||
<h1>viddl</h1>
|
<h1>viddl</h1>
|
||||||
<p>Your request is being processed... Please wait...</p>
|
<p>Your request is being processed... Please wait...</p>
|
||||||
|
<hr>
|
||||||
|
<p>viddl is free <a href="https://github.com/depsterr/viddl">open source</a> software and is powered by <a href="https://yt-dl.org/">youtube-dl</a>.</p>
|
||||||
</center>
|
</center>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user