From: Cameron Ball Date: Thu, 13 Jun 2019 08:00:22 +0000 (+0800) Subject: Case for when there is no video X-Git-Url: http://cameron1729.xyz/?p=xyz.git;a=commitdiff_plain;h=45bc5cf4387301ea11596e02e4d34e35bacada1d Case for when there is no video --- diff --git a/app/Main.hs b/app/Main.hs index 4d1f781..0b0c25b 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -67,13 +67,19 @@ entry = do then putStrLn "Video filename?" >> getLine >>= return . ("::" ++) . (++ ".webm") else return "" + ytLink <- if (ytUrl /= "") + then return $ "\nhttps://www.youtube.com/watch?v=" ++ ytUrl ++ "" + else return "" + 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 ++ ytFilename ++ "\nEntry goes here!\nᚳᚱᛒ\nhttps://www.youtube.com/watch?v=" ++ ytUrl ++ "") + writeFile filename (show stamp ++ "::" ++ entryName ++ ytFilename ++ "\nEntry goes here!\nᚳᚱᛒ" ++ ytLink) putStrLn $ "Created " ++ 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) ++ "'" + if (ytUrl /= "") + then callCommand $ "youtube-dl -f 'webm[height<1080]+bestaudio' \"https://www.youtube.com/watch?v=" ++ ytUrl ++ "\" -o 'build/videos/" ++ (snd . splitAt 2 $ ytFilename) ++ "'" + else return () build usage :: IO ()