projects
/
xyz.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5a05dd0
)
Automate downloading of video entries
author
Cameron Ball
<cameron@moodle.com>
Thu, 13 Jun 2019 07:54:10 +0000
(15:54 +0800)
committer
Cameron Ball
<cameron@moodle.com>
Thu, 13 Jun 2019 07:54:10 +0000
(15:54 +0800)
app/Main.hs
patch
|
blob
|
history
diff --git
a/app/Main.hs
b/app/Main.hs
index
d68cc4c
..
4d1f781
100644
(file)
--- a/
app/Main.hs
+++ b/
app/Main.hs
@@
-10,7
+10,7
@@
import Prelude hiding (init)
import Data.List (intercalate)
import Text.JSON
import Text.JSON.Generic
import Data.List (intercalate)
import Text.JSON
import Text.JSON.Generic
-import Data.Text hiding (intercalate, unlines, init, length)
+import Data.Text hiding (intercalate, unlines, init, length
, splitAt
)
import Data.Time.Clock.POSIX
import System.File.Tree hiding (mapM, mapM_)
import System.Directory (doesFileExist)
import Data.Time.Clock.POSIX
import System.File.Tree hiding (mapM, mapM_)
import System.Directory (doesFileExist)
@@
-61,12
+61,20
@@
entry :: IO ()
entry = do
putStrLn "Enter a name for this entry:"
entryName <- getLine
entry = do
putStrLn "Enter a name for this entry:"
entryName <- getLine
+ putStrLn "YouTube video ID?"
+ ytUrl <- getLine
+ ytFilename <- if (ytUrl /= "")
+ then putStrLn "Video filename?" >> getLine >>= return . ("::" ++) . (++ ".webm")
+ else return ""
+
entryNum <- fmap ((+1) . length) $ allFilesIn "entries"
stamp <- fmap round getPOSIXTime
let filename = "entries/" ++ (show entryNum) ++ "-" ++ (unpack . (toLower. replace " " "-") $ pack entryName) ++ ".txt"
entryNum <- fmap ((+1) . length) $ allFilesIn "entries"
stamp <- fmap round getPOSIXTime
let filename = "entries/" ++ (show entryNum) ++ "-" ++ (unpack . (toLower. replace " " "-") $ pack entryName) ++ ".txt"
- writeFile filename (show stamp ++ "::" ++ entryName ++
"\n
")
+ writeFile filename (show stamp ++ "::" ++ entryName ++
ytFilename ++ "\nEntry goes here!\nᚳᚱᛒ\n<a href=\"https://www.youtube.com/watch?v=" ++ ytUrl ++ "\">https://www.youtube.com/watch?v=" ++ ytUrl ++ "</a>
")
putStrLn $ "Created " ++ filename
putStrLn $ "Created " ++ filename
- callCommand $ "emacsclient " ++ filename ++ " &"
+ callCommand $ "nano " ++ filename
+ callCommand $ "youtube-dl -f 'webm[height<1080]+bestaudio' \"https://www.youtube.com/watch?v=" ++ ytUrl ++ "\" -o 'build/videos/" ++ (snd . splitAt 2 $ ytFilename) ++ "'"
+ build
usage :: IO ()
usage = putStr . ununlines $ [
usage :: IO ()
usage = putStr . ununlines $ [
@@
-78,9
+86,9
@@
usage = putStr . ununlines $ [
]
]
]
]
-parse ["init"] = init >> exit
-parse ["build"] = continueIfValidProject build >> exit
-parse ["entry"] = continueIfValidProject entry >> exit
+parse ["init"] = init >> exit
Success
+parse ["build"] = continueIfValidProject build >> exit
Success
+parse ["entry"] = continueIfValidProject entry >> exit
Success
parse [_] = usage >> exit
parse [] = usage >> exit
parse [_] = usage >> exit
parse [] = usage >> exit