summaryrefslogtreecommitdiff
path: root/Annex/YoutubeDl.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Annex/YoutubeDl.hs')
-rw-r--r--Annex/YoutubeDl.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/Annex/YoutubeDl.hs b/Annex/YoutubeDl.hs
index 43e63dfd6..95b6bf762 100644
--- a/Annex/YoutubeDl.hs
+++ b/Annex/YoutubeDl.hs
@@ -24,6 +24,7 @@ import Utility.HtmlDetect
import Logs.Transfer
import Network.URI
+import Control.Concurrent.Async
-- Runs youtube-dl in a work directory, to download a single media file
-- from the url. Reutrns the path to the media file in the work directory.
@@ -168,8 +169,16 @@ youtubeDlFileName' url
, Param "--get-filename"
, Param "--no-warnings"
]
- (output, ok) <- liftIO $ processTranscript "youtube-dl"
- (toCommand opts) Nothing
+ (Nothing, Just o, Just e, pid) <- liftIO $ createProcess
+ (proc "youtube-dl" (toCommand opts))
+ { std_out = CreatePipe
+ , std_err = CreatePipe
+ }
+ output <- liftIO $ fmap fst $
+ hGetContentsStrict o
+ `concurrently`
+ hGetContentsStrict e
+ ok <- liftIO $ checkSuccessProcess pid
return $ case (ok, lines output) of
(True, (f:_)) | not (null f) -> Right f
_ -> nomedia